@openbrf/plugin-sdk 1.0.0 → 1.2.0
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/README.md +95 -0
- package/dist/abort-signal.d.ts +23 -0
- package/dist/abort-signal.d.ts.map +1 -0
- package/dist/abort-signal.js +2 -0
- package/dist/abort-signal.js.map +1 -0
- package/dist/action-refusal.d.ts +101 -0
- package/dist/action-refusal.d.ts.map +1 -0
- package/dist/action-refusal.js +96 -0
- package/dist/action-refusal.js.map +1 -0
- package/dist/action-schema.d.ts.map +1 -1
- package/dist/action-schema.js +4 -1
- package/dist/action-schema.js.map +1 -1
- package/dist/actions.d.ts +94 -6
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/blocks.d.ts +310 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +185 -0
- package/dist/blocks.js.map +1 -0
- package/dist/catalog.d.ts +399 -7
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +373 -9
- package/dist/catalog.js.map +1 -1
- package/dist/entitlements.d.ts +117 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +62 -0
- package/dist/entitlements.js.map +1 -0
- package/dist/extensions.d.ts +183 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +67 -0
- package/dist/extensions.js.map +1 -0
- package/dist/finances.d.ts +294 -0
- package/dist/finances.d.ts.map +1 -0
- package/dist/finances.js +56 -0
- package/dist/finances.js.map +1 -0
- package/dist/findings.d.ts +90 -1
- package/dist/findings.d.ts.map +1 -1
- package/dist/findings.js +89 -0
- package/dist/findings.js.map +1 -1
- package/dist/host.d.ts +621 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -0
- package/dist/host.js.map +1 -1
- package/dist/imports.d.ts +104 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +70 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/localized-text.d.ts +18 -0
- package/dist/localized-text.d.ts.map +1 -0
- package/dist/localized-text.js +17 -0
- package/dist/localized-text.js.map +1 -0
- package/dist/manifest.d.ts +730 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +805 -11
- package/dist/manifest.js.map +1 -1
- package/dist/permissions.d.ts +170 -11
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +210 -2
- package/dist/permissions.js.map +1 -1
- package/dist/recipients.d.ts +139 -0
- package/dist/recipients.d.ts.map +1 -0
- package/dist/recipients.js +223 -0
- package/dist/recipients.js.map +1 -0
- package/dist/records.d.ts +130 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +85 -0
- package/dist/records.js.map +1 -0
- package/dist/require-capability.d.ts +37 -0
- package/dist/require-capability.d.ts.map +1 -0
- package/dist/require-capability.js +88 -0
- package/dist/require-capability.js.map +1 -0
- package/dist/settings-schema.d.ts +35 -0
- package/dist/settings-schema.d.ts.map +1 -1
- package/dist/settings-schema.js +55 -2
- package/dist/settings-schema.js.map +1 -1
- package/package.json +4 -4
- package/src/abort-signal.ts +22 -0
- package/src/action-refusal.ts +178 -0
- package/src/action-schema.ts +4 -1
- package/src/actions.ts +103 -6
- package/src/blocks.ts +289 -0
- package/src/catalog.ts +500 -57
- package/src/entitlements.ts +150 -0
- package/src/extensions.ts +212 -0
- package/src/finances.ts +317 -0
- package/src/findings.ts +92 -0
- package/src/host.ts +656 -2
- package/src/imports.ts +135 -0
- package/src/index.ts +193 -0
- package/src/localized-text.ts +19 -0
- package/src/manifest.ts +1039 -12
- package/src/permissions.ts +223 -3
- package/src/recipients.ts +294 -0
- package/src/records.ts +172 -0
- package/src/require-capability.ts +106 -0
- package/src/settings-schema.ts +64 -2
package/dist/catalog.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { IntegrityError, parseSha512 } from "./integrity.js";
|
|
3
|
-
import {
|
|
3
|
+
import { localizedTextSchema } from "./localized-text.js";
|
|
4
|
+
import { declaredActionsSchema, declaredExtensionPointsSchema, declaredExtensionsSchema, extensionGroupRefusals, extensionHostPersonalDataRefused, extensionPermissionsRefused, extensionPointRefusal, extensionRuleIssues, pluginExtensionPointSchema, pluginExtensionSchema, declaredDeviceRoutesSchema, deviceRouteRuleIssues, pluginActionSchema, pluginDeviceRouteSchema, pluginIdSchema, pluginManifestSchema, proposeImportPersonalDataIssues, } from "./manifest.js";
|
|
4
5
|
import { PLUGIN_PERMISSIONS, PLUGIN_PERSONAL_DATA_CATEGORIES, } from "./permissions.js";
|
|
6
|
+
import { declaredRecipientsSchema, pluginRecipientSchema, recipientCategoryIssues, } from "./recipients.js";
|
|
5
7
|
/**
|
|
6
8
|
* The catalog index.
|
|
7
9
|
*
|
|
@@ -66,11 +68,20 @@ export const catalogArtifactSchema = z.strictObject({
|
|
|
66
68
|
}),
|
|
67
69
|
bytes: z.int().min(1).optional(),
|
|
68
70
|
});
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
/**
|
|
72
|
+
* An extension point as the index lists it: the manifest's fields, and the
|
|
73
|
+
* curator's title and description in both languages.
|
|
74
|
+
*
|
|
75
|
+
* The text is the curator's rather than the plugin's own, as an entry's `name`
|
|
76
|
+
* is, because an addon's consent screen has to name the point before the host
|
|
77
|
+
* plugin's locale files exist on the instance (ADR 0030).
|
|
78
|
+
*/
|
|
79
|
+
export const catalogExtensionPointSchema = pluginExtensionPointSchema
|
|
80
|
+
.extend({
|
|
81
|
+
title: localizedTextSchema,
|
|
82
|
+
description: localizedTextSchema,
|
|
83
|
+
})
|
|
84
|
+
.strict();
|
|
74
85
|
/** Strict, and `.extend()` keeps it so for both kinds of entry. */
|
|
75
86
|
const baseEntrySchema = z.strictObject({
|
|
76
87
|
/**
|
|
@@ -87,7 +98,8 @@ const baseEntrySchema = z.strictObject({
|
|
|
87
98
|
/** Set on an entry that is still listed but should not be installed anew. */
|
|
88
99
|
deprecated: z.boolean().default(false),
|
|
89
100
|
});
|
|
90
|
-
export const catalogPluginEntrySchema = baseEntrySchema
|
|
101
|
+
export const catalogPluginEntrySchema = baseEntrySchema
|
|
102
|
+
.extend({
|
|
91
103
|
type: z.literal("plugin"),
|
|
92
104
|
/**
|
|
93
105
|
* The npm package name the tarball unpacks as. Needed because the installer
|
|
@@ -132,6 +144,86 @@ export const catalogPluginEntrySchema = baseEntrySchema.extend({
|
|
|
132
144
|
* definition of what it may contain is the point of that schema.
|
|
133
145
|
*/
|
|
134
146
|
oauthProtectedResource: pluginManifestSchema.shape.oauthProtectedResource,
|
|
147
|
+
/**
|
|
148
|
+
* The extension points the plugin offers, repeated from the manifest with
|
|
149
|
+
* the curator's text, so the host plugin's consent screen can say what its
|
|
150
|
+
* points accept before anything is downloaded (ADR 0030).
|
|
151
|
+
*
|
|
152
|
+
* In version 2 of the index only; see `catalogSchema`. Left without a
|
|
153
|
+
* default, so that a version 1 index carrying the key, even empty, can be
|
|
154
|
+
* told from one that does not.
|
|
155
|
+
*/
|
|
156
|
+
extensionPoints: declaredExtensionPointsSchema(catalogExtensionPointSchema).optional(),
|
|
157
|
+
/**
|
|
158
|
+
* The extension points of other plugins it extends, repeated on the same
|
|
159
|
+
* terms, so an addon's consent screen can say what it extends and what it
|
|
160
|
+
* hands over. Version 2 only.
|
|
161
|
+
*/
|
|
162
|
+
extends: declaredExtensionsSchema(pluginExtensionSchema.strict()).optional(),
|
|
163
|
+
/**
|
|
164
|
+
* Where the plugin connects to, repeated on the same terms as the
|
|
165
|
+
* declaration above it (ADR 0037).
|
|
166
|
+
*
|
|
167
|
+
* A field version 1 of the index does not define, so only an index of
|
|
168
|
+
* version 2 may carry it, and an index of version 1 that does is refused.
|
|
169
|
+
* Absent rather than defaulted, so that rule can tell an entry that left it
|
|
170
|
+
* out from one that declared none; a reader takes absent as none.
|
|
171
|
+
*/
|
|
172
|
+
recipients: declaredRecipientsSchema(pluginRecipientSchema.strict()).optional(),
|
|
173
|
+
/**
|
|
174
|
+
* The routes a device reaches with a device token, repeated on the same
|
|
175
|
+
* terms (ADR 0031).
|
|
176
|
+
*
|
|
177
|
+
* The consent screen names them - "can be reached by devices holding a token
|
|
178
|
+
* the board issues" - before anything is downloaded. In version 2 of the
|
|
179
|
+
* index only; see `catalogSchema`. Left without a default, so that a version 1
|
|
180
|
+
* index carrying the key, even empty, can be told from one that does not.
|
|
181
|
+
*/
|
|
182
|
+
deviceRoutes: declaredDeviceRoutesSchema(pluginDeviceRouteSchema.strict()).optional(),
|
|
183
|
+
/**
|
|
184
|
+
* That the plugin is an AI package, repeated on the same terms.
|
|
185
|
+
*
|
|
186
|
+
* It decides what the plugin's dispatch reaches and how the audit log names
|
|
187
|
+
* its writes, so the board reads it on the consent screen, and the install
|
|
188
|
+
* echo compares it, before anything is downloaded.
|
|
189
|
+
*
|
|
190
|
+
* Added within version 1 of the index rather than as a new version, because
|
|
191
|
+
* absent means the same as false: an index that lists no AI package need not
|
|
192
|
+
* carry the field and stays one an older instance reads. One that lists an
|
|
193
|
+
* AI package is refused whole by an older instance, which is the rule above
|
|
194
|
+
* doing its work - that instance would otherwise offer the plugin for
|
|
195
|
+
* consent without saying what it is, and dispatch it as a plain plugin.
|
|
196
|
+
*/
|
|
197
|
+
ai: pluginManifestSchema.shape.ai,
|
|
198
|
+
/**
|
|
199
|
+
* The licence a paid plugin reads, repeated on the same terms (ADR 0042).
|
|
200
|
+
*
|
|
201
|
+
* Above all its `audiences`: the services the plugin may present the
|
|
202
|
+
* association's licence to are a grant the board consents to, as it does
|
|
203
|
+
* `permissions`, so the consent screen states them and the install echo
|
|
204
|
+
* compares them before anything is downloaded. The manifest's own strict
|
|
205
|
+
* schema, so a misspelled field is refused here as it is there.
|
|
206
|
+
*
|
|
207
|
+
* Added within version 1 of the index on the `ai` field's terms: absent
|
|
208
|
+
* means the plugin reads no licence, and an index that lists a licensed
|
|
209
|
+
* plugin is refused whole by an instance from before the field.
|
|
210
|
+
*/
|
|
211
|
+
licence: pluginManifestSchema.shape.licence,
|
|
212
|
+
/**
|
|
213
|
+
* The day the release was published, which the update screen compares with
|
|
214
|
+
* the `updatesUntil` of the licence the instance holds. Required with
|
|
215
|
+
* `licence`, as in the manifest.
|
|
216
|
+
*/
|
|
217
|
+
released: pluginManifestSchema.shape.released,
|
|
218
|
+
})
|
|
219
|
+
.superRefine((entry, ctx) => {
|
|
220
|
+
if (entry.licence !== undefined && entry.released === undefined) {
|
|
221
|
+
ctx.addIssue({
|
|
222
|
+
code: "custom",
|
|
223
|
+
path: ["released"],
|
|
224
|
+
message: "an entry that declares a licence must say when it was released",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
135
227
|
});
|
|
136
228
|
/**
|
|
137
229
|
* A theme entry. Themes install through the same download-and-verify path and
|
|
@@ -152,13 +244,226 @@ export const catalogEntrySchema = z.discriminatedUnion("type", [
|
|
|
152
244
|
catalogPluginEntrySchema,
|
|
153
245
|
catalogThemeEntrySchema,
|
|
154
246
|
]);
|
|
247
|
+
/**
|
|
248
|
+
* The index versions this package reads.
|
|
249
|
+
*
|
|
250
|
+
* Version 2 adds the fields ADR 0030 lists: `extensionPoints` and `extends`
|
|
251
|
+
* (ADR 0030), `recipients` (ADR 0037) and `deviceRoutes` (ADR 0031). An
|
|
252
|
+
* instance reads both, and the catalog serves version 1, without the entries
|
|
253
|
+
* that need version 2, to instances that have not upgraded.
|
|
254
|
+
*/
|
|
255
|
+
export const CATALOG_INDEX_VERSIONS = [1, 2];
|
|
155
256
|
export const catalogSchema = z
|
|
156
257
|
.strictObject({
|
|
157
258
|
/** Index format version, so a future shape can be recognised and refused. */
|
|
158
|
-
version: z.literal(
|
|
259
|
+
version: z.literal(CATALOG_INDEX_VERSIONS),
|
|
159
260
|
entries: z.array(catalogEntrySchema).max(500),
|
|
160
261
|
})
|
|
161
262
|
.superRefine((catalog, ctx) => {
|
|
263
|
+
const plugins = new Map();
|
|
264
|
+
const pluginIndex = new Map();
|
|
265
|
+
for (const [index, entry] of catalog.entries.entries()) {
|
|
266
|
+
if (entry.type === "plugin" && !plugins.has(entry.id)) {
|
|
267
|
+
plugins.set(entry.id, entry);
|
|
268
|
+
pluginIndex.set(entry.id, index);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** The addons already refused beside a plugin they extend. */
|
|
272
|
+
const pairRefused = new Set();
|
|
273
|
+
for (const [index, entry] of catalog.entries.entries()) {
|
|
274
|
+
if (entry.type !== "plugin") {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
// The manifest's rule, so an entry the loader would refuse is never
|
|
278
|
+
// offered for consent.
|
|
279
|
+
for (const issue of proposeImportPersonalDataIssues(entry)) {
|
|
280
|
+
ctx.addIssue({
|
|
281
|
+
code: "custom",
|
|
282
|
+
path: ["entries", index, "personalData"],
|
|
283
|
+
message: issue.message,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/*
|
|
287
|
+
* A field version 1 does not define is refused there as any unknown key
|
|
288
|
+
* is, so an older instance and this one read the same index the same
|
|
289
|
+
* way.
|
|
290
|
+
*/
|
|
291
|
+
if (catalog.version === 1) {
|
|
292
|
+
for (const field of [
|
|
293
|
+
"extensionPoints",
|
|
294
|
+
"extends",
|
|
295
|
+
"deviceRoutes",
|
|
296
|
+
]) {
|
|
297
|
+
if (entry[field] !== undefined) {
|
|
298
|
+
ctx.addIssue({
|
|
299
|
+
code: "custom",
|
|
300
|
+
path: ["entries", index, field],
|
|
301
|
+
message: `${field} needs version 2 of the index`,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
// The manifest's own rules, so an entry whose own declaration breaks
|
|
308
|
+
// one is never offered for consent.
|
|
309
|
+
for (const issue of extensionRuleIssues({
|
|
310
|
+
id: entry.id,
|
|
311
|
+
permissions: entry.permissions,
|
|
312
|
+
personalData: entry.personalData,
|
|
313
|
+
extensionPoints: entry.extensionPoints ?? [],
|
|
314
|
+
extends: entry.extends ?? [],
|
|
315
|
+
})) {
|
|
316
|
+
ctx.addIssue({
|
|
317
|
+
code: "custom",
|
|
318
|
+
path: ["entries", index, ...issue.path],
|
|
319
|
+
message: issue.message,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
for (const issue of deviceRouteRuleIssues({
|
|
323
|
+
deviceRoutes: entry.deviceRoutes ?? [],
|
|
324
|
+
oauthProtectedResource: entry.oauthProtectedResource,
|
|
325
|
+
permissions: entry.permissions,
|
|
326
|
+
})) {
|
|
327
|
+
ctx.addIssue({
|
|
328
|
+
code: "custom",
|
|
329
|
+
path: ["entries", index, ...issue.path],
|
|
330
|
+
message: issue.message,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/*
|
|
334
|
+
* The rule between an addon and a plugin it extends, where the index
|
|
335
|
+
* lists both, read from the two entries. One it does not list is held to
|
|
336
|
+
* it by the loader, which reads the installed manifests, as it holds
|
|
337
|
+
* one it lists.
|
|
338
|
+
*/
|
|
339
|
+
for (const [position, extension] of (entry.extends ?? []).entries()) {
|
|
340
|
+
const host = plugins.get(extension.plugin);
|
|
341
|
+
if (host === undefined) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const named = {
|
|
345
|
+
addon: entry.id,
|
|
346
|
+
plugin: extension.plugin,
|
|
347
|
+
point: extension.point,
|
|
348
|
+
};
|
|
349
|
+
const unserved = extensionPointRefusal(extension, host.extensionPoints ?? []);
|
|
350
|
+
if (unserved !== null) {
|
|
351
|
+
pairRefused.add(entry.id);
|
|
352
|
+
const { field, message, detail } = unservedIssue(extension, unserved);
|
|
353
|
+
ctx.addIssue({
|
|
354
|
+
code: "custom",
|
|
355
|
+
path: ["entries", index, "extends", position, field],
|
|
356
|
+
message,
|
|
357
|
+
params: {
|
|
358
|
+
refusal: {
|
|
359
|
+
code: unserved.reason,
|
|
360
|
+
detail: { ...named, ...detail },
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const refused = extensionPermissionsRefused(entry, host);
|
|
367
|
+
if (refused.length > 0) {
|
|
368
|
+
pairRefused.add(entry.id);
|
|
369
|
+
ctx.addIssue({
|
|
370
|
+
code: "custom",
|
|
371
|
+
path: ["entries", index, "extends", position, "plugin"],
|
|
372
|
+
message: host.permissions.includes("site:blocks")
|
|
373
|
+
? `${extension.plugin} asks for "site:blocks", so a plugin that extends it may not read the register or propose imports: ${refused.join(", ")}`
|
|
374
|
+
: `${extension.plugin} reads the register or proposes imports, so a plugin that asks for "site:blocks" may not extend it: ${refused.join(", ")}`,
|
|
375
|
+
params: {
|
|
376
|
+
refusal: {
|
|
377
|
+
code: "extension-permission-refused",
|
|
378
|
+
detail: { ...named, permissions: refused },
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const categories = extensionHostPersonalDataRefused(entry, host);
|
|
385
|
+
if (categories.length > 0) {
|
|
386
|
+
pairRefused.add(entry.id);
|
|
387
|
+
ctx.addIssue({
|
|
388
|
+
code: "custom",
|
|
389
|
+
path: ["entries", index, "extends", position, "plugin"],
|
|
390
|
+
message: `${extension.plugin} handles personal data, so a plugin that asks for "site:blocks" may not extend it: ${categories.join(", ")}`,
|
|
391
|
+
params: {
|
|
392
|
+
refusal: {
|
|
393
|
+
code: "extension-host-personal-data-refused",
|
|
394
|
+
detail: { ...named, categories },
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/*
|
|
402
|
+
* And the rule on the plugins joined by extensions, among those the index
|
|
403
|
+
* lists, as the loader reads it: beside the addons the rule above has not
|
|
404
|
+
* already refused.
|
|
405
|
+
*/
|
|
406
|
+
if (catalog.version === 2) {
|
|
407
|
+
const members = [...plugins.values()]
|
|
408
|
+
.filter((entry) => !pairRefused.has(entry.id))
|
|
409
|
+
.map((entry) => ({
|
|
410
|
+
id: entry.id,
|
|
411
|
+
permissions: entry.permissions,
|
|
412
|
+
extends: entry.extends ?? [],
|
|
413
|
+
}));
|
|
414
|
+
for (const [id, refusal] of extensionGroupRefusals(members)) {
|
|
415
|
+
ctx.addIssue({
|
|
416
|
+
code: "custom",
|
|
417
|
+
path: ["entries", pluginIndex.get(id) ?? 0, "extends"],
|
|
418
|
+
message: `the plugins it is joined to by extensions would hold one that asks for "site:blocks" (${refusal.website.join(", ")}) and one that reads the register or proposes imports (${refusal.register.join(", ")})`,
|
|
419
|
+
params: {
|
|
420
|
+
refusal: {
|
|
421
|
+
code: "extension-group-refused",
|
|
422
|
+
detail: {
|
|
423
|
+
addon: id,
|
|
424
|
+
website: refusal.website,
|
|
425
|
+
register: refusal.register,
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/*
|
|
433
|
+
* A field is in the version that defines it and in no earlier one: an
|
|
434
|
+
* instance that reads only version 1 would refuse the entry, and an index
|
|
435
|
+
* claiming version 1 while carrying it is not one such an instance could
|
|
436
|
+
* read.
|
|
437
|
+
*/
|
|
438
|
+
if (catalog.version === 1) {
|
|
439
|
+
for (const [index, entry] of catalog.entries.entries()) {
|
|
440
|
+
if (entry.type === "plugin" && entry.recipients !== undefined) {
|
|
441
|
+
ctx.addIssue({
|
|
442
|
+
code: "custom",
|
|
443
|
+
path: ["entries", index, "recipients"],
|
|
444
|
+
message: "recipients is not in version 1 of the index; an entry that declares them is listed in version 2",
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/*
|
|
450
|
+
* The manifest's rule on what a recipient may receive, so an entry the
|
|
451
|
+
* loader would refuse is not offered for consent with a category the
|
|
452
|
+
* plugin does not declare it handles. The comparison with the installed
|
|
453
|
+
* manifest comes later; this holds the entry to itself.
|
|
454
|
+
*/
|
|
455
|
+
for (const [index, entry] of catalog.entries.entries()) {
|
|
456
|
+
if (entry.type !== "plugin" || entry.recipients === undefined) {
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
for (const issue of recipientCategoryIssues(entry.recipients, entry.personalData)) {
|
|
460
|
+
ctx.addIssue({
|
|
461
|
+
code: "custom",
|
|
462
|
+
path: ["entries", index, ...issue.path],
|
|
463
|
+
message: issue.message,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
162
467
|
/*
|
|
163
468
|
* An id names one entry in the whole index, not one per type. An install
|
|
164
469
|
* finds its entry by id and then refuses one of the wrong type, so a theme
|
|
@@ -179,6 +484,24 @@ export const catalogSchema = z
|
|
|
179
484
|
});
|
|
180
485
|
}
|
|
181
486
|
});
|
|
487
|
+
/**
|
|
488
|
+
* The refusals of an index that its reader is told in their own language.
|
|
489
|
+
*
|
|
490
|
+
* What the schema says about one entry's field is English for the catalog's
|
|
491
|
+
* curator, who fixes the index from it. These hold one entry against another,
|
|
492
|
+
* an addon against the plugin it extends or against the plugins joined to it,
|
|
493
|
+
* and are the loader's own refusals of the same pair, under the same codes. So
|
|
494
|
+
* the refusal carries its code and the values its sentence is completed with
|
|
495
|
+
* beside the English line, and whoever shows it translates the code.
|
|
496
|
+
*/
|
|
497
|
+
export const CATALOG_REFUSALS = [
|
|
498
|
+
"extension-point-unknown",
|
|
499
|
+
"extension-version-unsupported",
|
|
500
|
+
"extension-personal-data-refused",
|
|
501
|
+
"extension-permission-refused",
|
|
502
|
+
"extension-host-personal-data-refused",
|
|
503
|
+
"extension-group-refused",
|
|
504
|
+
];
|
|
182
505
|
/**
|
|
183
506
|
* Parses a catalog index.
|
|
184
507
|
*
|
|
@@ -195,9 +518,50 @@ export function parseCatalogIndex(input) {
|
|
|
195
518
|
if (result.success) {
|
|
196
519
|
return { ok: true, value: result.data };
|
|
197
520
|
}
|
|
521
|
+
const diagnostics = result.error.issues.map((issue) => ({
|
|
522
|
+
issue: `${issue.path.join(".") || "(root)"}: ${issue.message}`,
|
|
523
|
+
refusal: catalogRefusalOf(issue),
|
|
524
|
+
}));
|
|
198
525
|
return {
|
|
199
526
|
ok: false,
|
|
200
|
-
issues:
|
|
527
|
+
issues: diagnostics.map((diagnostic) => diagnostic.issue),
|
|
528
|
+
diagnostics,
|
|
201
529
|
};
|
|
202
530
|
}
|
|
531
|
+
function catalogRefusalOf(issue) {
|
|
532
|
+
if (issue.code !== "custom" || typeof issue.params !== "object") {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
const refusal = issue.params
|
|
536
|
+
?.refusal;
|
|
537
|
+
return refusal !== undefined && CATALOG_REFUSALS.includes(refusal.code)
|
|
538
|
+
? refusal
|
|
539
|
+
: null;
|
|
540
|
+
}
|
|
541
|
+
/** The field, the curator's line and the values of a point's refusal. */
|
|
542
|
+
function unservedIssue(extension, unserved) {
|
|
543
|
+
switch (unserved.reason) {
|
|
544
|
+
case "extension-point-unknown":
|
|
545
|
+
return {
|
|
546
|
+
field: "point",
|
|
547
|
+
message: `${extension.plugin} declares no extension point "${extension.point}"`,
|
|
548
|
+
detail: {},
|
|
549
|
+
};
|
|
550
|
+
case "extension-version-unsupported":
|
|
551
|
+
return {
|
|
552
|
+
field: "version",
|
|
553
|
+
message: `"${extension.point}" of ${extension.plugin} is at version ${String(unserved.supported)}, not ${String(extension.version)}`,
|
|
554
|
+
detail: {
|
|
555
|
+
version: extension.version,
|
|
556
|
+
supported: unserved.supported,
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
case "extension-personal-data-refused":
|
|
560
|
+
return {
|
|
561
|
+
field: "personalData",
|
|
562
|
+
message: `"${extension.point}" of ${extension.plugin} does not accept ${unserved.categories.join(", ")}`,
|
|
563
|
+
detail: { categories: unserved.categories },
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
}
|
|
203
567
|
//# sourceMappingURL=catalog.js.map
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,6DAA6D;AAC7D,SAAS,gBAAgB,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD;;;;;;;;;OASG;IACH,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IAChC;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAC1D,KAAK,EACH,uEAAuE;KAC1E,CAAC;IACF,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;C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,CAAC,IAAI,CAAC;QACrE,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,yEAAyE;AACzE,SAAS,aAAa,CACpB,SAIC,EACD,QAA+B;IAE/B,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,yBAAyB;YAC5B,OAAO;gBACL,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,GAAG,SAAS,CAAC,MAAM,iCAAiC,SAAS,CAAC,KAAK,GAAG;gBAC/E,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,KAAK,+BAA+B;YAClC,OAAO;gBACL,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,IAAI,SAAS,CAAC,KAAK,QAAQ,SAAS,CAAC,MAAM,kBAAkB,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;gBACpI,MAAM,EAAE;oBACN,OAAO,EAAE,SAAS,CAAC,OAAO;oBAC1B,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B;aACF,CAAC;QACJ,KAAK,iCAAiC;YACpC,OAAO;gBACL,KAAK,EAAE,cAAc;gBACrB,OAAO,EAAE,IAAI,SAAS,CAAC,KAAK,QAAQ,SAAS,CAAC,MAAM,oBAAoB,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACxG,MAAM,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE;aAC5C,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a paid plugin reads about its licence (ADR 0042).
|
|
3
|
+
*
|
|
4
|
+
* The host holds the licences the board entered and verifies them offline,
|
|
5
|
+
* against the keys the plugin's manifest declares and the instance's own id
|
|
6
|
+
* and key, on the association's calendar day. A plugin gets the finding and
|
|
7
|
+
* never the file, and decides for itself what it withholds without an active
|
|
8
|
+
* entitlement: the host loads and serves it either way.
|
|
9
|
+
*/
|
|
10
|
+
/** The version of the licence file format this contract reads. */
|
|
11
|
+
export declare const LICENCE_FORMAT = "openbrf-licence/1";
|
|
12
|
+
/** The version of the presentation format `present()` writes. */
|
|
13
|
+
export declare const LICENCE_PRESENTATION_FORMAT = "openbrf-licence-presentation/1";
|
|
14
|
+
/** The largest licence file the host accepts, in bytes. */
|
|
15
|
+
export declare const LICENCE_FILE_MAX_BYTES = 16384;
|
|
16
|
+
/** The largest presentation a service has to read, in bytes. */
|
|
17
|
+
export declare const LICENCE_PRESENTATION_MAX_BYTES = 24576;
|
|
18
|
+
/**
|
|
19
|
+
* The finding for the entitlement the manifest names, judged today.
|
|
20
|
+
*
|
|
21
|
+
* Dates are `YYYY-MM-DD` on the association's calendar day, and inclusive: a
|
|
22
|
+
* licence valid until a day is active through the whole of it.
|
|
23
|
+
*
|
|
24
|
+
* - `active`: a licence one of the plugin's keys verified names the
|
|
25
|
+
* entitlement, is bound to this instance, and covers today and this release.
|
|
26
|
+
* - `absent`: no licence the plugin's keys verified names the entitlement.
|
|
27
|
+
* - `expired`: today is after its `validUntil`.
|
|
28
|
+
* - `version-not-covered`: this release was published after its
|
|
29
|
+
* `updatesUntil`. An earlier release stays covered.
|
|
30
|
+
* - `wrong-instance`: it was issued to another instance, by id or by key.
|
|
31
|
+
* - `tampered`: it verified when it was entered and no longer does.
|
|
32
|
+
* - `not-yet-valid`: it was issued after today, which is a wrong clock on
|
|
33
|
+
* one side or the other.
|
|
34
|
+
*
|
|
35
|
+
* Without an active licence the finding is that of the licence entered most
|
|
36
|
+
* recently, so a board that has just entered the wrong file is told about
|
|
37
|
+
* that file.
|
|
38
|
+
*/
|
|
39
|
+
export type EntitlementState = {
|
|
40
|
+
status: "active";
|
|
41
|
+
licenceId: string;
|
|
42
|
+
validUntil: string | null;
|
|
43
|
+
updatesUntil: string | null;
|
|
44
|
+
} | {
|
|
45
|
+
status: "absent";
|
|
46
|
+
} | {
|
|
47
|
+
status: "expired";
|
|
48
|
+
licenceId: string;
|
|
49
|
+
validUntil: string;
|
|
50
|
+
} | {
|
|
51
|
+
status: "version-not-covered";
|
|
52
|
+
licenceId: string;
|
|
53
|
+
updatesUntil: string;
|
|
54
|
+
released: string;
|
|
55
|
+
} | {
|
|
56
|
+
status: "wrong-instance";
|
|
57
|
+
licenceId: string;
|
|
58
|
+
} | {
|
|
59
|
+
status: "tampered";
|
|
60
|
+
} | {
|
|
61
|
+
status: "not-yet-valid";
|
|
62
|
+
licenceId: string;
|
|
63
|
+
issuedOn: string;
|
|
64
|
+
};
|
|
65
|
+
export type EntitlementStatus = EntitlementState["status"];
|
|
66
|
+
export declare const ENTITLEMENT_STATUSES: readonly ["active", "absent", "expired", "version-not-covered", "wrong-instance", "tampered", "not-yet-valid"];
|
|
67
|
+
/**
|
|
68
|
+
* A licensed plugin's view of its entitlement.
|
|
69
|
+
*
|
|
70
|
+
* Read on every call rather than once at boot, so a licence the board enters,
|
|
71
|
+
* one that ends, and the next one taking over all reach a running plugin
|
|
72
|
+
* without a restart.
|
|
73
|
+
*/
|
|
74
|
+
export interface PluginEntitlements {
|
|
75
|
+
/** The entitlement the manifest names, judged today. */
|
|
76
|
+
get(): Promise<EntitlementState>;
|
|
77
|
+
/**
|
|
78
|
+
* The active licence with a fresh signature by the instance key, for one of
|
|
79
|
+
* the audiences the manifest declares, as the text to send that service.
|
|
80
|
+
* Null without an active licence.
|
|
81
|
+
*
|
|
82
|
+
* Signed without a network call; sending it is the plugin's. A presentation
|
|
83
|
+
* is good at its audience for five minutes and once, so make one per
|
|
84
|
+
* request rather than keeping one.
|
|
85
|
+
*
|
|
86
|
+
* Throws a RangeError for an audience the manifest does not declare, since
|
|
87
|
+
* that is a defect in the plugin rather than a state of the licence.
|
|
88
|
+
*/
|
|
89
|
+
present(audience: string): Promise<string | null>;
|
|
90
|
+
}
|
|
91
|
+
export interface TestEntitlementsOptions {
|
|
92
|
+
/** What `get()` answers. */
|
|
93
|
+
state: EntitlementState;
|
|
94
|
+
/** The manifest's `licence.audiences`. None by default. */
|
|
95
|
+
audiences?: readonly string[];
|
|
96
|
+
/** What `present()` answers while the state is active. */
|
|
97
|
+
presentation?: (audience: string) => string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A stand-in for `host.entitlements` in a plugin's own tests.
|
|
101
|
+
*
|
|
102
|
+
* It answers with the state it was given and keeps the host's two rules about
|
|
103
|
+
* presenting: an undeclared audience is refused, and nothing is presented
|
|
104
|
+
* without an active licence. A plugin that wants to test the service end of a
|
|
105
|
+
* presentation signs licences with a throwaway key generated in the test;
|
|
106
|
+
* nothing here needs one.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createTestEntitlements(options: TestEntitlementsOptions): PluginEntitlements & {
|
|
109
|
+
state: EntitlementState;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The refusal of an audience the manifest does not declare, worded once for
|
|
113
|
+
* the host and its test double. The audience is left out: it is whatever the
|
|
114
|
+
* plugin passed.
|
|
115
|
+
*/
|
|
116
|
+
export declare function undeclaredAudienceError(): RangeError;
|
|
117
|
+
//# sourceMappingURL=entitlements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.d.ts","sourceRoot":"","sources":["../src/entitlements.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kEAAkE;AAClE,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAElD,iEAAiE;AACjE,eAAO,MAAM,2BAA2B,mCAAmC,CAAC;AAE5E,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,gEAAgE;AAChE,eAAO,MAAM,8BAA8B,QAAS,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG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EAAE,gBAAgB,CAAA;CAAE,CAkBlD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,UAAU,CAKpD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a paid plugin reads about its licence (ADR 0042).
|
|
3
|
+
*
|
|
4
|
+
* The host holds the licences the board entered and verifies them offline,
|
|
5
|
+
* against the keys the plugin's manifest declares and the instance's own id
|
|
6
|
+
* and key, on the association's calendar day. A plugin gets the finding and
|
|
7
|
+
* never the file, and decides for itself what it withholds without an active
|
|
8
|
+
* entitlement: the host loads and serves it either way.
|
|
9
|
+
*/
|
|
10
|
+
/** The version of the licence file format this contract reads. */
|
|
11
|
+
export const LICENCE_FORMAT = "openbrf-licence/1";
|
|
12
|
+
/** The version of the presentation format `present()` writes. */
|
|
13
|
+
export const LICENCE_PRESENTATION_FORMAT = "openbrf-licence-presentation/1";
|
|
14
|
+
/** The largest licence file the host accepts, in bytes. */
|
|
15
|
+
export const LICENCE_FILE_MAX_BYTES = 16_384;
|
|
16
|
+
/** The largest presentation a service has to read, in bytes. */
|
|
17
|
+
export const LICENCE_PRESENTATION_MAX_BYTES = 24_576;
|
|
18
|
+
export const ENTITLEMENT_STATUSES = [
|
|
19
|
+
"active",
|
|
20
|
+
"absent",
|
|
21
|
+
"expired",
|
|
22
|
+
"version-not-covered",
|
|
23
|
+
"wrong-instance",
|
|
24
|
+
"tampered",
|
|
25
|
+
"not-yet-valid",
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* A stand-in for `host.entitlements` in a plugin's own tests.
|
|
29
|
+
*
|
|
30
|
+
* It answers with the state it was given and keeps the host's two rules about
|
|
31
|
+
* presenting: an undeclared audience is refused, and nothing is presented
|
|
32
|
+
* without an active licence. A plugin that wants to test the service end of a
|
|
33
|
+
* presentation signs licences with a throwaway key generated in the test;
|
|
34
|
+
* nothing here needs one.
|
|
35
|
+
*/
|
|
36
|
+
export function createTestEntitlements(options) {
|
|
37
|
+
const audiences = new Set(options.audiences ?? []);
|
|
38
|
+
const double = {
|
|
39
|
+
state: options.state,
|
|
40
|
+
get: () => Promise.resolve(double.state),
|
|
41
|
+
present: (audience) => {
|
|
42
|
+
if (!audiences.has(audience)) {
|
|
43
|
+
return Promise.reject(undeclaredAudienceError());
|
|
44
|
+
}
|
|
45
|
+
if (double.state.status !== "active") {
|
|
46
|
+
return Promise.resolve(null);
|
|
47
|
+
}
|
|
48
|
+
return Promise.resolve(options.presentation?.(audience) ?? `test-presentation:${audience}`);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return double;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The refusal of an audience the manifest does not declare, worded once for
|
|
55
|
+
* the host and its test double. The audience is left out: it is whatever the
|
|
56
|
+
* plugin passed.
|
|
57
|
+
*/
|
|
58
|
+
export function undeclaredAudienceError() {
|
|
59
|
+
return new RangeError("present() was asked for an audience the plugin's manifest does not " +
|
|
60
|
+
"declare under licence.audiences.");
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sourceRoot":"","sources":["../src/entitlements.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD,iEAAiE;AACjE,MAAM,CAAC,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAE5E,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,gEAAgE;AAChE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC;AA4CrD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,qBAAqB;IACrB,gBAAgB;IAChB,UAAU;IACV,eAAe;CACgC,CAAC;AAoClD;;;;;;;;GAQG;AACH,MAAM,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