@deveye/types 0.24.0 → 0.24.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/featureRegistry.ts +2 -13
- package/src/features/admin.ts +2 -2
- package/src/http/auth.ts +1 -1
- package/src/index.ts +1 -5
- package/src/sdk/sealed.test.ts +46 -0
- package/src/sdk/sealed.ts +45 -0
- package/src/sdk/server.ts +11 -1
package/package.json
CHANGED
|
@@ -466,22 +466,11 @@ export const SHAREABLE_FEATURES: readonly WorkspaceFeatureId[] = FEATURE_REGISTR
|
|
|
466
466
|
(f) => f.shareTier !== 'never'
|
|
467
467
|
).map((f) => f.id);
|
|
468
468
|
|
|
469
|
-
/**
|
|
470
|
-
* Celles dont la lecture élargie est réellement branchée : `shareTier` dit ce
|
|
471
|
-
* que le chiffrement autorise, cette liste ce que le code fait. Partagée entre
|
|
472
|
-
* client et serveur : le serveur refuse, le client n'affiche pas l'onglet.
|
|
473
|
-
* Brancher une native : `listVisible` / `findVisible` dans son dépôt, le codec
|
|
474
|
-
* par ligne dans son listage, une entrée ici. Un module se déclare par son
|
|
475
|
-
* manifest (`shareTier` autre que `'never'`) et son entrée `items`.
|
|
476
|
-
*/
|
|
477
|
-
export const SHARE_WIRED_FEATURES: readonly WorkspaceFeatureId[] = ['backup'];
|
|
478
|
-
|
|
479
469
|
/**
|
|
480
470
|
* Celles dont un projet relie les éléments : le module Projets tient une table
|
|
481
471
|
* de liaison par famille, et son contrat d'usage (`PROJECTS_USAGE_PROVIDER`) ne
|
|
482
|
-
* connaît que celles-ci. Partagée entre client et serveur
|
|
483
|
-
*
|
|
484
|
-
* le client n'affiche pas l'onglet. En relier une de plus, c'est une entrée ici
|
|
472
|
+
* connaît que celles-ci. Partagée entre client et serveur : le serveur rend une
|
|
473
|
+
* liste vide pour une autre, le client n'affiche pas l'onglet. En relier une de plus, c'est une entrée ici
|
|
485
474
|
* et une dans le `Record` du contrat.
|
|
486
475
|
*/
|
|
487
476
|
export const PROJECT_LINKED_FEATURES: readonly FeatureId[] = [
|
package/src/features/admin.ts
CHANGED
|
@@ -70,7 +70,7 @@ export const adminMaintenanceSchema = z.object({
|
|
|
70
70
|
/** Le texte choisi, `null` pour celui par défaut. */
|
|
71
71
|
message: z.string().nullable(),
|
|
72
72
|
defaultMessage: z.string(),
|
|
73
|
-
/** Le processus a démarré avec `MAINTENANCE=
|
|
73
|
+
/** Le processus a démarré avec `MAINTENANCE=true`. */
|
|
74
74
|
envSeeded: z.boolean(),
|
|
75
75
|
updated: z.number().int().nonnegative(),
|
|
76
76
|
updatedBy: maintenanceAuthorSchema
|
|
@@ -168,7 +168,7 @@ export const adminMaintenanceSeats = {
|
|
|
168
168
|
output: adminMaintenanceSchema
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
/** Ferme le rappel de `MAINTENANCE=
|
|
171
|
+
/** Ferme le rappel de `MAINTENANCE=true`, pour tous les administrateurs. */
|
|
172
172
|
export const adminMaintenanceDismissNotice = {
|
|
173
173
|
command: 'admin.maintenanceDismissNotice' as const,
|
|
174
174
|
input: z.object({}),
|
package/src/http/auth.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const sessionBundleSchema = z.object({
|
|
|
35
35
|
/** Where this server's source code is offered (`SOURCE_URL`), as the AGPL requires. `null`: none. */
|
|
36
36
|
sourceUrl: z.string().url().nullable(),
|
|
37
37
|
/**
|
|
38
|
-
* Admin only: the process booted with `MAINTENANCE=
|
|
38
|
+
* Admin only: the process booted with `MAINTENANCE=true` and no admin has
|
|
39
39
|
* closed the reminder. Shown once the site maintenance is lifted. Read at
|
|
40
40
|
* load, not live.
|
|
41
41
|
*/
|
package/src/index.ts
CHANGED
|
@@ -865,11 +865,7 @@ export {
|
|
|
865
865
|
sharingCommands
|
|
866
866
|
} from './features/sharing';
|
|
867
867
|
export { linksCommands, projectLinksGet, projectLinksSet } from './features/links';
|
|
868
|
-
export {
|
|
869
|
-
PROJECT_LINKED_FEATURES,
|
|
870
|
-
SHAREABLE_FEATURES,
|
|
871
|
-
SHARE_WIRED_FEATURES
|
|
872
|
-
} from './domain/featureRegistry';
|
|
868
|
+
export { PROJECT_LINKED_FEATURES, SHAREABLE_FEATURES } from './domain/featureRegistry';
|
|
873
869
|
export {
|
|
874
870
|
DNS_RECORD_TYPES,
|
|
875
871
|
FEATURE_DOMAIN_HOST_MAX,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { sealedColumnsProblem } from './sealed';
|
|
5
|
+
|
|
6
|
+
const accountExport = { tables: { ft_demo_keys: { skip: 'Key material never leaves.' } } };
|
|
7
|
+
|
|
8
|
+
test('sealedColumnsProblem accepts a column of a table the module owns', () => {
|
|
9
|
+
assert.equal(
|
|
10
|
+
sealedColumnsProblem({
|
|
11
|
+
accountExport,
|
|
12
|
+
sealed: [{ table: 'ft_demo_keys', column: 'sealed', id: 'id', match: { kind: 'root' } }]
|
|
13
|
+
}),
|
|
14
|
+
null
|
|
15
|
+
);
|
|
16
|
+
assert.equal(sealedColumnsProblem({}), null);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('sealedColumnsProblem refuses a foreign table, a bad name and a column declared twice', () => {
|
|
20
|
+
assert.match(
|
|
21
|
+
sealedColumnsProblem({
|
|
22
|
+
accountExport,
|
|
23
|
+
sealed: [{ table: 'user_2fa', column: 'secret_enc', id: 'user_id' }]
|
|
24
|
+
}) ?? '',
|
|
25
|
+
/user_2fa is not in accountExport\.tables/
|
|
26
|
+
);
|
|
27
|
+
assert.match(
|
|
28
|
+
sealedColumnsProblem({
|
|
29
|
+
accountExport,
|
|
30
|
+
sealed: [
|
|
31
|
+
{
|
|
32
|
+
table: 'ft_demo_keys',
|
|
33
|
+
column: 'sealed',
|
|
34
|
+
id: 'id',
|
|
35
|
+
match: { 'kind = 1 OR 1': 'x' }
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}) ?? '',
|
|
39
|
+
/not an identifier/
|
|
40
|
+
);
|
|
41
|
+
const twice = { table: 'ft_demo_keys', column: 'sealed', id: 'id' };
|
|
42
|
+
assert.match(
|
|
43
|
+
sealedColumnsProblem({ accountExport, sealed: [twice, twice] }) ?? '',
|
|
44
|
+
/declared twice/
|
|
45
|
+
);
|
|
46
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FeatureServer } from './server';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A column whose cells you seal with `keys.sealBytes`, declared in
|
|
5
|
+
* {@link FeatureServer.sealed}. When the server key (`CRYPT_KEY_A` /
|
|
6
|
+
* `CRYPT_KEY_B`) changes, the host re-wraps every declared cell, and it refuses
|
|
7
|
+
* to boot on a cell left in an outdated format. A sealed column you leave out
|
|
8
|
+
* turns unreadable at the first rotation.
|
|
9
|
+
*/
|
|
10
|
+
export interface FeatureSealedColumn {
|
|
11
|
+
table: string;
|
|
12
|
+
column: string;
|
|
13
|
+
/** The column that identifies a row on its own: the rotation rewrites the cell by it. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Only the rows whose columns hold these values, when the table mixes sealed cells with others. */
|
|
16
|
+
match?: Readonly<Record<string, string>>;
|
|
17
|
+
/** The `context` you pass to `sealBytes` for the row `id`; leave it out when you pass none. */
|
|
18
|
+
context?: (id: string | number) => string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What is wrong with your sealed columns, or `null`. Checked at boot: every
|
|
25
|
+
* name ends up in SQL, and a table must be one of yours, as
|
|
26
|
+
* `accountExport.tables` lists them.
|
|
27
|
+
*/
|
|
28
|
+
export function sealedColumnsProblem(
|
|
29
|
+
server: Pick<FeatureServer, 'sealed' | 'accountExport'>
|
|
30
|
+
): string | null {
|
|
31
|
+
const owned = new Set(Object.keys(server.accountExport?.tables ?? {}));
|
|
32
|
+
const seen = new Set<string>();
|
|
33
|
+
for (const sealed of server.sealed ?? []) {
|
|
34
|
+
const names = [sealed.table, sealed.column, sealed.id, ...Object.keys(sealed.match ?? {})];
|
|
35
|
+
const bad = names.find((name) => !IDENTIFIER.test(name));
|
|
36
|
+
if (bad !== undefined) return `sealed: « ${bad} » is not an identifier`;
|
|
37
|
+
if (!owned.has(sealed.table)) {
|
|
38
|
+
return `sealed: ${sealed.table} is not in accountExport.tables`;
|
|
39
|
+
}
|
|
40
|
+
const cell = `${sealed.table}.${sealed.column}`;
|
|
41
|
+
if (seen.has(cell)) return `sealed: ${cell} declared twice`;
|
|
42
|
+
seen.add(cell);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
package/src/sdk/server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Duplex } from 'node:stream';
|
|
2
2
|
import type { FeatureAccountExport } from './accountExport';
|
|
3
|
+
import type { FeatureSealedColumn } from './sealed';
|
|
3
4
|
import type { ItemTree, ItemTreeRows } from './copy';
|
|
4
5
|
import type { z, ZodType } from 'zod';
|
|
5
6
|
import type { ErrorCode } from '../protocol/error';
|
|
@@ -873,7 +874,9 @@ export interface SdkObjectStore {
|
|
|
873
874
|
* Raw bytes under the SERVER key, for wrapping module-owned key material; never
|
|
874
875
|
* for user data, which goes through ciphers and the store. The host seals under
|
|
875
876
|
* a sub-key of its own for each module: a blob sealed by one module never opens
|
|
876
|
-
* in another, nor as one of the app's own sealed keys.
|
|
877
|
+
* in another, nor as one of the app's own sealed keys. Declare every column you
|
|
878
|
+
* keep these blobs in ({@link FeatureServer.sealed}): a rotation of the server
|
|
879
|
+
* key re-wraps only what is declared.
|
|
877
880
|
*/
|
|
878
881
|
export interface SdkServerKeys {
|
|
879
882
|
/**
|
|
@@ -1600,6 +1603,11 @@ export interface FeatureServer<Repo = unknown> {
|
|
|
1600
1603
|
* feature owns a table; without tables, the host exports your store alone.
|
|
1601
1604
|
*/
|
|
1602
1605
|
accountExport?: FeatureAccountExport<Repo>;
|
|
1606
|
+
/**
|
|
1607
|
+
* The columns you fill with `keys.sealBytes`: see {@link FeatureSealedColumn}.
|
|
1608
|
+
* Each table is one of yours, listed in `accountExport.tables`.
|
|
1609
|
+
*/
|
|
1610
|
+
sealed?: readonly FeatureSealedColumn[];
|
|
1603
1611
|
/** One entry per quota of the manifest, by its key, `perOperation` ones excepted, and none other. */
|
|
1604
1612
|
quotas?: Readonly<Record<string, FeatureQuotaEntry<Repo>>>;
|
|
1605
1613
|
/**
|
|
@@ -2068,6 +2076,8 @@ export type {
|
|
|
2068
2076
|
} from './copy';
|
|
2069
2077
|
|
|
2070
2078
|
export { accountExportProblem, EXPORT_SECRET_COLUMN, exportTableRows } from './accountExport';
|
|
2079
|
+
export { sealedColumnsProblem } from './sealed';
|
|
2080
|
+
export type { FeatureSealedColumn } from './sealed';
|
|
2071
2081
|
export type {
|
|
2072
2082
|
FeatureAccountExport,
|
|
2073
2083
|
SdkAccountExportContext,
|