@kubohiroya/turbowarp-extension-security-dialog 0.9.2 → 0.11.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/NOTICE.md CHANGED
@@ -8,14 +8,16 @@ notice, so this code can be combined into a larger work distributed under GPL-3.
8
8
  the TurboWarp-Plus Editor ships it.
9
9
 
10
10
  `assets/common.svg` is the fallback icon shown when an extension has no preview of its own. It is
11
- original to this package: a jigsaw piece outline with a serif T, drawn for it and derived from no
11
+ original to this package: white code brackets on a gray square, drawn for it and derived from no
12
12
  other work. `scripts/build.ts` embeds it into `dist` as a base64 data URI, so it travels in the
13
13
  published package.
14
14
 
15
- `assets/trusted.svg` is the mark beside an extension the host trusts: the TurboWarp Plus mark (the
15
+ `assets/trusted.svg` is the mark beside a host-confirmed TurboWarp Plus family extension: the TurboWarp Plus mark (the
16
16
  hat block with a warp swirl and a plus sign, drawn by the same author for the TurboWarp-Plus Editor)
17
17
  with a green check over it. It is embedded into `dist` the same way.
18
18
 
19
+ `assets/host-trusted.svg` is an original, unbranded check mark for other extensions trusted by the host.
20
+
19
21
  ## JavaScript parsing
20
22
 
21
23
  The review bundles Acorn and Acorn Walk to read extension names without executing the source.
package/README.ja.md CHANGED
@@ -145,6 +145,20 @@ HTTP(S)のソースから説明を読み取り、相対バナーURLは取得後
145
145
  サンドボックスなしを適用します。すべての行が信頼済みの作品では、ホストは `requiresReview` で確認を
146
146
  省略できます。
147
147
 
148
+ 実行の信頼とファミリー所属は別です。ホストが Plus カタログとの照合で
149
+ `entry.state.plusFamily` も指定した行だけに Plus マークを表示します。それ以外の信頼済みの行は、
150
+ ブランドを含まないチェックで示します。`ExtensionRow` 単体では `plusFamily` プロパティで指定します。
151
+ 拡張が自称するメタデータや、ID の一致だけでは所属を決めません。
152
+
153
+ TurboWarp ギャラリーの拡張は、公式メタデータとコードの完全な URL を照合して画像を取得します。
154
+ 画像取得とソースの説明取得は並行して進み、操作や実行許可を待たせません。
155
+ 画像がない場合や表示に失敗した場合は、ブランドを含まない汎用アイコンへ戻します。
156
+
157
+ ギャラリーのバナーは180×90pxで表示し、それ以外の拡張も同じ高さ90pxの枠に揃えます。バナーレイアウトのないファミリー拡張は、
158
+ カタログが選んだブロックSVGを縦横比を保って枠内いっぱいに中央表示します。
159
+ 作品を開く場合も、URLと固定ハッシュを照合してカタログ画像を取得します。
160
+ 狭幅では説明を画像の上下に配置し、枠を画面幅に合わせて縮小します。
161
+
148
162
  **記録された答えは、いまも選択肢である場合だけ尊重します。** 作品が `remote-cacheable` から
149
163
  埋め込みに変わった、行が信頼済みになった、といった場合に、もう提示しない答えを持ち込みません。
150
164
 
package/README.md CHANGED
@@ -129,7 +129,12 @@ scrolls independently of Cancel and Add. Dismissing the unsandboxed notice prese
129
129
  and returns focus to the control that opened it.
130
130
 
131
131
  Individual review keeps its top action visibly selected and disabled. Rows use the host's icon or
132
- the source's declared banner; the common icon is only for rows without a picture declaration.
132
+ the source's declared banner. Gallery images are resolved against the official catalog by the
133
+ full extension URL, independently of source metadata loading. Missing or broken pictures use
134
+ an unbranded common icon. Picture loading never grants execution permission.
135
+ Gallery banners use a 180 by 90 area, with other extension previews sharing its 90px height. Square family block SVGs fill its height and
136
+ stay centered without distortion. Opening a project can resolve the same catalog artwork by
137
+ its URL and pinned digest. Narrow screens stack the description and preview and scale the area to fit.
133
138
  Display metadata can be read from HTTP(S), and relative banners resolve against the final source URL.
134
139
  When CORS prevents caching an image, it can still be displayed directly by the browser.
135
140
 
@@ -138,6 +143,11 @@ GitHub versions link to their release notes. The description preserves line brea
138
143
  HTTP(S) URLs and email addresses into links. The creator's contact appears next to their name
139
144
  when supplied.
140
145
 
146
+ Execution trust and family membership are separate: only rows with host-confirmed
147
+ `entry.state.plusFamily` use the Plus mark. Other trusted rows use an unbranded check.
148
+ For a standalone `ExtensionRow`, pass `plusFamily` explicitly after checking the host's Plus
149
+ catalog. Extension-declared metadata and matching IDs alone do not establish membership.
150
+
141
151
  ### Using one row of the list
142
152
 
143
153
  `ExtensionRow` draws the same row the screen draws for each extension: its name (with a checkbox, if it can be chosen), IDs, trusted mark, version with a link to its release notes, picture, description, and creator with contact. Another screen that lists extensions shows them the same way. In TurboWarp Plus Editor, the screen that chooses which block palette groups to show uses it.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.9.2",
4
- "revision": "fb4b579ba5ea450cb2c7a61c5fe616ac33239bbb",
3
+ "version": "0.11.0",
4
+ "revision": "6f06c900f2a1d5ecf9ec61d9dc751cb15f2bc755",
5
5
  "sourceState": "commit"
6
6
  }
@@ -227,7 +227,7 @@ var reviewRows = (entries, vm, loader = true) => entries.map((entry) => ({
227
227
  metadata: entry.metadata,
228
228
  source: { kind: loader ? "catalog" : "legacy", url: entry.url },
229
229
  dependencies: [...entry.dependencies || []],
230
- state: { trusted: true, loaded: vm.extensionManager.isExtensionLoaded(entry.id) }
230
+ state: { trusted: true, plusFamily: true, loaded: vm.extensionManager.isExtensionLoaded(entry.id) }
231
231
  }));
232
232
  function createCatalogLibrary({
233
233
  catalog: plusCatalog,
@@ -195,7 +195,7 @@ var reviewRows = (entries, vm, loader = true) => entries.map((entry) => ({
195
195
  metadata: entry.metadata,
196
196
  source: { kind: loader ? "catalog" : "legacy", url: entry.url },
197
197
  dependencies: [...entry.dependencies || []],
198
- state: { trusted: true, loaded: vm.extensionManager.isExtensionLoaded(entry.id) }
198
+ state: { trusted: true, plusFamily: true, loaded: vm.extensionManager.isExtensionLoaded(entry.id) }
199
199
  }));
200
200
  function createCatalogLibrary({
201
201
  catalog: plusCatalog,
@@ -0,0 +1,9 @@
1
+ import type { ReviewEntry } from './review-types.js';
2
+ export interface PreviewCatalog {
3
+ read(signal: AbortSignal): Promise<{
4
+ catalog?: unknown;
5
+ icons?: Record<string, string>;
6
+ }>;
7
+ }
8
+ /** The catalog already chooses the declared banner or the package's block SVG. */
9
+ export declare function createCatalogPreviewResolver(catalog?: PreviewCatalog): (entry: ReviewEntry, signal: AbortSignal) => Promise<string | undefined>;
@@ -17,6 +17,8 @@ export interface ExtensionRowProps {
17
17
  locale?: string;
18
18
  /** Marks the row as trusted by the host. */
19
19
  trusted?: boolean;
20
+ /** The host confirmed membership in the TurboWarp Plus family. Independent of execution trust. */
21
+ plusFamily?: boolean;
20
22
  /** Given, the row has a checkbox, and its picture chooses the same way. */
21
23
  pick?: ExtensionRowPick;
22
24
  /** Where pictures are kept between visits; null keeps nothing. */
@@ -33,5 +35,5 @@ export interface ExtensionRowProps {
33
35
  * picture, what it says it does and who made it. The review screen and any other list of
34
36
  * extensions draw the same row, so an extension looks the same wherever it is offered.
35
37
  */
36
- export declare const ExtensionRow: ({ metadata, ids, locale, trusted, pick, previewCache, itemProps, details, children }: ExtensionRowProps) => React.JSX.Element;
38
+ export declare const ExtensionRow: ({ metadata, ids, locale, trusted, plusFamily, pick, previewCache, itemProps, details, children }: ExtensionRowProps) => React.JSX.Element;
37
39
  export default ExtensionRow;
@@ -0,0 +1,2 @@
1
+ /** One catalog read per review, matched by the code's full URL rather than a claimed ID. */
2
+ export declare function createGalleryPreviewResolver(): (url: string, signal: AbortSignal) => Promise<string | undefined>;
package/dist/index.cjs CHANGED
@@ -36,8 +36,10 @@ var index_exports = {};
36
36
  __export(index_exports, {
37
37
  allRequireUnsandboxed: () => allRequireUnsandboxed,
38
38
  contradictsDeclaration: () => contradictsDeclaration,
39
+ createCatalogPreviewResolver: () => createCatalogPreviewResolver,
39
40
  createDecisionStorage: () => createDecisionStorage,
40
41
  createExtensionWaitDialog: () => createExtensionWaitDialog,
42
+ createGalleryPreviewResolver: () => createGalleryPreviewResolver,
41
43
  createPreviewCache: () => createPreviewCache,
42
44
  decodeExtensionDataURL: () => decodeExtensionDataURL,
43
45
  defaultDecision: () => defaultDecision,
@@ -347,6 +349,82 @@ async function loadExtensionInfo(url, signal) {
347
349
  return { source, metadata };
348
350
  }
349
351
 
352
+ // src/gallery-preview.ts
353
+ var origin = "https://extensions.turbowarp.org/";
354
+ var catalogURL = `${origin}generated-metadata/extensions-v0.json`;
355
+ function galleryURL(value) {
356
+ if (typeof value !== "string" || !value.trim()) return;
357
+ try {
358
+ const url = new URL(value, origin);
359
+ if (url.origin === new URL(origin).origin && !url.username && !url.password && !url.search && !url.hash) {
360
+ return url.href;
361
+ }
362
+ } catch (e) {
363
+ }
364
+ }
365
+ function createGalleryPreviewResolver() {
366
+ let pending;
367
+ return async (url, signal) => {
368
+ if (!url.startsWith(origin) || galleryURL(url) !== url || signal.aborted) return;
369
+ if (!pending) {
370
+ pending = (async () => {
371
+ const controller = new AbortController();
372
+ const abort = () => controller.abort();
373
+ signal.addEventListener("abort", abort, { once: true });
374
+ const timer = setTimeout(abort, 4e3);
375
+ try {
376
+ const response = await fetch(catalogURL, {
377
+ signal: controller.signal,
378
+ credentials: "omit",
379
+ referrerPolicy: "no-referrer"
380
+ });
381
+ if (!response.ok) return /* @__PURE__ */ new Map();
382
+ const data = await response.json();
383
+ const pictures = /* @__PURE__ */ new Map();
384
+ const seen = /* @__PURE__ */ new Set();
385
+ for (const item of Array.isArray(data == null ? void 0 : data.extensions) ? data.extensions : []) {
386
+ if (!item || typeof item.slug !== "string") continue;
387
+ const source = galleryURL(`${origin}${item.slug}.js`);
388
+ const image = galleryURL(item.image);
389
+ if (!source) continue;
390
+ if (seen.has(source)) {
391
+ pictures.delete(source);
392
+ continue;
393
+ }
394
+ seen.add(source);
395
+ if (image) pictures.set(source, image);
396
+ }
397
+ return pictures;
398
+ } catch (e) {
399
+ return /* @__PURE__ */ new Map();
400
+ } finally {
401
+ clearTimeout(timer);
402
+ signal.removeEventListener("abort", abort);
403
+ }
404
+ })();
405
+ }
406
+ return (await pending).get(url);
407
+ };
408
+ }
409
+
410
+ // src/catalog-preview.ts
411
+ function createCatalogPreviewResolver(catalog) {
412
+ let pending;
413
+ return async (entry, signal) => {
414
+ var _a;
415
+ if (!catalog || !((_a = entry.state) == null ? void 0 : _a.plusFamily) || signal.aborted) return;
416
+ pending != null ? pending : pending = catalog.read(signal).then((read) => ({
417
+ entries: read.catalog ? parseExtensionCatalog(read.catalog) : [],
418
+ icons: read.icons || {}
419
+ })).catch(() => ({ entries: [], icons: {} }));
420
+ const { entries, icons } = await pending;
421
+ if (signal.aborted) return;
422
+ const source = entry.source;
423
+ const item = entries.find((item2) => entry.ids.includes(item2.id) && ("url" in source && !source.url.startsWith("data:") ? item2.url === source.url && (!("sha256" in source) || source.sha256 === item2.sha256) : "sha256" in source && source.sha256 === item2.sha256));
424
+ return item && (icons[item.id] || item.metadata.banner);
425
+ };
426
+ }
427
+
350
428
  // src/selection.ts
351
429
  function resolveExtensionSelection(entries, chosen = [], loaded = []) {
352
430
  const byId = new Map(entries.map((entry) => [entry.id, entry]));
@@ -595,7 +673,8 @@ var messages = {
595
673
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
596
674
  closeWarning: "Close",
597
675
  "requirement-required": "\u26A0\uFE0F Needs to run without the sandbox",
598
- trusted: "Trusted by TurboWarp Plus: runs without the sandbox",
676
+ trusted: "Trusted by the host: runs without the sandbox",
677
+ plusFamily: "TurboWarp Plus family",
599
678
  trustedNote: "Catalog extensions are treated like TurboWarp\u2019s own gallery and are not asked about.",
600
679
  "state-loaded": "\u25B6\uFE0F Already running",
601
680
  "state-dependency": "\u{1F517} Needed by {names}",
@@ -653,7 +732,8 @@ var messages = {
653
732
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
654
733
  closeWarning: "\u9589\u3058\u308B",
655
734
  "requirement-required": "\u26A0\uFE0F \u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981",
656
- trusted: "TurboWarp Plus \u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
735
+ trusted: "\u30DB\u30B9\u30C8\u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
736
+ plusFamily: "TurboWarp Plus \u30D5\u30A1\u30DF\u30EA\u30FC",
657
737
  trustedNote: "\u30AB\u30BF\u30ED\u30B0\u306E\u62E1\u5F35\u306F TurboWarp \u306E\u6A19\u6E96\u30AE\u30E3\u30E9\u30EA\u30FC\u3068\u540C\u3058\u6271\u3044\u3067\u3001\u78BA\u8A8D\u3092\u6C42\u3081\u307E\u305B\u3093\u3002",
658
738
  "state-loaded": "\u25B6\uFE0F \u8AAD\u307F\u8FBC\u307F\u6E08\u307F",
659
739
  "state-dependency": "\u{1F517} {names} \u304C\u5FC5\u8981\u3068\u3057\u3066\u3044\u307E\u3059",
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export type * from './review-types.js';
2
2
  export * from './catalog.js';
3
3
  export * from './metadata.js';
4
+ export { createGalleryPreviewResolver } from './gallery-preview.js';
5
+ export { createCatalogPreviewResolver } from './catalog-preview.js';
6
+ export type { PreviewCatalog } from './catalog-preview.js';
4
7
  export * from './selection.js';
5
8
  export * from './storage.js';
6
9
  export * from './decisions.js';
package/dist/index.mjs CHANGED
@@ -302,6 +302,82 @@ async function loadExtensionInfo(url, signal) {
302
302
  return { source, metadata };
303
303
  }
304
304
 
305
+ // src/gallery-preview.ts
306
+ var origin = "https://extensions.turbowarp.org/";
307
+ var catalogURL = `${origin}generated-metadata/extensions-v0.json`;
308
+ function galleryURL(value) {
309
+ if (typeof value !== "string" || !value.trim()) return;
310
+ try {
311
+ const url = new URL(value, origin);
312
+ if (url.origin === new URL(origin).origin && !url.username && !url.password && !url.search && !url.hash) {
313
+ return url.href;
314
+ }
315
+ } catch (e) {
316
+ }
317
+ }
318
+ function createGalleryPreviewResolver() {
319
+ let pending;
320
+ return async (url, signal) => {
321
+ if (!url.startsWith(origin) || galleryURL(url) !== url || signal.aborted) return;
322
+ if (!pending) {
323
+ pending = (async () => {
324
+ const controller = new AbortController();
325
+ const abort = () => controller.abort();
326
+ signal.addEventListener("abort", abort, { once: true });
327
+ const timer = setTimeout(abort, 4e3);
328
+ try {
329
+ const response = await fetch(catalogURL, {
330
+ signal: controller.signal,
331
+ credentials: "omit",
332
+ referrerPolicy: "no-referrer"
333
+ });
334
+ if (!response.ok) return /* @__PURE__ */ new Map();
335
+ const data = await response.json();
336
+ const pictures = /* @__PURE__ */ new Map();
337
+ const seen = /* @__PURE__ */ new Set();
338
+ for (const item of Array.isArray(data == null ? void 0 : data.extensions) ? data.extensions : []) {
339
+ if (!item || typeof item.slug !== "string") continue;
340
+ const source = galleryURL(`${origin}${item.slug}.js`);
341
+ const image = galleryURL(item.image);
342
+ if (!source) continue;
343
+ if (seen.has(source)) {
344
+ pictures.delete(source);
345
+ continue;
346
+ }
347
+ seen.add(source);
348
+ if (image) pictures.set(source, image);
349
+ }
350
+ return pictures;
351
+ } catch (e) {
352
+ return /* @__PURE__ */ new Map();
353
+ } finally {
354
+ clearTimeout(timer);
355
+ signal.removeEventListener("abort", abort);
356
+ }
357
+ })();
358
+ }
359
+ return (await pending).get(url);
360
+ };
361
+ }
362
+
363
+ // src/catalog-preview.ts
364
+ function createCatalogPreviewResolver(catalog) {
365
+ let pending;
366
+ return async (entry, signal) => {
367
+ var _a;
368
+ if (!catalog || !((_a = entry.state) == null ? void 0 : _a.plusFamily) || signal.aborted) return;
369
+ pending != null ? pending : pending = catalog.read(signal).then((read) => ({
370
+ entries: read.catalog ? parseExtensionCatalog(read.catalog) : [],
371
+ icons: read.icons || {}
372
+ })).catch(() => ({ entries: [], icons: {} }));
373
+ const { entries, icons } = await pending;
374
+ if (signal.aborted) return;
375
+ const source = entry.source;
376
+ const item = entries.find((item2) => entry.ids.includes(item2.id) && ("url" in source && !source.url.startsWith("data:") ? item2.url === source.url && (!("sha256" in source) || source.sha256 === item2.sha256) : "sha256" in source && source.sha256 === item2.sha256));
377
+ return item && (icons[item.id] || item.metadata.banner);
378
+ };
379
+ }
380
+
305
381
  // src/selection.ts
306
382
  function resolveExtensionSelection(entries, chosen = [], loaded = []) {
307
383
  const byId = new Map(entries.map((entry) => [entry.id, entry]));
@@ -550,7 +626,8 @@ var messages = {
550
626
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
551
627
  closeWarning: "Close",
552
628
  "requirement-required": "\u26A0\uFE0F Needs to run without the sandbox",
553
- trusted: "Trusted by TurboWarp Plus: runs without the sandbox",
629
+ trusted: "Trusted by the host: runs without the sandbox",
630
+ plusFamily: "TurboWarp Plus family",
554
631
  trustedNote: "Catalog extensions are treated like TurboWarp\u2019s own gallery and are not asked about.",
555
632
  "state-loaded": "\u25B6\uFE0F Already running",
556
633
  "state-dependency": "\u{1F517} Needed by {names}",
@@ -608,7 +685,8 @@ var messages = {
608
685
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
609
686
  closeWarning: "\u9589\u3058\u308B",
610
687
  "requirement-required": "\u26A0\uFE0F \u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981",
611
- trusted: "TurboWarp Plus \u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
688
+ trusted: "\u30DB\u30B9\u30C8\u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
689
+ plusFamily: "TurboWarp Plus \u30D5\u30A1\u30DF\u30EA\u30FC",
612
690
  trustedNote: "\u30AB\u30BF\u30ED\u30B0\u306E\u62E1\u5F35\u306F TurboWarp \u306E\u6A19\u6E96\u30AE\u30E3\u30E9\u30EA\u30FC\u3068\u540C\u3058\u6271\u3044\u3067\u3001\u78BA\u8A8D\u3092\u6C42\u3081\u307E\u305B\u3093\u3002",
613
691
  "state-loaded": "\u25B6\uFE0F \u8AAD\u307F\u8FBC\u307F\u6E08\u307F",
614
692
  "state-dependency": "\u{1F517} {names} \u304C\u5FC5\u8981\u3068\u3057\u3066\u3044\u307E\u3059",
@@ -732,8 +810,10 @@ function createExtensionWaitDialog(document, locale = "en", { delayMs = 300 } =
732
810
  export {
733
811
  allRequireUnsandboxed,
734
812
  contradictsDeclaration,
813
+ createCatalogPreviewResolver,
735
814
  createDecisionStorage,
736
815
  createExtensionWaitDialog,
816
+ createGalleryPreviewResolver,
737
817
  createPreviewCache,
738
818
  decodeExtensionDataURL,
739
819
  defaultDecision,
@@ -60,7 +60,8 @@ var messages = {
60
60
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
61
61
  closeWarning: "Close",
62
62
  "requirement-required": "\u26A0\uFE0F Needs to run without the sandbox",
63
- trusted: "Trusted by TurboWarp Plus: runs without the sandbox",
63
+ trusted: "Trusted by the host: runs without the sandbox",
64
+ plusFamily: "TurboWarp Plus family",
64
65
  trustedNote: "Catalog extensions are treated like TurboWarp\u2019s own gallery and are not asked about.",
65
66
  "state-loaded": "\u25B6\uFE0F Already running",
66
67
  "state-dependency": "\u{1F517} Needed by {names}",
@@ -118,7 +119,8 @@ var messages = {
118
119
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
119
120
  closeWarning: "\u9589\u3058\u308B",
120
121
  "requirement-required": "\u26A0\uFE0F \u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981",
121
- trusted: "TurboWarp Plus \u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
122
+ trusted: "\u30DB\u30B9\u30C8\u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
123
+ plusFamily: "TurboWarp Plus \u30D5\u30A1\u30DF\u30EA\u30FC",
122
124
  trustedNote: "\u30AB\u30BF\u30ED\u30B0\u306E\u62E1\u5F35\u306F TurboWarp \u306E\u6A19\u6E96\u30AE\u30E3\u30E9\u30EA\u30FC\u3068\u540C\u3058\u6271\u3044\u3067\u3001\u78BA\u8A8D\u3092\u6C42\u3081\u307E\u305B\u3093\u3002",
123
125
  "state-loaded": "\u25B6\uFE0F \u8AAD\u307F\u8FBC\u307F\u6E08\u307F",
124
126
  "state-dependency": "\u{1F517} {names} \u304C\u5FC5\u8981\u3068\u3057\u3066\u3044\u307E\u3059",
@@ -34,7 +34,8 @@ var messages = {
34
34
  unsandboxedWarning: "Without the sandbox, an extension can reach the project, the editor and this site\u2019s data. Choose it only for code you trust.",
35
35
  closeWarning: "Close",
36
36
  "requirement-required": "\u26A0\uFE0F Needs to run without the sandbox",
37
- trusted: "Trusted by TurboWarp Plus: runs without the sandbox",
37
+ trusted: "Trusted by the host: runs without the sandbox",
38
+ plusFamily: "TurboWarp Plus family",
38
39
  trustedNote: "Catalog extensions are treated like TurboWarp\u2019s own gallery and are not asked about.",
39
40
  "state-loaded": "\u25B6\uFE0F Already running",
40
41
  "state-dependency": "\u{1F517} Needed by {names}",
@@ -92,7 +93,8 @@ var messages = {
92
93
  unsandboxedWarning: "\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u306E\u62E1\u5F35\u306F\u3001\u4F5C\u54C1\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u30FB\u3053\u306E\u30B5\u30A4\u30C8\u306E\u30C7\u30FC\u30BF\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u3059\u3002\u4FE1\u983C\u3067\u304D\u308B\u30B3\u30FC\u30C9\u306B\u3060\u3051\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002",
93
94
  closeWarning: "\u9589\u3058\u308B",
94
95
  "requirement-required": "\u26A0\uFE0F \u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u304C\u5FC5\u8981",
95
- trusted: "TurboWarp Plus \u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
96
+ trusted: "\u30DB\u30B9\u30C8\u304C\u4FE1\u983C\u3059\u308B\u62E1\u5F35\uFF1A\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306A\u3057\u3067\u52D5\u304D\u307E\u3059",
97
+ plusFamily: "TurboWarp Plus \u30D5\u30A1\u30DF\u30EA\u30FC",
96
98
  trustedNote: "\u30AB\u30BF\u30ED\u30B0\u306E\u62E1\u5F35\u306F TurboWarp \u306E\u6A19\u6E96\u30AE\u30E3\u30E9\u30EA\u30FC\u3068\u540C\u3058\u6271\u3044\u3067\u3001\u78BA\u8A8D\u3092\u6C42\u3081\u307E\u305B\u3093\u3002",
97
99
  "state-loaded": "\u25B6\uFE0F \u8AAD\u307F\u8FBC\u307F\u6E08\u307F",
98
100
  "state-dependency": "\u{1F517} {names} \u304C\u5FC5\u8981\u3068\u3057\u3066\u3044\u307E\u3059",
package/dist/preview.d.ts CHANGED
@@ -3,6 +3,7 @@ interface PreviewProps {
3
3
  url: string;
4
4
  name: string;
5
5
  fallback: boolean;
6
+ fallbackURL?: string;
6
7
  cache?: PreviewCache | null;
7
8
  locale?: string;
8
9
  }
@@ -87,9 +87,14 @@ var contactURL = (value) => {
87
87
  };
88
88
 
89
89
  // src/catalog.ts
90
+ var ID = /^[A-Za-z0-9]+$/;
90
91
  function fail(message) {
91
92
  throw new Error(message);
92
93
  }
94
+ var object = (value, what) => {
95
+ if (value === null || typeof value !== "object" || Array.isArray(value)) fail(`${what} must be an object`);
96
+ return value;
97
+ };
93
98
  var string = (value, what, limit = 2048) => {
94
99
  if (typeof value !== "string" || value.length === 0 || value.length > limit) fail(`${what} must be text`);
95
100
  return value;
@@ -108,6 +113,110 @@ var reviewURL = (value, what = "URL", allowHTTP = false) => {
108
113
  }
109
114
  return text;
110
115
  };
116
+ var metadataOf = (value) => {
117
+ const source = object(value, "metadata");
118
+ const result = {};
119
+ for (const key of [
120
+ "name",
121
+ "id",
122
+ "description",
123
+ "author",
124
+ "version",
125
+ "license",
126
+ "package",
127
+ "banner",
128
+ "unsandboxed",
129
+ "updatedAt"
130
+ ]) {
131
+ if (source[key] !== void 0) result[key] = string(source[key], key, 4096);
132
+ }
133
+ for (const key of ["repository", "docsURL"]) {
134
+ if (source[key] !== void 0) result[key] = reviewURL(source[key], key);
135
+ }
136
+ if (source.authorURL !== void 0) result.authorURL = contactURL(source.authorURL);
137
+ if (source.descriptions !== void 0) {
138
+ const descriptions = object(source.descriptions, "descriptions");
139
+ result.descriptions = {};
140
+ for (const [tag, text] of Object.entries(descriptions)) {
141
+ if (!/^[a-z]{2}(-[A-Za-z0-9]+)*$/.test(tag)) fail("descriptions keys must be language tags");
142
+ result.descriptions[tag] = string(text, "description", 4096);
143
+ }
144
+ }
145
+ return result;
146
+ };
147
+ var categoriesOf = (value) => {
148
+ const list2 = value === void 0 ? [] : value;
149
+ if (!Array.isArray(list2)) fail("categories must be a list");
150
+ const byId = /* @__PURE__ */ new Map();
151
+ list2.forEach((item, order) => {
152
+ const category = object(item, "category");
153
+ const id = string(category.id, "category id", 128);
154
+ if (byId.has(id)) fail(`Duplicate category ${id}`);
155
+ const resolved = { id, title: string(category.title, "category title", 256), order };
156
+ if (category.titleJa !== void 0) resolved.titleJa = string(category.titleJa, "category titleJa", 256);
157
+ byId.set(id, Object.freeze(resolved));
158
+ });
159
+ return byId;
160
+ };
161
+ function parseExtensionCatalog(data2) {
162
+ const document = object(data2, "catalog");
163
+ if (document.schemaVersion !== void 0 && document.schemaVersion !== 1) {
164
+ fail(`Unsupported catalog schema ${document.schemaVersion}`);
165
+ }
166
+ const categories = categoriesOf(document.categories);
167
+ const list2 = document.extensions;
168
+ if (!Array.isArray(list2)) fail("catalog extensions must be a list");
169
+ const byId = /* @__PURE__ */ new Map();
170
+ const urls = /* @__PURE__ */ new Set();
171
+ const entries = list2.map((item) => {
172
+ const source = object(item, "extension");
173
+ const id = string(source.id, "extension id", 128);
174
+ if (!ID.test(id)) fail(`Invalid extension id ${id}`);
175
+ if (byId.has(id)) fail(`Duplicate extension ${id}`);
176
+ const url = reviewURL(source.url, `${id} url`);
177
+ if (urls.has(url)) fail(`Duplicate extension URL ${url}`);
178
+ urls.add(url);
179
+ const dependencies = source.dependencies === void 0 ? [] : source.dependencies;
180
+ if (!Array.isArray(dependencies)) fail(`${id} dependencies must be a list`);
181
+ const entry = {
182
+ key: id,
183
+ id,
184
+ ids: [id],
185
+ url,
186
+ dependencies: Object.freeze(dependencies.map((value) => string(value, "dependency", 128))),
187
+ // The dashboard catalog states name, description, creator and banner beside the URL.
188
+ // A nested `metadata` object, the older shape, still wins where it says something.
189
+ metadata: Object.freeze(metadataOf(__spreadValues(__spreadValues({}, source), source.metadata === void 0 ? {} : object(source.metadata, "metadata"))))
190
+ };
191
+ if (source.sha256 !== void 0) {
192
+ entry.sha256 = string(source.sha256, "sha256", 64);
193
+ if (!/^[0-9a-f]{64}$/.test(entry.sha256)) fail(`Invalid sha256 for ${id}`);
194
+ }
195
+ if (source.category !== void 0) {
196
+ const category = string(source.category, "category", 128);
197
+ if (!categories.has(category)) fail(`Unknown category ${category}`);
198
+ entry.category = categories.get(category);
199
+ }
200
+ byId.set(id, entry);
201
+ return entry;
202
+ });
203
+ for (const entry of entries) {
204
+ for (const dependency of entry.dependencies) {
205
+ if (!byId.has(dependency)) fail(`${entry.id} depends on missing ${dependency}`);
206
+ }
207
+ }
208
+ const state = /* @__PURE__ */ new Map();
209
+ const walk = (id) => {
210
+ const mark = state.get(id);
211
+ if (mark === "done") return;
212
+ if (mark === "open") fail(`Dependency cycle at ${id}`);
213
+ state.set(id, "open");
214
+ for (const dependency of byId.get(id).dependencies) walk(dependency);
215
+ state.set(id, "done");
216
+ };
217
+ for (const entry of entries) walk(entry.id);
218
+ return entries.map((entry) => Object.freeze(entry));
219
+ }
111
220
 
112
221
  // src/metadata.ts
113
222
  var BLOCK = /\/\*\*([\s\S]*?)\*\//;
@@ -231,6 +340,24 @@ async function loadExtensionInfo(url, signal) {
231
340
  return { source, metadata };
232
341
  }
233
342
 
343
+ // src/catalog-preview.ts
344
+ function createCatalogPreviewResolver(catalog) {
345
+ let pending;
346
+ return async (entry, signal) => {
347
+ var _a;
348
+ if (!catalog || !((_a = entry.state) == null ? void 0 : _a.plusFamily) || signal.aborted) return;
349
+ pending != null ? pending : pending = catalog.read(signal).then((read) => ({
350
+ entries: read.catalog ? parseExtensionCatalog(read.catalog) : [],
351
+ icons: read.icons || {}
352
+ })).catch(() => ({ entries: [], icons: {} }));
353
+ const { entries, icons } = await pending;
354
+ if (signal.aborted) return;
355
+ const source = entry.source;
356
+ const item = entries.find((item2) => entry.ids.includes(item2.id) && ("url" in source && !source.url.startsWith("data:") ? item2.url === source.url && (!("sha256" in source) || source.sha256 === item2.sha256) : "sha256" in source && source.sha256 === item2.sha256));
357
+ return item && (icons[item.id] || item.metadata.banner);
358
+ };
359
+ }
360
+
234
361
  // src/storage.ts
235
362
  var NAME = "twextsec";
236
363
  var VERSION = 1;
@@ -6456,6 +6583,7 @@ function embeddedExtensionName(bytes, id) {
6456
6583
 
6457
6584
  // src/project-review.tsx
6458
6585
  function createProjectSecurityReview({
6586
+ catalog,
6459
6587
  trusted: defaultTrusted,
6460
6588
  pendingReview: pendingPlusReview,
6461
6589
  reviewedArchive: reviewedProjectArchive,
@@ -6508,7 +6636,7 @@ function createProjectSecurityReview({
6508
6636
  source,
6509
6637
  requestedExecution: spec.execution,
6510
6638
  dependencies: [...spec.dependencies]
6511
- }, vouched ? { state: { trusted: true } } : {});
6639
+ }, vouched ? { state: { trusted: true, plusFamily: true } } : {});
6512
6640
  }));
6513
6641
  const frames = /* @__PURE__ */ new WeakMap();
6514
6642
  const frameFor = (Modal) => {
@@ -6546,9 +6674,10 @@ function createProjectSecurityReview({
6546
6674
  return install(vm, async (entries, initial) => {
6547
6675
  const rows = await Promise.all(entries.map(async (entry) => {
6548
6676
  const url = "url" in entry.source ? entry.source.url : void 0;
6549
- const vouched = entry.source.kind === "legacy" && (isTrusted2(url) || await trusted.isTrustedURL(url));
6677
+ const plusFamily = entry.source.kind === "legacy" && await trusted.isTrustedURL(url);
6678
+ const vouched = entry.source.kind === "legacy" && (isTrusted2(url) || plusFamily);
6550
6679
  const banner = bannerFor({ ids: entry.ids, url });
6551
- return __spreadValues(__spreadValues(__spreadValues({}, entry), banner ? { metadata: __spreadProps(__spreadValues({}, entry.metadata), { banner }) } : {}), vouched ? { state: __spreadProps(__spreadValues({}, entry.state), { trusted: true }) } : {});
6680
+ return __spreadValues(__spreadValues(__spreadValues({}, entry), banner ? { metadata: __spreadProps(__spreadValues({}, entry.metadata), { banner }) } : {}), vouched ? { state: __spreadProps(__spreadValues({}, entry.state), { trusted: true, plusFamily }) } : {});
6552
6681
  }));
6553
6682
  const starting = initialDecisions(rows, "open", { recorded: initial });
6554
6683
  if (!requiresReview(rows)) return starting;
@@ -6587,6 +6716,7 @@ function createProjectSecurityReview({
6587
6716
  // A custom extension's name, description, creator and licence are its own leading comment,
6588
6717
  // read without running it, so the row says what it is and labels each part a claim.
6589
6718
  loadInfo: loadExtensionInfo,
6719
+ loadPreview: createCatalogPreviewResolver(catalog),
6590
6720
  onComplete
6591
6721
  }),
6592
6722
  /**
@@ -1,8 +1,10 @@
1
1
  import { installBatchExtensionLoader } from '@kubohiroya/turbowarp-extension-security-dialog/turbowarp';
2
2
  import React from 'react';
3
+ import type { PreviewCatalog } from './catalog-preview.js';
3
4
  import type { createProjectReviewChannel, ReadEmbeddedReviewFile } from './project-review-channel.js';
4
5
  export { embeddedExtensionName } from './embedded-extension-name.js';
5
6
  export interface ProjectReviewPorts {
7
+ catalog?: PreviewCatalog;
6
8
  trusted: {
7
9
  ready?(): Promise<void>;
8
10
  listedDigests?: ReadonlySet<unknown>;
@@ -16,7 +18,7 @@ export interface ProjectReviewPorts {
16
18
  duringApproval<T>(vm: object, run: () => Promise<T>): Promise<T>;
17
19
  styles: Record<string, string>;
18
20
  }
19
- export declare function createProjectSecurityReview({ trusted: defaultTrusted, pendingReview: pendingPlusReview, reviewedArchive: reviewedProjectArchive, duringApproval: duringProjectLoadApproval, styles }: ProjectReviewPorts): {
21
+ export declare function createProjectSecurityReview({ catalog, trusted: defaultTrusted, pendingReview: pendingPlusReview, reviewedArchive: reviewedProjectArchive, duringApproval: duringProjectLoadApproval, styles }: ProjectReviewPorts): {
20
22
  identifyProject: (input: any) => Promise<string | null>;
21
23
  plusReviewRows: (manifest: any, trusted: any, readEmbeddedFile?: ReadEmbeddedReviewFile) => Promise<any[]>;
22
24
  frameFor: (Modal: any) => any;