@deveye/types 0.24.6 → 0.25.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/feedback.ts +12 -4
- package/src/domain/home.ts +13 -0
- package/src/domain/live.ts +8 -0
- package/src/domain/loginChecks.ts +72 -0
- package/src/domain/role.ts +9 -3
- package/src/domain/stepUp.ts +29 -0
- package/src/domain/user.ts +24 -5
- package/src/domain/workspace.ts +21 -0
- package/src/domain/workspaceRole.ts +1 -1
- package/src/features/admin.ts +60 -3
- package/src/features/feedback.ts +8 -7
- package/src/features/loginChecks.ts +102 -0
- package/src/features/registry.ts +4 -0
- package/src/features/stepUp.ts +26 -0
- package/src/features/twoFactor.ts +13 -6
- package/src/features/user.ts +23 -0
- package/src/features/workspace.ts +63 -7
- package/src/http/auth.ts +44 -12
- package/src/http/device.ts +10 -1
- package/src/index.ts +69 -6
- package/src/protocol/agent.ts +25 -8
- package/src/protocol/error.ts +5 -1
- package/src/sdk/client-ambient.d.ts +39 -9
- package/src/sdk/client.ts +7 -7
- package/src/sdk/copy.test.ts +23 -0
- package/src/sdk/copy.ts +24 -2
- package/src/sdk/csv.test.ts +28 -0
- package/src/sdk/csv.ts +24 -0
- package/src/sdk/deviceRelay.ts +8 -2
- package/src/sdk/index.ts +1 -0
- package/src/sdk/manifest.ts +25 -7
- package/src/sdk/net.test.ts +10 -2
- package/src/sdk/net.ts +35 -30
- package/src/sdk/providers.ts +7 -0
- package/src/sdk/server.ts +132 -16
- package/src/sdk/testing.test.ts +1 -0
- package/src/sdk/testing.ts +48 -13
|
@@ -66,7 +66,20 @@ export const workspaceLeave = {
|
|
|
66
66
|
output: z.object({ workspaceId: z.number().int().positive() })
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Ce qu'un départ emporte avec le membre : les projections qu'il avait réglées
|
|
71
|
+
* entre cet espace et d'autres, dans les deux sens, nommées pour la
|
|
72
|
+
* confirmation. Pour soi-même, ou pour un autre avec `workspace.members`.
|
|
73
|
+
*/
|
|
74
|
+
export const workspaceMemberShares = {
|
|
75
|
+
command: 'workspace.memberShares' as const,
|
|
76
|
+
input: z.object({ userId: z.number().int().positive() }),
|
|
77
|
+
output: z.object({
|
|
78
|
+
shares: z.array(z.object({ feature: z.string(), label: z.string() }))
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Exclut un membre de l'espace actif, et retire ses projections avec lui. */
|
|
70
83
|
export const workspaceRemoveMember = {
|
|
71
84
|
command: 'workspace.removeMember' as const,
|
|
72
85
|
input: z.object({ userId: z.number().int().positive() }),
|
|
@@ -74,16 +87,54 @@ export const workspaceRemoveMember = {
|
|
|
74
87
|
};
|
|
75
88
|
|
|
76
89
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
90
|
+
* Invite une adresse à rejoindre l'espace actif. La réponse ne dit jamais si un
|
|
91
|
+
* compte porte cette adresse : l'invitation est posée telle quelle, et c'est le
|
|
92
|
+
* compte qui l'accepte (`workspace.acceptInvite`) ou la refuse.
|
|
80
93
|
*/
|
|
81
|
-
export const
|
|
82
|
-
command: 'workspace.
|
|
94
|
+
export const workspaceInvite = {
|
|
95
|
+
command: 'workspace.invite' as const,
|
|
83
96
|
input: z.object({ email: z.string().email() }),
|
|
97
|
+
output: z.object({})
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Les invitations en attente de l'espace actif, pour qui gère ses membres. */
|
|
101
|
+
export const workspaceInvitations = {
|
|
102
|
+
command: 'workspace.invitations' as const,
|
|
103
|
+
input: z.object({}),
|
|
104
|
+
output: z.object({
|
|
105
|
+
invitations: z.array(
|
|
106
|
+
z.object({
|
|
107
|
+
id: z.number().int().positive(),
|
|
108
|
+
email: z.string(),
|
|
109
|
+
/** Seconds. */
|
|
110
|
+
expiresAt: z.number().int().nonnegative()
|
|
111
|
+
})
|
|
112
|
+
)
|
|
113
|
+
})
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const workspaceCancelInvite = {
|
|
117
|
+
command: 'workspace.cancelInvite' as const,
|
|
118
|
+
input: z.object({ invitationId: z.number().int().positive() }),
|
|
119
|
+
output: z.object({ invitationId: z.number().int().positive() })
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Accepte une invitation adressée à l'appelant : il devient membre de l'espace,
|
|
124
|
+
* avec le rôle fixé à l'invitation. L'espace rendu est celui qu'il rejoint.
|
|
125
|
+
*/
|
|
126
|
+
export const workspaceAcceptInvite = {
|
|
127
|
+
command: 'workspace.acceptInvite' as const,
|
|
128
|
+
input: z.object({ invitationId: z.number().int().positive() }),
|
|
84
129
|
output: z.object({ workspace: workspaceSchema })
|
|
85
130
|
};
|
|
86
131
|
|
|
132
|
+
export const workspaceDeclineInvite = {
|
|
133
|
+
command: 'workspace.declineInvite' as const,
|
|
134
|
+
input: z.object({ invitationId: z.number().int().positive() }),
|
|
135
|
+
output: z.object({ invitationId: z.number().int().positive() })
|
|
136
|
+
};
|
|
137
|
+
|
|
87
138
|
/** Le contenu modifiable d'un rôle. */
|
|
88
139
|
const roleDraftSchema = z.object({
|
|
89
140
|
name: z.string().min(1).max(WORKSPACE_ROLE_NAME_MAX),
|
|
@@ -157,8 +208,13 @@ export const workspaceCommands = [
|
|
|
157
208
|
workspaceAssignRole,
|
|
158
209
|
workspaceRename,
|
|
159
210
|
workspaceLeave,
|
|
211
|
+
workspaceMemberShares,
|
|
160
212
|
workspaceRemoveMember,
|
|
161
|
-
|
|
213
|
+
workspaceInvite,
|
|
214
|
+
workspaceInvitations,
|
|
215
|
+
workspaceCancelInvite,
|
|
216
|
+
workspaceAcceptInvite,
|
|
217
|
+
workspaceDeclineInvite,
|
|
162
218
|
workspaceAdd,
|
|
163
219
|
workspaceDelete,
|
|
164
220
|
workspaceActivate,
|
package/src/http/auth.ts
CHANGED
|
@@ -46,7 +46,9 @@ export type SessionBundle = z.infer<typeof sessionBundleSchema>;
|
|
|
46
46
|
|
|
47
47
|
export const loginRequestSchema = z.object({
|
|
48
48
|
username: z.string().min(1).max(120),
|
|
49
|
-
password: z.string().min(1).max(512)
|
|
49
|
+
password: z.string().min(1).max(512),
|
|
50
|
+
/** A federated page's trusted-browser token for this account; a same-origin page holds a cookie instead. */
|
|
51
|
+
trustToken: z.string().max(256).optional()
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
@@ -84,33 +86,63 @@ export const changePasswordResponseSchema = z.object({
|
|
|
84
86
|
|
|
85
87
|
export type ChangePasswordResponse = z.infer<typeof changePasswordResponseSchema>;
|
|
86
88
|
|
|
89
|
+
/**
|
|
90
|
+
* What may stand between a correct password and a session, in this order: a
|
|
91
|
+
* code mailed to a browser the account does not know, the authenticator app,
|
|
92
|
+
* a code texted to that browser.
|
|
93
|
+
*/
|
|
94
|
+
export const loginStepSchema = z.enum(['email', 'totp', 'sms']);
|
|
95
|
+
|
|
96
|
+
export type LoginStep = z.infer<typeof loginStepSchema>;
|
|
97
|
+
|
|
98
|
+
/** A login waiting for the code of `step`. */
|
|
99
|
+
export const loginPendingSchema = z.object({
|
|
100
|
+
status: z.literal('pending'),
|
|
101
|
+
step: loginStepSchema,
|
|
102
|
+
/** Where the code went, masked (`g•••@gmail.com`, `•• •• •• 12 34`). */
|
|
103
|
+
to: z.string().optional(),
|
|
104
|
+
/** The challenge, for a federated origin (no cookie holds it there). */
|
|
105
|
+
challenge: z.string().optional()
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export type LoginPending = z.infer<typeof loginPendingSchema>;
|
|
109
|
+
|
|
87
110
|
/**
|
|
88
111
|
* The auth flow returns the authenticated user and its workspaces in one shot.
|
|
89
112
|
* Tokens are delivered as HttpOnly cookies, never in the JSON body, except to a
|
|
90
113
|
* federated origin (`tokens`, see {@link sessionTokensSchema}).
|
|
91
114
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* client then posts a TOTP/backup code.
|
|
115
|
+
* A login may first reply `pending`: each code posted to `/login/verify` moves
|
|
116
|
+
* to the next step, until the session opens (`signedIn`).
|
|
95
117
|
*/
|
|
96
|
-
export const loginResponseSchema = z.discriminatedUnion('
|
|
118
|
+
export const loginResponseSchema = z.discriminatedUnion('status', [
|
|
97
119
|
sessionBundleSchema.extend({
|
|
98
|
-
|
|
99
|
-
tokens: sessionTokensSchema.optional()
|
|
120
|
+
status: z.literal('signedIn'),
|
|
121
|
+
tokens: sessionTokensSchema.optional(),
|
|
122
|
+
/** A federated page's new trusted-browser token, when it asked to be trusted. */
|
|
123
|
+
trustToken: z.string().optional()
|
|
100
124
|
}),
|
|
101
|
-
|
|
125
|
+
loginPendingSchema
|
|
102
126
|
]);
|
|
103
127
|
|
|
104
128
|
export type LoginResponse = z.infer<typeof loginResponseSchema>;
|
|
105
129
|
|
|
106
|
-
|
|
107
|
-
|
|
130
|
+
/** `POST /api/auth/login/verify`: the code of the current step. */
|
|
131
|
+
export const loginVerifyRequestSchema = z.object({
|
|
132
|
+
/** Six digits, or a recovery code on the `totp` step. */
|
|
108
133
|
code: z.string().min(6).max(24),
|
|
109
|
-
/**
|
|
134
|
+
/** Trust this browser: its next logins skip the mailed and texted codes. */
|
|
135
|
+
trust: z.boolean().optional(),
|
|
136
|
+
/** The challenge handed by `/login`, from a federated origin. */
|
|
110
137
|
challenge: z.string().max(2048).optional()
|
|
111
138
|
});
|
|
112
139
|
|
|
113
|
-
export type
|
|
140
|
+
export type LoginVerifyRequest = z.infer<typeof loginVerifyRequestSchema>;
|
|
141
|
+
|
|
142
|
+
/** `POST /api/auth/login/resend` and `/login/cancel`: only a federated origin names its challenge. */
|
|
143
|
+
export const loginChallengeRequestSchema = z.object({ challenge: z.string().max(2048).optional() });
|
|
144
|
+
|
|
145
|
+
export type LoginChallengeRequest = z.infer<typeof loginChallengeRequestSchema>;
|
|
114
146
|
|
|
115
147
|
/** Body of `/refresh` and `/logout` from a federated origin; a same-origin page sends none. */
|
|
116
148
|
export const refreshRequestSchema = z.object({ refreshToken: z.string().max(2048) });
|
package/src/http/device.ts
CHANGED
|
@@ -173,7 +173,16 @@ export const agentTargetStatusSchema = z.object({
|
|
|
173
173
|
/** Whether the binary is present on the server (greys it out in the UI). */
|
|
174
174
|
available: z.boolean(),
|
|
175
175
|
/** Size in bytes when available, else `null`. */
|
|
176
|
-
sizeBytes: z.number().int().nonnegative().nullable()
|
|
176
|
+
sizeBytes: z.number().int().nonnegative().nullable(),
|
|
177
|
+
/**
|
|
178
|
+
* SHA-256 of the served binary, from the release manifest: what a user
|
|
179
|
+
* compares before running a binary fetched by hand. `null` when the
|
|
180
|
+
* binary is absent or no manifest names it (a local build).
|
|
181
|
+
*/
|
|
182
|
+
sha256: z
|
|
183
|
+
.string()
|
|
184
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
185
|
+
.nullable()
|
|
177
186
|
});
|
|
178
187
|
|
|
179
188
|
export type AgentTargetStatus = z.infer<typeof agentTargetStatusSchema>;
|
package/src/index.ts
CHANGED
|
@@ -526,7 +526,7 @@ export type {
|
|
|
526
526
|
} from './domain/project';
|
|
527
527
|
export { presenceEventSchema } from './domain/presence';
|
|
528
528
|
export type { PresenceEvent, PresenceRow } from './domain/presence';
|
|
529
|
-
export { userRoleSchema } from './domain/role';
|
|
529
|
+
export { canModerate, userRoleSchema } from './domain/role';
|
|
530
530
|
export type { UserRole } from './domain/role';
|
|
531
531
|
export {
|
|
532
532
|
homeFeatureIdSchema,
|
|
@@ -546,6 +546,7 @@ export {
|
|
|
546
546
|
isFeatureTile,
|
|
547
547
|
isHomeFolder,
|
|
548
548
|
isShortcutTile,
|
|
549
|
+
placedFeatureIds,
|
|
549
550
|
shortcutItemSchema,
|
|
550
551
|
shortcutPreviewSchema,
|
|
551
552
|
shortcutTemplateSchema,
|
|
@@ -652,7 +653,11 @@ export type {
|
|
|
652
653
|
SecrecyWrapMode,
|
|
653
654
|
UserSecretKeyRow
|
|
654
655
|
} from './domain/secrecy';
|
|
655
|
-
export {
|
|
656
|
+
export {
|
|
657
|
+
WORKSPACE_INVITATION_TTL_SECONDS,
|
|
658
|
+
workspaceKindSchema,
|
|
659
|
+
workspaceSchema
|
|
660
|
+
} from './domain/workspace';
|
|
656
661
|
export {
|
|
657
662
|
REMOTE_INSTANCES_MAX,
|
|
658
663
|
REMOTE_LABEL_MAX,
|
|
@@ -690,6 +695,7 @@ export type {
|
|
|
690
695
|
} from './domain/workspaceRole';
|
|
691
696
|
export type {
|
|
692
697
|
Workspace,
|
|
698
|
+
WorkspaceInvitationRow,
|
|
693
699
|
WorkspaceKind,
|
|
694
700
|
WorkspaceMemberRow,
|
|
695
701
|
WorkspaceRow
|
|
@@ -895,6 +901,25 @@ export type {
|
|
|
895
901
|
MetricsResolution
|
|
896
902
|
} from './domain/metrics';
|
|
897
903
|
export { twoFactorSetupSchema, twoFactorStatusSchema } from './domain/twoFactor';
|
|
904
|
+
export {
|
|
905
|
+
STEP_UP_MINUTES_DEFAULT,
|
|
906
|
+
STEP_UP_MINUTES_MAX,
|
|
907
|
+
STEP_UP_MINUTES_MIN,
|
|
908
|
+
STEP_UP_STRICT_MINUTES,
|
|
909
|
+
stepUpRequiredDetailsSchema,
|
|
910
|
+
stepUpStatusSchema
|
|
911
|
+
} from './domain/stepUp';
|
|
912
|
+
export type { StepUpRequiredDetails, StepUpStatus } from './domain/stepUp';
|
|
913
|
+
export {
|
|
914
|
+
LOGIN_HISTORY_DAYS,
|
|
915
|
+
LOGIN_HISTORY_WINDOW_DAYS,
|
|
916
|
+
loginChecksStatusSchema,
|
|
917
|
+
loginEntrySchema,
|
|
918
|
+
TRUSTED_BROWSER_DAYS,
|
|
919
|
+
TRUSTED_BROWSERS_MAX,
|
|
920
|
+
trustedBrowserSchema
|
|
921
|
+
} from './domain/loginChecks';
|
|
922
|
+
export type { LoginChecksStatus, LoginEntry, TrustedBrowser } from './domain/loginChecks';
|
|
898
923
|
export type {
|
|
899
924
|
BackupCodeRow,
|
|
900
925
|
TwoFactorRow,
|
|
@@ -919,6 +944,9 @@ export {
|
|
|
919
944
|
adminDeleteUser,
|
|
920
945
|
adminExternalServices,
|
|
921
946
|
adminExternalServicesSchema,
|
|
947
|
+
adminFeatureFactSchema,
|
|
948
|
+
adminFeatureStats,
|
|
949
|
+
adminFeatureStatsSchema,
|
|
922
950
|
adminMaintenanceDismissNotice,
|
|
923
951
|
adminMaintenanceFeature,
|
|
924
952
|
adminMaintenanceGet,
|
|
@@ -927,12 +955,21 @@ export {
|
|
|
927
955
|
adminMaintenanceSeats,
|
|
928
956
|
adminMaintenanceSignups,
|
|
929
957
|
adminMaintenanceSite,
|
|
958
|
+
adminPending,
|
|
959
|
+
adminPendingSchema,
|
|
930
960
|
adminSetUserRole,
|
|
931
961
|
adminSetUserStatus,
|
|
932
962
|
adminUserList,
|
|
933
963
|
adminUserSchema
|
|
934
964
|
} from './features/admin';
|
|
935
|
-
export type {
|
|
965
|
+
export type {
|
|
966
|
+
AdminExternalServices,
|
|
967
|
+
AdminFeatureFact,
|
|
968
|
+
AdminFeatureStats,
|
|
969
|
+
AdminMaintenance,
|
|
970
|
+
AdminPending,
|
|
971
|
+
AdminUser
|
|
972
|
+
} from './features/admin';
|
|
936
973
|
export {
|
|
937
974
|
debugBenchCatalog,
|
|
938
975
|
debugBenchContextSchema,
|
|
@@ -999,8 +1036,13 @@ export {
|
|
|
999
1036
|
workspaceCommands,
|
|
1000
1037
|
workspaceDelete,
|
|
1001
1038
|
workspaceLeave,
|
|
1039
|
+
workspaceMemberShares,
|
|
1002
1040
|
workspaceRemoveMember,
|
|
1003
|
-
|
|
1041
|
+
workspaceInvite,
|
|
1042
|
+
workspaceInvitations,
|
|
1043
|
+
workspaceCancelInvite,
|
|
1044
|
+
workspaceAcceptInvite,
|
|
1045
|
+
workspaceDeclineInvite,
|
|
1004
1046
|
workspaceAssignRole,
|
|
1005
1047
|
workspaceRename,
|
|
1006
1048
|
workspaceRoleCreate,
|
|
@@ -1030,6 +1072,7 @@ export {
|
|
|
1030
1072
|
userExportPartSchema,
|
|
1031
1073
|
userExportPrepare,
|
|
1032
1074
|
userExportPreview,
|
|
1075
|
+
userInvitations,
|
|
1033
1076
|
userPlan,
|
|
1034
1077
|
userSetAvatar,
|
|
1035
1078
|
userSetColor,
|
|
@@ -1080,6 +1123,20 @@ export {
|
|
|
1080
1123
|
notifyRouteSet,
|
|
1081
1124
|
notifyRouteTest
|
|
1082
1125
|
} from './features/notify';
|
|
1126
|
+
export { stepUpCommands, stepUpConfirm, stepUpSetInterval, stepUpStatus } from './features/stepUp';
|
|
1127
|
+
export {
|
|
1128
|
+
loginChecksCommands,
|
|
1129
|
+
loginChecksForgetBrowser,
|
|
1130
|
+
loginChecksForgetBrowsers,
|
|
1131
|
+
loginChecksHistory,
|
|
1132
|
+
loginChecksLogoutOthers,
|
|
1133
|
+
loginChecksPhoneConfirm,
|
|
1134
|
+
loginChecksPhoneRemove,
|
|
1135
|
+
loginChecksPhoneStart,
|
|
1136
|
+
loginChecksSetEmail,
|
|
1137
|
+
loginChecksSetSms,
|
|
1138
|
+
loginChecksStatus
|
|
1139
|
+
} from './features/loginChecks';
|
|
1083
1140
|
export {
|
|
1084
1141
|
twoFactorCommands,
|
|
1085
1142
|
twoFactorDisable,
|
|
@@ -1127,8 +1184,12 @@ export type { FeedbackFilter } from './features/feedback';
|
|
|
1127
1184
|
export {
|
|
1128
1185
|
changePasswordRequestSchema,
|
|
1129
1186
|
changePasswordResponseSchema,
|
|
1187
|
+
loginChallengeRequestSchema,
|
|
1188
|
+
loginPendingSchema,
|
|
1130
1189
|
loginRequestSchema,
|
|
1131
1190
|
loginResponseSchema,
|
|
1191
|
+
loginStepSchema,
|
|
1192
|
+
loginVerifyRequestSchema,
|
|
1132
1193
|
meResponseSchema,
|
|
1133
1194
|
passwordSchema,
|
|
1134
1195
|
refreshRequestSchema,
|
|
@@ -1143,14 +1204,17 @@ export {
|
|
|
1143
1204
|
signupStatusSchema,
|
|
1144
1205
|
signupVerifyRequestSchema,
|
|
1145
1206
|
signupVerifyResponseSchema,
|
|
1146
|
-
twoFactorChallengeRequestSchema,
|
|
1147
1207
|
wsTicketResponseSchema
|
|
1148
1208
|
} from './http/auth';
|
|
1149
1209
|
export type {
|
|
1150
1210
|
ChangePasswordRequest,
|
|
1151
1211
|
ChangePasswordResponse,
|
|
1212
|
+
LoginChallengeRequest,
|
|
1213
|
+
LoginPending,
|
|
1152
1214
|
LoginRequest,
|
|
1153
1215
|
LoginResponse,
|
|
1216
|
+
LoginStep,
|
|
1217
|
+
LoginVerifyRequest,
|
|
1154
1218
|
MeResponse,
|
|
1155
1219
|
RefreshRequest,
|
|
1156
1220
|
RefreshResponse,
|
|
@@ -1164,7 +1228,6 @@ export type {
|
|
|
1164
1228
|
SignupStatus,
|
|
1165
1229
|
SignupVerifyRequest,
|
|
1166
1230
|
SignupVerifyResponse,
|
|
1167
|
-
TwoFactorChallengeRequest,
|
|
1168
1231
|
WsTicketResponse
|
|
1169
1232
|
} from './http/auth';
|
|
1170
1233
|
export {
|
package/src/protocol/agent.ts
CHANGED
|
@@ -1475,10 +1475,12 @@ export type AgentServerMessage = z.infer<typeof agentServerMessageSchema>;
|
|
|
1475
1475
|
|
|
1476
1476
|
/**
|
|
1477
1477
|
* Signature of a high-impact order, carried next to `command` and `payload` as
|
|
1478
|
-
* `sig`. Ed25519 over `command \n nonce \n issuedAt \n` followed
|
|
1479
|
-
* bytes of the payload as sent. The agent verifies it against the
|
|
1480
|
-
* enrolment
|
|
1481
|
-
*
|
|
1478
|
+
* `sig`. Ed25519 over `command \n deviceId \n nonce \n issuedAt \n` followed
|
|
1479
|
+
* by the exact bytes of the payload as sent. The agent verifies it against the
|
|
1480
|
+
* key pinned at enrolment and its own device id (one key signs for every
|
|
1481
|
+
* machine of a server: without the id, an order signed for one would run on
|
|
1482
|
+
* all), refuses an `issuedAt` more than five minutes off, and refuses a nonce
|
|
1483
|
+
* it has already seen.
|
|
1482
1484
|
*/
|
|
1483
1485
|
export const orderSignatureSchema = z.object({
|
|
1484
1486
|
nonce: z.string().length(32),
|
|
@@ -1489,21 +1491,36 @@ export type OrderSignature = z.infer<typeof orderSignatureSchema>;
|
|
|
1489
1491
|
|
|
1490
1492
|
/**
|
|
1491
1493
|
* The orders the server signs (`ORDER_SIGNING_KEY`) and the agent refuses
|
|
1492
|
-
* unsigned: what runs code, writes or deletes files,
|
|
1493
|
-
* privileges
|
|
1494
|
-
*
|
|
1494
|
+
* unsigned: what runs code, writes, moves or deletes files, reads their
|
|
1495
|
+
* content, changes the agent's privileges, its life or its token, drives its
|
|
1496
|
+
* containers, reaches into its network, or drives what CloudSync writes.
|
|
1497
|
+
* `sync.applyChunk` is not signed (a chunk per megabyte would exhaust the
|
|
1498
|
+
* nonce window) but only lands in a transfer a signed `sync.applyStart`
|
|
1499
|
+
* opened; `agent.update` is not signed so an agent that predates this format
|
|
1500
|
+
* can still be updated. Mirror of `SIGNED_COMMANDS` in `agent/src/protocol.rs`.
|
|
1495
1501
|
*/
|
|
1496
1502
|
export const SIGNED_AGENT_COMMANDS: ReadonlySet<string> = new Set([
|
|
1497
1503
|
AGENT_TERM_OPEN,
|
|
1498
1504
|
AGENT_FILES_MUTATE,
|
|
1499
1505
|
AGENT_FILES_UPLOAD,
|
|
1506
|
+
AGENT_FILES_DOWNLOAD,
|
|
1507
|
+
AGENT_FILES_ARCHIVE,
|
|
1508
|
+
AGENT_SYNC_CONFIG,
|
|
1509
|
+
AGENT_SYNC_SCAN,
|
|
1510
|
+
AGENT_SYNC_PUSH,
|
|
1511
|
+
AGENT_SYNC_APPLY_START,
|
|
1512
|
+
AGENT_SYNC_APPLY_DIR,
|
|
1513
|
+
AGENT_SYNC_APPLY_LOCAL,
|
|
1514
|
+
AGENT_SYNC_MOVE,
|
|
1515
|
+
AGENT_SYNC_DELETE,
|
|
1500
1516
|
AGENT_SERVICE,
|
|
1501
1517
|
AGENT_POWER,
|
|
1502
1518
|
AGENT_DESTROY,
|
|
1503
1519
|
AGENT_PKG_UPGRADE,
|
|
1504
1520
|
AGENT_LIFECYCLE,
|
|
1505
1521
|
AGENT_DOCKER_ACTION,
|
|
1506
|
-
AGENT_TUNNEL_OPEN
|
|
1522
|
+
AGENT_TUNNEL_OPEN,
|
|
1523
|
+
AGENT_TOKEN_ROTATE
|
|
1507
1524
|
]);
|
|
1508
1525
|
|
|
1509
1526
|
/**
|
package/src/protocol/error.ts
CHANGED
|
@@ -22,7 +22,11 @@ export const ErrorCodeSchema = z.enum([
|
|
|
22
22
|
'maintenance',
|
|
23
23
|
// The server is full for this kind of account: the socket waits in line
|
|
24
24
|
// (see `domain/admission.ts`). `details` carries `{ position }`.
|
|
25
|
-
'queued'
|
|
25
|
+
'queued',
|
|
26
|
+
// Driving a machine needs a fresh authenticator code in this session
|
|
27
|
+
// (see `domain/stepUp.ts`). `details` carries `{ twoFactor }`: `false`
|
|
28
|
+
// when the account has no authenticator app to ask a code from.
|
|
29
|
+
'stepup_required'
|
|
26
30
|
]);
|
|
27
31
|
|
|
28
32
|
export type ErrorCode = z.infer<typeof ErrorCodeSchema>;
|
|
@@ -581,16 +581,27 @@ declare module 'deveye-sdk-client' {
|
|
|
581
581
|
export const ReadOnlyNotice: ComponentType<{ children: ReactNode }>;
|
|
582
582
|
export interface ErrorNoteInput {
|
|
583
583
|
message: string;
|
|
584
|
+
/** The failure's code, `null` when it carries none: it decides whether a report is offered. */
|
|
584
585
|
code: string | null;
|
|
585
586
|
}
|
|
586
587
|
export interface ErrorNoteProps {
|
|
587
588
|
note: ErrorNoteInput | null;
|
|
589
|
+
/** The caller's repair actions (retry, open settings), before the report button. */
|
|
588
590
|
children?: ReactNode;
|
|
591
|
+
/** Makes the banner dismissible: the close button comes last, after the report button. */
|
|
592
|
+
onDismiss?: () => void;
|
|
593
|
+
/**
|
|
594
|
+
* Keeps the banner where it is written instead of the frame's slot: the
|
|
595
|
+
* failure of one row among others (a history entry, an upload).
|
|
596
|
+
*/
|
|
597
|
+
inline?: boolean;
|
|
589
598
|
}
|
|
590
599
|
/**
|
|
591
600
|
* A refusal banner: the sentence, the caller's own repair actions as
|
|
592
601
|
* children, and a report button when the failure is not one the user can
|
|
593
|
-
* fix on their own.
|
|
602
|
+
* fix on their own. Wherever you write it, it shows at the top of its
|
|
603
|
+
* frame, full width: under your view's `StickyHeader`, under a dialog's
|
|
604
|
+
* title. Without either, it stays in place.
|
|
594
605
|
*/
|
|
595
606
|
export const ErrorNote: ComponentType<ErrorNoteProps>;
|
|
596
607
|
/** Open the report form, primed with what failed. */
|
|
@@ -651,10 +662,16 @@ declare module 'deveye-sdk-client' {
|
|
|
651
662
|
done: Promise<void>;
|
|
652
663
|
abort(): void;
|
|
653
664
|
}
|
|
654
|
-
/**
|
|
665
|
+
/**
|
|
666
|
+
* What `UploadHandle.done` rejects with: the server's message (`{ message }`
|
|
667
|
+
* in your route's error body), or why the connection ended. `code` is the
|
|
668
|
+
* protocol code the HTTP status maps to (409 `conflict`, 413 `validation`,
|
|
669
|
+
* 5xx `internal`, a dropped connection `network`), `null` once aborted.
|
|
670
|
+
*/
|
|
655
671
|
export class UploadError extends Error {
|
|
672
|
+
readonly code: string | null;
|
|
656
673
|
readonly aborted: boolean;
|
|
657
|
-
constructor(message: string, aborted?: boolean);
|
|
674
|
+
constructor(message: string, code: string | null, aborted?: boolean);
|
|
658
675
|
}
|
|
659
676
|
/**
|
|
660
677
|
* POSTs the file as is (`application/octet-stream`) to a route of yours,
|
|
@@ -764,12 +781,18 @@ declare module 'deveye-sdk-client' {
|
|
|
764
781
|
load: () => Promise<T>,
|
|
765
782
|
fallback: string,
|
|
766
783
|
deps?: readonly unknown[]
|
|
767
|
-
): { data: T | null; error:
|
|
784
|
+
): { data: T | null; error: ErrorNoteInput | null; loading: boolean; reload: () => void };
|
|
768
785
|
export function invalidate(...keys: ExternalResourceKey[]): void;
|
|
769
786
|
export function useResourceVersion(key: ExternalResourceKey): number;
|
|
770
787
|
/** Imperative subscription to one resource key's invalidations. Returns the unsubscribe. */
|
|
771
788
|
export function onResourceChange(key: ExternalResourceKey, cb: () => void): () => void;
|
|
772
789
|
export function humanizeError(error: unknown, fallback: string): string;
|
|
790
|
+
/**
|
|
791
|
+
* A failure as `ErrorNote` shows it: the `humanizeError` sentence and the
|
|
792
|
+
* code, read off the error's shape. What every failure shown to the user
|
|
793
|
+
* goes through, so that one nobody can fix offers a report.
|
|
794
|
+
*/
|
|
795
|
+
export function errorNote(error: unknown, fallback: string): ErrorNoteInput;
|
|
773
796
|
/** The error a command rejects with: the server's code (or the socket's), its message, and the validation details when any. */
|
|
774
797
|
export class WsError extends Error {
|
|
775
798
|
constructor(code: string, message: string, details?: unknown);
|
|
@@ -845,9 +868,12 @@ declare module 'deveye-sdk-client' {
|
|
|
845
868
|
/**
|
|
846
869
|
* The rejection of `ensureSecrecyUnlocked` / `withSecrecy` when the user
|
|
847
870
|
* dismisses the unlock prompt: a deliberate cancel, not a failure (close a
|
|
848
|
-
* view that has nothing to show, rather than reporting an error).
|
|
871
|
+
* view that has nothing to show, rather than reporting an error). Coded
|
|
872
|
+
* `locked`: `errorNote` reads it as a refusal, and offers no report.
|
|
849
873
|
*/
|
|
850
|
-
export class UnlockCancelledError extends Error {
|
|
874
|
+
export class UnlockCancelledError extends Error {
|
|
875
|
+
readonly code: 'locked';
|
|
876
|
+
}
|
|
851
877
|
|
|
852
878
|
// ── Live ───────────────────────────────────────────────────────────────
|
|
853
879
|
export type LiveSegmentKind = 'view' | 'l1' | 'l2' | 'l3' | 'l4';
|
|
@@ -923,7 +949,7 @@ declare module 'deveye-sdk-client' {
|
|
|
923
949
|
load: (() => Promise<readonly DeviceRelayOption[]>) | null
|
|
924
950
|
): {
|
|
925
951
|
devices: readonly DeviceRelayOption[];
|
|
926
|
-
error:
|
|
952
|
+
error: ErrorNoteInput | null;
|
|
927
953
|
};
|
|
928
954
|
/** One rule of a `PathExclusionsEditor`. */
|
|
929
955
|
export interface PathExclusionItem {
|
|
@@ -1105,7 +1131,7 @@ declare module 'deveye-sdk-client' {
|
|
|
1105
1131
|
export function useDomains(feature: FeatureId): {
|
|
1106
1132
|
domains: readonly FeatureDomain[];
|
|
1107
1133
|
loading: boolean;
|
|
1108
|
-
error:
|
|
1134
|
+
error: ErrorNoteInput | null;
|
|
1109
1135
|
};
|
|
1110
1136
|
/**
|
|
1111
1137
|
* A member's identity dot: their avatar, or the default picture until they
|
|
@@ -1142,7 +1168,11 @@ declare module 'deveye-sdk-client' {
|
|
|
1142
1168
|
/** Image inputs accepted by `fileToSquareDataUrl`. */
|
|
1143
1169
|
export const ACCEPTED_TYPES: readonly string[];
|
|
1144
1170
|
export const MAX_INPUT_BYTES: number;
|
|
1145
|
-
/**
|
|
1171
|
+
/**
|
|
1172
|
+
* A picked image, resized to a square data URL under `maxLength`
|
|
1173
|
+
* characters. A file it cannot use throws an error coded `validation`
|
|
1174
|
+
* whose message is readable: `errorNote` shows it as is.
|
|
1175
|
+
*/
|
|
1146
1176
|
export function fileToSquareDataUrl(
|
|
1147
1177
|
file: File,
|
|
1148
1178
|
opts: { size: number; maxLength: number }
|
package/src/sdk/client.ts
CHANGED
|
@@ -55,11 +55,6 @@ export interface AccountViewProps {
|
|
|
55
55
|
hint?: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/** Props of {@link FeatureClient.AdminView}. */
|
|
59
|
-
export interface AdminViewProps {
|
|
60
|
-
close(): void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
58
|
/**
|
|
64
59
|
* Your package's `./client` export.
|
|
65
60
|
*/
|
|
@@ -74,8 +69,13 @@ export interface FeatureClient {
|
|
|
74
69
|
Full?: ComponentType<FeatureViewProps>;
|
|
75
70
|
/** The view `manifest.accountEntry` opens from the user menu. */
|
|
76
71
|
AccountView?: ComponentType<AccountViewProps>;
|
|
77
|
-
/**
|
|
78
|
-
|
|
72
|
+
/**
|
|
73
|
+
* One component per tab of `manifest.adminTabs`, by its id, drawn under
|
|
74
|
+
* the header of the feature administration popup: no title of your own,
|
|
75
|
+
* the popup names your feature and the tab. No props: the data comes from
|
|
76
|
+
* `useResource`, and the commands it sends decide who may read what.
|
|
77
|
+
*/
|
|
78
|
+
AdminTabs?: Readonly<Record<string, ComponentType>>;
|
|
79
79
|
/**
|
|
80
80
|
* The vignette shown on your card in the home grid's add market and on
|
|
81
81
|
* your "About" sheet. Without one, the host draws a neutral module mark:
|
package/src/sdk/copy.test.ts
CHANGED
|
@@ -314,6 +314,25 @@ describe('copie d’un élément', () => {
|
|
|
314
314
|
);
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
+
it('expurge un secret de sa colonne scellée, et refuse une valeur scellée qui ne serait pas du texte', async () => {
|
|
318
|
+
const tree: ItemTree = [
|
|
319
|
+
{ ...TREE[0], redact: { content: (plain) => plain.replace('tableau', '•') } }
|
|
320
|
+
];
|
|
321
|
+
const rows = await exportItemTree(fakeDb(seed()), tree, 1, cipherOf('A'));
|
|
322
|
+
assert.equal(rows.boards[0].content, '•');
|
|
323
|
+
|
|
324
|
+
const target = seed();
|
|
325
|
+
await assert.rejects(
|
|
326
|
+
importItemTree(
|
|
327
|
+
fakeDb(target),
|
|
328
|
+
TREE,
|
|
329
|
+
{ boards: [{ id: 1, content: { $wire: 'x' } }] },
|
|
330
|
+
into('B')
|
|
331
|
+
),
|
|
332
|
+
/Valeur inattendue/
|
|
333
|
+
);
|
|
334
|
+
});
|
|
335
|
+
|
|
317
336
|
it('refuse un élément que la destination tient déjà sous le même nom', async () => {
|
|
318
337
|
const tree: ItemTree = [
|
|
319
338
|
{ ...TREE[0], unique: { column: 'name_ref', message: 'Déjà là.' } }
|
|
@@ -370,5 +389,9 @@ describe('arbre d’un élément', () => {
|
|
|
370
389
|
itemTreeProblem([TREE[0], TREE[1], TREE[2], { ...LABELS, refs: {} }]) ?? '',
|
|
371
390
|
/scoped/
|
|
372
391
|
);
|
|
392
|
+
assert.match(
|
|
393
|
+
itemTreeProblem([{ ...TREE[0], redact: { name: (p) => p } }]) ?? '',
|
|
394
|
+
/redacted/
|
|
395
|
+
);
|
|
373
396
|
});
|
|
374
397
|
});
|