@openbrf/plugin-sdk 0.0.0-stage → 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.
Files changed (134) hide show
  1. package/LICENSE +661 -0
  2. package/LICENSE-EXCEPTION.md +28 -0
  3. package/README.md +94 -2
  4. package/dist/abort-signal.d.ts +23 -0
  5. package/dist/abort-signal.d.ts.map +1 -0
  6. package/dist/abort-signal.js +2 -0
  7. package/dist/abort-signal.js.map +1 -0
  8. package/dist/action-refusal.d.ts +101 -0
  9. package/dist/action-refusal.d.ts.map +1 -0
  10. package/dist/action-refusal.js +96 -0
  11. package/dist/action-refusal.js.map +1 -0
  12. package/dist/action-schema.d.ts +42 -0
  13. package/dist/action-schema.d.ts.map +1 -0
  14. package/dist/action-schema.js +67 -0
  15. package/dist/action-schema.js.map +1 -0
  16. package/dist/actions.d.ts +287 -0
  17. package/dist/actions.d.ts.map +1 -0
  18. package/dist/actions.js +68 -0
  19. package/dist/actions.js.map +1 -0
  20. package/dist/api-version.d.ts +23 -0
  21. package/dist/api-version.d.ts.map +1 -0
  22. package/dist/api-version.js +27 -0
  23. package/dist/api-version.js.map +1 -0
  24. package/dist/blocks.d.ts +310 -0
  25. package/dist/blocks.d.ts.map +1 -0
  26. package/dist/blocks.js +185 -0
  27. package/dist/blocks.js.map +1 -0
  28. package/dist/catalog.d.ts +707 -0
  29. package/dist/catalog.d.ts.map +1 -0
  30. package/dist/catalog.js +567 -0
  31. package/dist/catalog.js.map +1 -0
  32. package/dist/define-plugin.d.ts +14 -0
  33. package/dist/define-plugin.d.ts.map +1 -0
  34. package/dist/define-plugin.js +15 -0
  35. package/dist/define-plugin.js.map +1 -0
  36. package/dist/entitlements.d.ts +117 -0
  37. package/dist/entitlements.d.ts.map +1 -0
  38. package/dist/entitlements.js +62 -0
  39. package/dist/entitlements.js.map +1 -0
  40. package/dist/extensions.d.ts +183 -0
  41. package/dist/extensions.d.ts.map +1 -0
  42. package/dist/extensions.js +67 -0
  43. package/dist/extensions.js.map +1 -0
  44. package/dist/finances.d.ts +294 -0
  45. package/dist/finances.d.ts.map +1 -0
  46. package/dist/finances.js +56 -0
  47. package/dist/finances.js.map +1 -0
  48. package/dist/findings.d.ts +156 -0
  49. package/dist/findings.d.ts.map +1 -0
  50. package/dist/findings.js +146 -0
  51. package/dist/findings.js.map +1 -0
  52. package/dist/host.d.ts +827 -0
  53. package/dist/host.d.ts.map +1 -0
  54. package/dist/host.js +80 -0
  55. package/dist/host.js.map +1 -0
  56. package/dist/imports.d.ts +104 -0
  57. package/dist/imports.d.ts.map +1 -0
  58. package/dist/imports.js +70 -0
  59. package/dist/imports.js.map +1 -0
  60. package/dist/index.d.ts +34 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +31 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/integrity.d.ts +38 -0
  65. package/dist/integrity.d.ts.map +1 -0
  66. package/dist/integrity.js +105 -0
  67. package/dist/integrity.js.map +1 -0
  68. package/dist/localized-text.d.ts +18 -0
  69. package/dist/localized-text.d.ts.map +1 -0
  70. package/dist/localized-text.js +17 -0
  71. package/dist/localized-text.js.map +1 -0
  72. package/dist/manifest.d.ts +1122 -0
  73. package/dist/manifest.d.ts.map +1 -0
  74. package/dist/manifest.js +1118 -0
  75. package/dist/manifest.js.map +1 -0
  76. package/dist/module.d.ts +35 -0
  77. package/dist/module.d.ts.map +1 -0
  78. package/dist/module.js +2 -0
  79. package/dist/module.js.map +1 -0
  80. package/dist/package-check.d.ts +66 -0
  81. package/dist/package-check.d.ts.map +1 -0
  82. package/dist/package-check.js +755 -0
  83. package/dist/package-check.js.map +1 -0
  84. package/dist/permissions.d.ts +224 -0
  85. package/dist/permissions.d.ts.map +1 -0
  86. package/dist/permissions.js +277 -0
  87. package/dist/permissions.js.map +1 -0
  88. package/dist/recipients.d.ts +139 -0
  89. package/dist/recipients.d.ts.map +1 -0
  90. package/dist/recipients.js +223 -0
  91. package/dist/recipients.js.map +1 -0
  92. package/dist/records.d.ts +130 -0
  93. package/dist/records.d.ts.map +1 -0
  94. package/dist/records.js +85 -0
  95. package/dist/records.js.map +1 -0
  96. package/dist/require-capability.d.ts +37 -0
  97. package/dist/require-capability.d.ts.map +1 -0
  98. package/dist/require-capability.js +88 -0
  99. package/dist/require-capability.js.map +1 -0
  100. package/dist/settings-schema.d.ts +130 -0
  101. package/dist/settings-schema.d.ts.map +1 -0
  102. package/dist/settings-schema.js +272 -0
  103. package/dist/settings-schema.js.map +1 -0
  104. package/dist/standard-schema.d.ts +43 -0
  105. package/dist/standard-schema.d.ts.map +1 -0
  106. package/dist/standard-schema.js +2 -0
  107. package/dist/standard-schema.js.map +1 -0
  108. package/package.json +55 -3
  109. package/src/abort-signal.ts +22 -0
  110. package/src/action-refusal.ts +178 -0
  111. package/src/action-schema.ts +89 -0
  112. package/src/actions.ts +344 -0
  113. package/src/api-version.ts +28 -0
  114. package/src/blocks.ts +289 -0
  115. package/src/catalog.ts +679 -0
  116. package/src/define-plugin.ts +18 -0
  117. package/src/entitlements.ts +150 -0
  118. package/src/extensions.ts +212 -0
  119. package/src/finances.ts +317 -0
  120. package/src/findings.ts +163 -0
  121. package/src/host.ts +894 -0
  122. package/src/imports.ts +135 -0
  123. package/src/index.ts +316 -0
  124. package/src/integrity.ts +125 -0
  125. package/src/localized-text.ts +19 -0
  126. package/src/manifest.ts +1412 -0
  127. package/src/module.ts +38 -0
  128. package/src/package-check.ts +894 -0
  129. package/src/permissions.ts +295 -0
  130. package/src/recipients.ts +294 -0
  131. package/src/records.ts +172 -0
  132. package/src/require-capability.ts +106 -0
  133. package/src/settings-schema.ts +334 -0
  134. package/src/standard-schema.ts +39 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAuB,MAAM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O,GAAG,kBAAkB,CAcpE"}
@@ -0,0 +1,567 @@
1
+ import { z } from "zod";
2
+ import { IntegrityError, parseSha512 } from "./integrity.js";
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";
5
+ import { PLUGIN_PERMISSIONS, PLUGIN_PERSONAL_DATA_CATEGORIES, } from "./permissions.js";
6
+ import { declaredRecipientsSchema, pluginRecipientSchema, recipientCategoryIssues, } from "./recipients.js";
7
+ /**
8
+ * The catalog index.
9
+ *
10
+ * One file listing everything an instance may install: plugins and themes
11
+ * alike, since both are distributed the same way and the board browses one
12
+ * screen per kind rather than one source per kind. Delisting is a commit
13
+ * against the index, which is why an instance re-reads it rather than caching
14
+ * it across installs.
15
+ *
16
+ * Exported so the index is checked by the same schema wherever it is read: by
17
+ * the instance before it offers an entry to a board, and by the catalog's own
18
+ * check before a listing is merged.
19
+ *
20
+ * Entries are parsed strictly. The index arrives over the network, and an
21
+ * entry the instance does not fully understand is an entry it must not offer
22
+ * to a board for consent - the consent screen's whole job is to say precisely
23
+ * what is being agreed to.
24
+ *
25
+ * Every object in it is strict as well: a field this version of the index does
26
+ * not define is refused, never dropped. Dropped, a misspelled field of the
27
+ * declaration would be replaced by its default before the consent screen or
28
+ * any check of the manifest saw it. The index carries its version for exactly
29
+ * this, so a new field is a new index version rather than a key an older
30
+ * instance ignores.
31
+ */
32
+ /** Whether `declared` is a digest `parseSha512` can read. */
33
+ function isReadableSha512(declared) {
34
+ try {
35
+ parseSha512(declared);
36
+ return true;
37
+ }
38
+ catch (error) {
39
+ if (error instanceof IntegrityError) {
40
+ return false;
41
+ }
42
+ throw error;
43
+ }
44
+ }
45
+ /** A tarball and the digest its bytes must hash to. */
46
+ export const catalogArtifactSchema = z.strictObject({
47
+ /**
48
+ * Direct URL.
49
+ *
50
+ * https on a curated instance, and nothing else: the shape is checked here
51
+ * but the destination is decided at fetch time, where http: and file: are
52
+ * refused unless the instance has opted out of curation. That is what keeps
53
+ * an entry - which is data fetched from elsewhere - from naming a `file:`
54
+ * path and having the instance read its own disk, or a plain-http address
55
+ * inside the network the instance sits in.
56
+ */
57
+ url: z.string().min(1).max(2000),
58
+ /**
59
+ * "sha512-<base64>" or 128 hex characters.
60
+ *
61
+ * Read through the same `parseSha512` the instance verifies a download with,
62
+ * so an entry the catalog's check lets through is one the instance can read,
63
+ * and an index with a badly spelled digest is refused by `parseCatalogIndex`
64
+ * alone.
65
+ */
66
+ sha512: z.string().min(1).max(200).refine(isReadableSha512, {
67
+ error: 'Expected a digest written as "sha512-<base64>" or 128 hex characters.',
68
+ }),
69
+ bytes: z.int().min(1).optional(),
70
+ });
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();
85
+ /** Strict, and `.extend()` keeps it so for both kinds of entry. */
86
+ const baseEntrySchema = z.strictObject({
87
+ /**
88
+ * Unique across the whole index, whatever the entry's type: an install
89
+ * looks an entry up by id alone.
90
+ */
91
+ id: pluginIdSchema,
92
+ version: z.string().min(1).max(64),
93
+ /** The curator's text, in both languages the interface is offered in. */
94
+ name: localizedTextSchema,
95
+ description: localizedTextSchema,
96
+ artifact: catalogArtifactSchema,
97
+ homepage: z.string().max(2000).optional(),
98
+ /** Set on an entry that is still listed but should not be installed anew. */
99
+ deprecated: z.boolean().default(false),
100
+ });
101
+ export const catalogPluginEntrySchema = baseEntrySchema
102
+ .extend({
103
+ type: z.literal("plugin"),
104
+ /**
105
+ * The npm package name the tarball unpacks as. Needed because the installer
106
+ * writes a dependency set for npm, which keys on the package name and not on
107
+ * the catalog id.
108
+ */
109
+ packageName: z.string().min(1).max(214),
110
+ /** Gated against the host's own contract version before an install starts. */
111
+ apiVersion: z.int().min(1),
112
+ /**
113
+ * Repeated from the plugin's manifest so the consent screen can be shown
114
+ * before anything is downloaded. The installed manifest is authoritative:
115
+ * the loader compares the two and refuses a plugin that asks for more than
116
+ * the board consented to.
117
+ */
118
+ permissions: z.array(z.enum(PLUGIN_PERMISSIONS)).max(16).default([]),
119
+ personalData: z
120
+ .array(z.enum(PLUGIN_PERSONAL_DATA_CATEGORIES))
121
+ .max(16)
122
+ .default([]),
123
+ /**
124
+ * The actions the plugin proposes, on the same terms as the two above.
125
+ *
126
+ * The widest part of the declaration, and so the part the consent screen
127
+ * most needs before anything is downloaded: an action names a capability and
128
+ * offers it to callers the board decides on.
129
+ *
130
+ * The manifest's own action fields and its own uniqueness rule, not a
131
+ * second array of the same thing: the rule on the ids has to hold at
132
+ * whichever boundary is read first, and two copies is two places for it to
133
+ * stop holding. Read strictly here, as everything in the index is.
134
+ */
135
+ actions: declaredActionsSchema(pluginActionSchema.strict()).default([]),
136
+ /**
137
+ * The route that serves MCP, repeated on the same terms as the three above.
138
+ *
139
+ * Both rules about it are decided before anything is downloaded - a second
140
+ * plugin declaring it is refused, and the reserved id `mcp-connector` may be
141
+ * taken only by a plugin that does declare it - so the index has to carry it.
142
+ * The manifest's own field schema rather than a second spelling of it: the
143
+ * value becomes a URL an unauthenticated caller is pointed at, and one
144
+ * definition of what it may contain is the point of that schema.
145
+ */
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
+ }
227
+ });
228
+ /**
229
+ * A theme entry. Themes install through the same download-and-verify path and
230
+ * are listed in the same index; what happens after the bytes are verified is
231
+ * the theme installer's business, not this schema's.
232
+ *
233
+ * No package name: a theme is data read out of its archive, never an npm
234
+ * package, and nothing that installs one keys on a package name.
235
+ */
236
+ export const catalogThemeEntrySchema = baseEntrySchema.extend({
237
+ type: z.literal("theme"),
238
+ /** The token contract range the theme was authored against. */
239
+ contract: z.string().min(1).max(64).optional(),
240
+ /** The theme it inherits from, as its manifest names it. */
241
+ extends: z.string().min(1).max(64).optional(),
242
+ });
243
+ export const catalogEntrySchema = z.discriminatedUnion("type", [
244
+ catalogPluginEntrySchema,
245
+ catalogThemeEntrySchema,
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];
256
+ export const catalogSchema = z
257
+ .strictObject({
258
+ /** Index format version, so a future shape can be recognised and refused. */
259
+ version: z.literal(CATALOG_INDEX_VERSIONS),
260
+ entries: z.array(catalogEntrySchema).max(500),
261
+ })
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
+ }
467
+ /*
468
+ * An id names one entry in the whole index, not one per type. An install
469
+ * finds its entry by id and then refuses one of the wrong type, so a theme
470
+ * sharing a plugin's id would leave that plugin impossible to install, and
471
+ * which of the two a board got would depend on the order of the file.
472
+ */
473
+ const firstIndexById = new Map();
474
+ for (const [index, entry] of catalog.entries.entries()) {
475
+ const first = firstIndexById.get(entry.id);
476
+ if (first === undefined) {
477
+ firstIndexById.set(entry.id, index);
478
+ continue;
479
+ }
480
+ ctx.addIssue({
481
+ code: "custom",
482
+ path: ["entries", index, "id"],
483
+ message: `"${entry.id}" is already the id of entry ${String(first)}; an id appears once in the index`,
484
+ });
485
+ }
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
+ ];
505
+ /**
506
+ * Parses a catalog index.
507
+ *
508
+ * A single malformed entry rejects the whole index rather than being dropped
509
+ * quietly. A board that installs from a catalog which silently lost an entry
510
+ * has no way to tell that from an entry that was delisted on purpose, and the
511
+ * two mean opposite things.
512
+ *
513
+ * Returns a result rather than throwing, as `parsePluginPackage` does, so a
514
+ * catalog's own check can list every problem at once.
515
+ */
516
+ export function parseCatalogIndex(input) {
517
+ const result = catalogSchema.safeParse(input);
518
+ if (result.success) {
519
+ return { ok: true, value: result.data };
520
+ }
521
+ const diagnostics = result.error.issues.map((issue) => ({
522
+ issue: `${issue.path.join(".") || "(root)"}: ${issue.message}`,
523
+ refusal: catalogRefusalOf(issue),
524
+ }));
525
+ return {
526
+ ok: false,
527
+ issues: diagnostics.map((diagnostic) => diagnostic.issue),
528
+ diagnostics,
529
+ };
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
+ }
567
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAA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AAC,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,14 @@
1
+ import type { PluginModuleFactory } from "./module.ts";
2
+ /**
3
+ * Declares a plugin's server entry point.
4
+ *
5
+ * Deliberately an identity function. ADR 0003 requires a plugin to ship a
6
+ * prebuilt CJS bundle whose only externals are host packages, so anything
7
+ * this helper did at runtime would either have to be bundled into every
8
+ * plugin or would make the SDK a runtime dependency the host has to resolve
9
+ * for it. Being identity means a bundler inlines it to nothing and the value
10
+ * the helper adds - the type of the factory, checked at the author's build
11
+ * time - costs the running instance nothing.
12
+ */
13
+ export declare function definePlugin(factory: PluginModuleFactory): PluginModuleFactory;
14
+ //# sourceMappingURL=define-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-plugin.d.ts","sourceRoot":"","sources":["../src/define-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAErB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Declares a plugin's server entry point.
3
+ *
4
+ * Deliberately an identity function. ADR 0003 requires a plugin to ship a
5
+ * prebuilt CJS bundle whose only externals are host packages, so anything
6
+ * this helper did at runtime would either have to be bundled into every
7
+ * plugin or would make the SDK a runtime dependency the host has to resolve
8
+ * for it. Being identity means a bundler inlines it to nothing and the value
9
+ * the helper adds - the type of the factory, checked at the author's build
10
+ * time - costs the running instance nothing.
11
+ */
12
+ export function definePlugin(factory) {
13
+ return factory;
14
+ }
15
+ //# sourceMappingURL=define-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-plugin.js","sourceRoot":"","sources":["../src/define-plugin.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC1B,OAA4B;IAE5B,OAAO,OAAO,CAAC;AACjB,CAAC"}