@kubohiroya/turbowarp-extension-security-dialog 0.8.5 → 0.8.6

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
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## This package
4
4
 
5
- Everything in `src/` and `assets/` was written for this package and is covered by
5
+ The code in `src/` and the original icons in `assets/` are covered by
6
6
  [LICENSE](./LICENSE) (MPL-2.0). No file here carries the "Incompatible With Secondary Licenses"
7
7
  notice, so this code can be combined into a larger work distributed under GPL-3.0 — which is how
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
11
  original to this package: a jigsaw piece outline with a serif T, drawn for it and derived from no
12
- other work. `scripts/build.mjs` embeds it into `dist` as a base64 data URI, so it travels in the
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
15
  `assets/trusted.svg` is the mark beside an extension the host trusts: the TurboWarp Plus mark (the
@@ -42,3 +42,9 @@ The source distributions are Camera Source 0.19.4, Asset Cache 0.3.2 and Bubble
42
42
  unmodified browser captures; source integrity, Editor revisions, image hashes and checks are recorded in
43
43
  `assets/screenshots/all-required-open-20261103.json`. The captured interface and extension graphics retain
44
44
  their respective rights holders and applicable licenses.
45
+
46
+ `assets/screenshots/public-review-{add,open}-{en,ja}-20261106.png` show the public Editor on
47
+ 6 November 2026 with security dialog 0.8.5. The add screenshots use the live TurboWarp Plus
48
+ catalog. The open screenshots use the published bundles listed above, embedded in an SB3.
49
+ See `assets/screenshots/public-review-20261106.json` for deployment revisions, source integrity,
50
+ image hashes and interaction checks.
package/README.ja.md CHANGED
@@ -18,18 +18,28 @@ VM は機能拡張を1つずつ読み込み、そのたびに尋ねます。作
18
18
 
19
19
  このパッケージは作品全体をまとめて集め、1つの問いにして、そのあとで読み込みます。
20
20
 
21
- ## 公開Editorのスクリーンショット
21
+ ## 公開 Editor の拡張確認画面
22
22
 
23
- 2026年11月3日の[公開Editor](https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=ja)で、
24
- 配布済みのCamera Source 0.19.4・Asset Cache 0.3.2・Bubble 0.13.5を開いた実画面です。
25
- 3件すべてが「サンドボックスなし」を必須と申告しているため、その選択肢だけを選択済みで表示します。
26
- 「動かさない」「サンドボックスの中で」と実行方法の一括指定は表示せず、OKで実行するかキャンセルで中止します。
27
- OK前にはどの拡張も実行していません。
23
+ 2026年11月6日に、共通ダイアログ 0.8.5 が配信されている
24
+ [公開 TurboWarp Plus Editor](https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=ja) で撮影しました。
28
25
 
29
- ![全拡張が必須と申告しているため、サンドボックスなしだけが選択済みの日本語確認画面。他の2実行選択肢と一括指定はなく、OKかキャンセルで続ける](https://raw.githubusercontent.com/kubohiroya/turbowarp-extension-security-dialog/main/assets/screenshots/all-required-open-ja-20261103.png)
26
+ **機能拡張を追加する。** TurboWarp Plus カタログで TurboWarp-Title-Menu を選ぶと、
27
+ サンドボックスなしで実行する場合の注意が出ます。拡張の行には読み込み元のアイコンと、
28
+ 拡張の紹介・リリース・製作者の連絡先へのリンクがあります。一覧をスクロールしても
29
+ 「キャンセル」「追加」は下部に表示され、注意を閉じても選択は残ります。
30
30
 
31
- 同じダイアログの[英語版](./README.md)も撮影しました。画像はダイアログ部分を無加工で撮影したもので、
32
- 配布物と画像のhash・Editorの固定revision・日英の確認結果を[撮影台帳](./assets/screenshots/all-required-open-20261103.json)に記録しています。
31
+ ![TurboWarp-Title-Menu を選択した公開カタログ。閉じられる注意と固定のキャンセル・追加ボタンを表示](./assets/screenshots/public-review-add-ja-20261106.png)
32
+
33
+ **作品を開く。** この SB3 には Camera Source 0.19.4、Asset Cache 0.3.2、Bubble 0.13.5 を
34
+ `data:` URL として保存しています。3件ともサンドボックスなしを必須と申告しているため、
35
+ 実行方法はその選択肢だけが選択済みになり、OK またはキャンセルを待ちます。
36
+ 図版の時点では、どの拡張もまだ実行していません。
37
+
38
+ ![公開 Editor の作品を開く確認画面。3件の必須拡張でサンドボックスなしを選択済み](./assets/screenshots/public-review-open-ja-20261106.png)
39
+
40
+ 配信リビジョン、配布物の整合性、画像のハッシュ、日英の操作確認は
41
+ [撮影記録](./assets/screenshots/public-review-20261106.json)に記載しています。
42
+ [英語版 README](./README.md) にも同じ画面を掲載しています。
33
43
 
34
44
  ## 入口
35
45
 
@@ -42,7 +52,7 @@ OK前にはどの拡張も実行していません。
42
52
 
43
53
  ## 画面
44
54
 
45
- ```jsx
55
+ ```tsx
46
56
  import {ExtensionReview} from '@kubohiroya/turbowarp-extension-security-dialog/react';
47
57
  import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
48
58
 
@@ -86,7 +96,7 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
86
96
  `loadingChoices` は行の source から選択肢を読み取り、横に対応表を置く必要がありません。source が
87
97
  持ち方を名指している行はもうそのように読み込まれているので、画面は尋ねるのではなく述べます。
88
98
 
89
- ### しないこと
99
+ ### 実行方法・信頼済みの拡張・記憶した選択
90
100
 
91
101
  **作品を開くとき、全件がサンドボックスなしを必須と申告していれば、そのモードを選択済みにします。**
92
102
  取得失敗がなく、空でない一覧のすべての申告が揃った場合だけ適用します。「動かさない」と
@@ -115,16 +125,16 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
115
125
  自動では消えず、「閉じる」で非表示にしても選択や許可は変わりません。警告が必要な選択を
116
126
  すべて解除するまでは閉じた状態を保ち、再び選択したときは表示し直します。
117
127
 
118
- **信頼済みの行は、尋ねずに述べます。** カタログに載っている拡張はホストの標準ギャラリーと同じ
119
- 扱いで、サンドボックスなしで動き、実行の選択肢を出しません。信頼済みの行だけの作品は止める
120
- 価値が無いので、`requiresReview` が画面を出さなくてよいと答えます。
128
+ **信頼済みかどうかはホストが決めます。** `entry.state.trusted` を指定した行には信頼済みの印を付け、
129
+ サンドボックスなしを適用します。すべての行が信頼済みの作品では、ホストは `requiresReview` で確認を
130
+ 省略できます。
121
131
 
122
132
  **記録された答えは、いまも選択肢である場合だけ尊重します。** 作品が `remote-cacheable` から
123
133
  埋め込みに変わった、行が信頼済みになった、といった場合に、もう提示しない答えを持ち込みません。
124
134
 
125
135
  ### 読み込みに失敗したとき
126
136
 
127
- ```jsx
137
+ ```tsx
128
138
  <ExtensionReview
129
139
  /* ...上と同じ */
130
140
  failure={{code: error.code, message: error.message, retryable: isWorthAskingAgain(error)}}
@@ -147,7 +157,7 @@ import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
147
157
 
148
158
  公開パッケージには `dist/build-info.json` を含め、
149
159
  `@kubohiroya/turbowarp-extension-security-dialog/build-info` からも参照できます。`name`、`version`、
150
- ソースの完全な `revision`、`sourceState`(`commit` または `working-tree`)を記録します。ホスト側は
160
+ ソースの完全な `revision`、`sourceState`(`commit`、`working-tree`、`git-archive`)を記録します。ホスト側は
151
161
  完全版を固定し、配信前に revision を照合できます。切り戻しはパッケージ版と lockfile を元に戻す
152
162
  ことで行えます。新しい失敗表示だけを止める場合は、`failure` と `onRetry` を渡さないでください。
153
163
 
@@ -227,8 +237,9 @@ const uninstall = installBatchExtensionLoader(vm, review, defaultURLs, createDec
227
237
 
228
238
  ```sh
229
239
  pnpm install
240
+ pnpm run typecheck
230
241
  pnpm run check # ビルド、単体テスト、pack の dry run
231
- node --test test/wait.browser.mjs test/review.browser.mjs # 取得待ち・選択画面の実ブラウザ検証
242
+ node --test test/wait.browser.ts test/review.browser.ts # 取得待ち・選択画面の実ブラウザ検証
232
243
  ```
233
244
 
234
245
  React と React DOM は peerDependencies なので、ホストが用意します。実行時の依存はありません。
package/README.md CHANGED
@@ -15,19 +15,29 @@ an extension asks twice: once to pick it, once to allow it.
15
15
 
16
16
  This package collects the whole project, puts one question, and only then loads anything.
17
17
 
18
- ## Public Editor screenshots
18
+ ## Extension review in the public Editor
19
19
 
20
- This is the [public Editor](https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=en) on
21
- 3 November 2026, opening the published Camera Source 0.19.4, Asset Cache 0.3.2 and Bubble 0.13.5 bundles.
22
- All three declare unsandboxed execution required, so that is the only execution choice shown and is already selected.
23
- The other two execution choices and execution bulk control are absent. OK runs the extensions; Cancel stops loading.
24
- No extension has run before OK.
20
+ These screenshots were taken on 6 November 2026 in the
21
+ [public TurboWarp Plus Editor](https://kubohiroya.github.io/turbowarp-plus-editor/editor.html?lang=en)
22
+ with security dialog 0.8.5.
25
23
 
26
- ![English review with only Without the sandbox selected for all three required extensions. The other two execution choices and execution bulk control are absent; choose OK or Cancel.](https://raw.githubusercontent.com/kubohiroya/turbowarp-extension-security-dialog/main/assets/screenshots/all-required-open-en-20261103.png)
24
+ **Add extensions.** In the TurboWarp Plus catalog, selecting TurboWarp-Title-Menu shows a
25
+ dismissible warning about running without the sandbox. The row shows loading options with
26
+ icons and links to the extension page, release notes and creator contact. Cancel and Add
27
+ stay visible as the list scrolls. Closing the warning keeps the selection.
27
28
 
28
- The same dialog was captured in [Japanese](./README.ja.md). These are unmodified dialog-only browser captures.
29
- Distribution and image hashes, pinned Editor revisions and the checks for both languages are recorded in
30
- [the capture manifest](./assets/screenshots/all-required-open-20261103.json).
29
+ ![Public catalog with TurboWarp-Title-Menu selected, a dismissible warning and fixed Cancel and Add buttons](./assets/screenshots/public-review-add-en-20261106.png)
30
+
31
+ **Open a project.** This SB3 stores Camera Source 0.19.4, Asset Cache 0.3.2 and Bubble 0.13.5
32
+ as `data:` URLs. All three declare that they require unsandboxed execution, so the dialog
33
+ preselects the only execution option and waits for OK or Cancel. No extension has run at
34
+ the point shown.
35
+
36
+ ![Public Editor review with unsandboxed execution preselected for the three required extensions](./assets/screenshots/public-review-open-en-20261106.png)
37
+
38
+ See the [capture record](./assets/screenshots/public-review-20261106.json) for the deployed
39
+ revisions, bundle integrity, image hashes and interaction checks, and the
40
+ [Japanese README](./README.ja.md) for the same screens in Japanese.
31
41
 
32
42
  ## Entry points
33
43
 
@@ -40,7 +50,7 @@ Distribution and image hashes, pinned Editor revisions and the checks for both l
40
50
 
41
51
  ## The screen
42
52
 
43
- ```jsx
53
+ ```tsx
44
54
  import {ExtensionReview} from '@kubohiroya/turbowarp-extension-security-dialog/react';
45
55
  import '@kubohiroya/turbowarp-extension-security-dialog/styles.css';
46
56
 
@@ -86,7 +96,7 @@ write permission back over it. So `loadingChoices` reads the choices off the row
86
96
  needs no table beside it — a row whose source names a form is already loading that way, and the
87
97
  screen states it instead of asking.
88
98
 
89
- ### What it will not do
99
+ ### Execution, trust and remembered choices
90
100
 
91
101
  **When opening a project whose extensions all declare unsandboxed execution required, that mode is preselected.**
92
102
  This applies only to a non-empty list with every declaration available and no failed row. The other two
@@ -96,17 +106,26 @@ Nothing runs before OK. Loading-source and cache-decline choices remain independ
96
106
  Adding from the catalog, or opening a mixed, optional, undeclared or failed batch, keeps the sandbox
97
107
  as the default and leaves the execution choices available. A choice contradicting a declaration is warned about.
98
108
 
99
- **A trusted row is stated, not asked about.** An extension the catalog lists is treated like the
100
- host's own gallery: it runs without the sandbox and offers no execution choice. A project with
101
- nothing but trusted rows is not worth stopping, so `requiresReview` says to skip the screen.
109
+ **The host identifies trusted rows** through `entry.state.trusted`. The dialog marks those rows
110
+ as trusted and sets them to run without the sandbox. The host can skip review for a project
111
+ whose rows are all trusted using `requiresReview`.
102
112
 
103
113
  **A remembered answer is honoured only where it is still one of the choices.** A project that
104
114
  moved from `remote-cacheable` to embedded bytes, or a row that has since become trusted, does not
105
115
  carry a stale answer into a screen that no longer offers it.
106
116
 
117
+ In add mode, the checkbox, preview icon and extension name appear together. The catalog area
118
+ scrolls independently of Cancel and Add. Dismissing the unsandboxed notice preserves the selection
119
+ and returns focus to the control that opened it.
120
+
121
+ For trusted entries, the trust badge links to the extension page when provided. Supported
122
+ GitHub versions link to their release notes. The description preserves line breaks and turns
123
+ HTTP(S) URLs and email addresses into links. The creator's contact appears next to their name
124
+ when supplied.
125
+
107
126
  ### When loading fails
108
127
 
109
- ```jsx
128
+ ```tsx
110
129
  <ExtensionReview
111
130
  /* ...as above */
112
131
  failure={{code: error.code, message: error.message, retryable: isWorthAskingAgain(error)}}
@@ -129,7 +148,7 @@ retry controls. `code` is optional display text, and `retryable` defaults to no
129
148
 
130
149
  Published packages include `dist/build-info.json`, also exported as
131
150
  `@kubohiroya/turbowarp-extension-security-dialog/build-info`. It records `name`, `version`, the full
132
- source `revision` and `sourceState` (`commit` or `working-tree`). Hosts can pin the exact version
151
+ source `revision` and `sourceState` (`commit`, `working-tree` or `git-archive`). Hosts can pin the exact version
133
152
  and verify its revision before deployment. To roll back, restore the previous package version and
134
153
  lockfile; to hide the new failure UI, stop passing `failure` and `onRetry`.
135
154
 
@@ -215,8 +234,9 @@ what a bundle says about its members is theirs, not its own.
215
234
 
216
235
  ```sh
217
236
  pnpm install
237
+ pnpm run typecheck
218
238
  pnpm run check # build, unit tests, and a packing dry run
219
- node --test test/wait.browser.mjs test/review.browser.mjs
239
+ node --test test/wait.browser.ts test/review.browser.ts
220
240
  ```
221
241
 
222
242
  React and React DOM are peer dependencies, so the host supplies them. There are no runtime
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-extension-security-dialog",
3
- "version": "0.8.5",
4
- "revision": "cba70ed1df196300cfb155da4397a50a920dd786",
3
+ "version": "0.8.6",
4
+ "revision": "3cdc9723c104c5818d952e778e25dc2429986767",
5
5
  "sourceState": "commit"
6
6
  }
@@ -0,0 +1,46 @@
1
+ import type { ExtensionMetadata } from './review-types.js';
2
+ export interface CatalogCategory {
3
+ id: string;
4
+ title: string;
5
+ titleJa?: string;
6
+ order: number;
7
+ }
8
+ export interface CatalogEntry {
9
+ key: string;
10
+ id: string;
11
+ ids: string[];
12
+ url: string;
13
+ sha256?: string;
14
+ dependencies: readonly string[];
15
+ metadata: ExtensionMetadata;
16
+ category?: CatalogCategory;
17
+ }
18
+ /**
19
+ * Only an absolute HTTPS address with nothing hidden in it.
20
+ *
21
+ * Credentials belong to whoever wrote the catalog, not to the person opening it, and a fragment
22
+ * cannot change which bytes arrive but can make two rows look like one. Both are refused rather
23
+ * than stripped, so a catalog that carries them is reported instead of quietly rewritten.
24
+ * @param {unknown} value The address to check.
25
+ * @param {string} what What to call it if it is wrong.
26
+ * @param {boolean} allowHTTP True only for a creator's own page, which runs no code here.
27
+ * @returns {string} The address, unchanged.
28
+ */
29
+ export declare const reviewURL: (value: unknown, what?: string, allowHTTP?: boolean) => string;
30
+ /**
31
+ * Read a dashboard catalog into rows, refusing anything the review screen could not show safely.
32
+ *
33
+ * Every refusal here is a catalog that would mislead: two rows claiming one ID, a dependency on
34
+ * something absent, a cycle no order can satisfy, an address that is not plainly HTTPS. The
35
+ * screen never has to ask whether what it was handed makes sense.
36
+ * @param {unknown} data The parsed catalog document.
37
+ * @returns {Array<object>} Frozen entries in catalog order, each with its resolved category.
38
+ */
39
+ export declare function parseExtensionCatalog(data: unknown): CatalogEntry[];
40
+ /**
41
+ * Fetch and read a catalog without sending anything about the person along.
42
+ * @param {string} url The catalog address.
43
+ * @param {AbortSignal} [signal] The caller's own deadline or cancellation.
44
+ * @returns {Promise<Array<object>>} The parsed entries.
45
+ */
46
+ export declare function loadExtensionCatalog(url: string, signal?: AbortSignal): Promise<CatalogEntry[]>;
@@ -0,0 +1,83 @@
1
+ import type { ExecutionDecision, LoadingMode, ReviewDecision, ReviewEntry } from './review-types.js';
2
+ export type ReviewMode = 'add' | 'open';
3
+ /** A row listed in the catalog is trusted like the host's own gallery and is never asked about. */
4
+ export declare const isTrusted: (entry: ReviewEntry) => boolean;
5
+ /** A complete, non-empty opening batch may preset the only required execution mode. */
6
+ export declare const allRequireUnsandboxed: (entries: ReviewEntry[]) => boolean;
7
+ /** The four forms, in the order someone adding an extension is offered them. */
8
+ export declare const loadingModes: readonly LoadingMode[];
9
+ /**
10
+ * Where a row may load from, which its own source already says.
11
+ *
12
+ * All four forms are the author's decision, so there is only one place a choice is left to make.
13
+ * A `catalog` row is in no project yet: whoever is looking at it is about to be its author and
14
+ * picks any of the four. A row a project already names has its form fixed, and the one thing the
15
+ * person opening it still decides is whether a `remote-cacheable` row may keep its copy in this
16
+ * browser — which is the same as choosing `remote-non-cacheable` for that row. Nothing else has a
17
+ * second form it could take: `remote-non-cacheable` is the author forbidding the copy and there
18
+ * is no way to write permission back over it, embedded bytes travel with the project and have
19
+ * nowhere else to come from, and a `legacy` URL predates the whole idea.
20
+ * @param {object} entry The row.
21
+ * @returns {Array<string>} The loading choices to offer, empty when there is nothing to choose.
22
+ */
23
+ export declare const loadingChoices: (entry: ReviewEntry) => LoadingMode[];
24
+ /**
25
+ * What a row may be allowed to do.
26
+ *
27
+ * A trusted row has no choice to make. Adding has no `deny` because not adding is what refusing
28
+ * looks like there; opening does, because the project already names the extension and the person
29
+ * still has to be able to say no to it.
30
+ * @param {object} entry The row.
31
+ * @param {string} mode Either add or open.
32
+ * @returns {Array<string>} The execution choices to offer, empty when there is nothing to choose.
33
+ */
34
+ export declare const executionChoices: (entry: ReviewEntry, mode: ReviewMode) => ExecutionDecision[];
35
+ /**
36
+ * Where a row starts before anyone touches it.
37
+ *
38
+ * A trusted row runs without the sandbox, as the gallery's own do. Everything else starts in the
39
+ * sandbox, including an extension that says it needs to be outside: that claim is the extension's
40
+ * own and must not pre-approve itself. What the project recorded is honoured only as far as the
41
+ * sandbox, for the same reason.
42
+ * @param {object} entry The row.
43
+ * @param {string} mode Either add or open.
44
+ * @param {string} fallbackLoading Which form is preferred where there is still a choice.
45
+ * @returns {object} The decision to start from.
46
+ */
47
+ export declare function defaultDecision(entry: ReviewEntry, _mode: ReviewMode, fallbackLoading?: LoadingMode): ReviewDecision;
48
+ /**
49
+ * The decisions a screen opens with: what was recorded last time, else the defaults.
50
+ *
51
+ * A recorded choice is only honoured where it is still one of the choices. A project that moved
52
+ * from a reference to embedded bytes, or a row that has since become trusted, must not carry a
53
+ * stale answer into a screen that no longer offers it. A complete opening batch that requires
54
+ * unsandboxed execution presets that mode even over an incompatible recorded execution choice;
55
+ * running the batch still requires the screen's OK.
56
+ * @param {Array<object>} entries The rows.
57
+ * @param {string} mode Either add or open.
58
+ * @param {object} options Previously recorded decisions and the fallback loading mode.
59
+ * @returns {Map<string, object>} The starting decisions, by row key.
60
+ */
61
+ export declare function initialDecisions(entries: ReviewEntry[], mode: ReviewMode, { recorded, fallbackLoading }?: {
62
+ recorded?: ReadonlyMap<string, ReviewDecision>;
63
+ fallbackLoading?: LoadingMode;
64
+ }): Map<string, ReviewDecision>;
65
+ /**
66
+ * Whether opening this project has anything to ask about.
67
+ *
68
+ * With nothing but trusted rows there is no question to put, and a dialog that only reports would
69
+ * be a toll gate on opening a project. The host skips the screen and uses the defaults.
70
+ * @param {Array<object>} entries The rows.
71
+ * @returns {boolean} True when at least one row needs a person.
72
+ */
73
+ export declare const requiresReview: (entries: ReviewEntry[]) => boolean;
74
+ /**
75
+ * Whether the sandbox is likely to break this row, by its own account.
76
+ *
77
+ * This is a warning, never a permission: the extension said it needs to be outside the sandbox,
78
+ * and choosing the sandbox anyway usually ends with the extension refusing to start.
79
+ * @param {object} entry The row.
80
+ * @param {object} decision The decision being made about it.
81
+ * @returns {boolean} True when the choice contradicts what the extension declared.
82
+ */
83
+ export declare const contradictsDeclaration: (entry: ReviewEntry, decision: ReviewDecision) => boolean;
@@ -0,0 +1,7 @@
1
+ import type { ExtensionMetadata } from './review-types.js';
2
+ /** Display-only links never supply code to the extension loader. */
3
+ export declare const displayURL: (value: unknown, allowMail?: boolean) => string | null;
4
+ /** Keep the contact field's existing URL contract, also accepting email links. */
5
+ export declare const contactURL: (value: unknown) => string;
6
+ /** This catalog's GitHub releases use v-prefixed package versions, including prereleases. */
7
+ export declare const releaseURL: (metadata: ExtensionMetadata) => string | null;
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -30,7 +31,7 @@ var __copyProps = (to, from, except, desc) => {
30
31
  };
31
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
33
 
33
- // src/index.js
34
+ // src/index.ts
34
35
  var index_exports = {};
35
36
  __export(index_exports, {
36
37
  allRequireUnsandboxed: () => allRequireUnsandboxed,
@@ -59,7 +60,7 @@ __export(index_exports, {
59
60
  });
60
61
  module.exports = __toCommonJS(index_exports);
61
62
 
62
- // src/display-urls.js
63
+ // src/display-urls.ts
63
64
  var displayURL = (value, allowMail = false) => {
64
65
  if (typeof value !== "string" || !value || /[\u0000-\u0020\u007f]/.test(value)) return null;
65
66
  try {
@@ -79,11 +80,11 @@ var contactURL = (value) => {
79
80
  return address;
80
81
  };
81
82
 
82
- // src/catalog.js
83
+ // src/catalog.ts
83
84
  var ID = /^[A-Za-z0-9]+$/;
84
- var fail = (message) => {
85
+ function fail(message) {
85
86
  throw new Error(message);
86
- };
87
+ }
87
88
  var object = (value, what) => {
88
89
  if (value === null || typeof value !== "object" || Array.isArray(value)) fail(`${what} must be an object`);
89
90
  return value;
@@ -217,7 +218,7 @@ async function loadExtensionCatalog(url, signal) {
217
218
  return parseExtensionCatalog(await response.json());
218
219
  }
219
220
 
220
- // src/metadata.js
221
+ // src/metadata.ts
221
222
  var BLOCK = /\/\*\*([\s\S]*?)\*\//;
222
223
  var FIELD = /^[ \t]*\*?[ \t]*@([A-Za-z][A-Za-z0-9]*)[ \t]+(.*)$/;
223
224
  var LIMIT = 4096;
@@ -245,7 +246,7 @@ function parseExtensionMetadata(source) {
245
246
  else metadata.description = value;
246
247
  return;
247
248
  }
248
- if (["repository", "docsURL", "authorURL"].includes(name)) {
249
+ if (name === "repository" || name === "docsURL" || name === "authorURL") {
249
250
  try {
250
251
  metadata[name] = name === "authorURL" ? contactURL(value) : reviewURL(value, name);
251
252
  } catch (error) {
@@ -338,7 +339,7 @@ async function loadExtensionInfo(url, signal) {
338
339
  return { source, metadata: parseExtensionMetadata(source) };
339
340
  }
340
341
 
341
- // src/selection.js
342
+ // src/selection.ts
342
343
  function resolveExtensionSelection(entries, chosen = [], loaded = []) {
343
344
  const byId = new Map(entries.map((entry) => [entry.id, entry]));
344
345
  const explicit = new Set([...chosen].filter((id) => byId.has(id)));
@@ -393,7 +394,7 @@ function resolveExtensionSelection(entries, chosen = [], loaded = []) {
393
394
  };
394
395
  }
395
396
 
396
- // src/storage.js
397
+ // src/storage.ts
397
398
  var NAME = "twextsec";
398
399
  var VERSION = 1;
399
400
  var DECISIONS = "decisions";
@@ -438,7 +439,10 @@ function createDecisionStorage({ fallbackLoading = "remote-cacheable" } = {}) {
438
439
  try {
439
440
  const stored = await run(DECISIONS, "readonly", (store) => store.get(String(project)));
440
441
  if (!stored || typeof stored !== "object") return /* @__PURE__ */ new Map();
441
- return new Map(Object.entries(stored).filter(([, value]) => value && typeof value === "object" && typeof value.execution === "string"));
442
+ return new Map(Object.entries(stored).filter((entry) => {
443
+ const value = entry[1];
444
+ return Boolean(value && typeof value === "object" && "execution" in value && typeof value.execution === "string");
445
+ }));
442
446
  } catch (error) {
443
447
  return /* @__PURE__ */ new Map();
444
448
  }
@@ -508,7 +512,7 @@ function createPreviewCache() {
508
512
  });
509
513
  }
510
514
 
511
- // src/decisions.js
515
+ // src/decisions.ts
512
516
  var isTrusted = (entry) => Boolean(entry && entry.state && entry.state.trusted);
513
517
  var allRequireUnsandboxed = (entries) => entries.length > 0 && entries.every(
514
518
  (entry) => !(entry.state && entry.state.error) && unsandboxedRequirement(entry.metadata || {}) === "required"
@@ -521,11 +525,11 @@ var loadingModes = Object.freeze([
521
525
  ]);
522
526
  var loadingChoices = (entry) => entry.source.kind === "catalog" ? [...loadingModes] : entry.source.kind === "remote-cacheable" ? ["remote-cacheable", "remote-non-cacheable"] : [];
523
527
  var executionChoices = (entry, mode) => isTrusted(entry) ? [] : mode === "add" ? ["sandboxed", "unsandboxed"] : ["deny", "sandboxed", "unsandboxed"];
524
- function defaultDecision(entry, mode, fallbackLoading = "remote-cacheable") {
528
+ function defaultDecision(entry, _mode, fallbackLoading = "remote-cacheable") {
525
529
  const execution = isTrusted(entry) ? "unsandboxed" : "sandboxed";
526
530
  const choices = loadingChoices(entry);
527
531
  if (choices.length === 0) {
528
- return entry.source.kind === "legacy" ? { execution } : { execution, loading: entry.source.kind };
532
+ return entry.source.kind === "legacy" || entry.source.kind === "catalog" ? { execution } : { execution, loading: entry.source.kind };
529
533
  }
530
534
  return { execution, loading: choices.includes(fallbackLoading) ? fallbackLoading : choices[0] };
531
535
  }
@@ -540,14 +544,14 @@ function initialDecisions(entries, mode, {
540
544
  const previous = recorded.get(entry.key);
541
545
  if (!previous) return [entry.key, base];
542
546
  const execution = !allRequired && executionChoices(entry, mode).includes(previous.execution) ? previous.execution : base.execution;
543
- const loading = loadingChoices(entry).includes(previous.loading) ? previous.loading : base.loading;
547
+ const loading = previous.loading !== void 0 && loadingChoices(entry).includes(previous.loading) ? previous.loading : base.loading;
544
548
  return [entry.key, loading === void 0 ? { execution } : { execution, loading }];
545
549
  }));
546
550
  }
547
551
  var requiresReview = (entries) => entries.some((entry) => !isTrusted(entry));
548
552
  var contradictsDeclaration = (entry, decision) => decision.execution === "sandboxed" && unsandboxedRequirement(entry.metadata || {}) === "required";
549
553
 
550
- // src/messages.js
554
+ // src/messages.ts
551
555
  var messages = {
552
556
  en: {
553
557
  addTitle: "Choose extensions",
@@ -650,7 +654,7 @@ var formatMessage = (locale, key, values = {}) => {
650
654
  return template.replace(/\{(\w+)\}/g, (match, name) => values[name] === void 0 ? match : String(values[name]));
651
655
  };
652
656
 
653
- // src/wait-dialog.js
657
+ // src/wait-dialog.ts
654
658
  var styles = ".twextsec-wait{position:fixed;left:50vw;top:50vh;right:auto;bottom:auto;margin:0;transform:translate(-50%,-50%);box-sizing:border-box;width:min(440px,calc(100vw - 32px));border:1px solid var(--ui-black-transparent,#0000001a);border-radius:12px;padding:20px 24px;color:var(--ui-modal-foreground,#263145);background:var(--ui-modal-background,#fff);box-shadow:0 16px 48px #0000004d;font:inherit}.twextsec-wait::backdrop{background:#111827a6}.twextsec-wait:focus,.twextsec-wait:focus-visible{outline:none}.twextsec-wait h2{margin:0 0 10px;font-size:1.05em}.twextsec-wait p{margin:0 0 8px}.twextsec-wait-source{overflow-wrap:anywhere;font-size:.85em;opacity:.7}.twextsec-wait-note{margin-bottom:0;font-size:.9em;opacity:.8}";
655
659
  var injectStyles = (document) => {
656
660
  if (!document.head || document.querySelector("[data-twextsec-wait-style]")) return;
@@ -674,7 +678,7 @@ function createExtensionWaitDialog(document, locale = "en", { delayMs = 300 } =
674
678
  const render = () => {
675
679
  if (!dialog) return;
676
680
  dialog.querySelector('[data-twextsec-wait="attempt"]').textContent = label("fetchWaitRetry");
677
- dialog.querySelector('[data-twextsec-wait="source"]').textContent = latest.url || "";
681
+ dialog.querySelector('[data-twextsec-wait="source"]').textContent = (latest == null ? void 0 : latest.url) || "";
678
682
  };
679
683
  const open2 = () => {
680
684
  timer = null;
package/dist/index.d.ts CHANGED
@@ -1,70 +1,9 @@
1
- export * from './review-types.js';
2
- import type {
3
- ExtensionMetadata, ReviewDecision, ReviewEntry, LoadingMode, ExecutionDecision
4
- } from './review-types.js';
5
-
6
- export interface CatalogCategory {
7
- id: string; title: string; titleJa?: string; order: number;
8
- }
9
- export interface CatalogEntry {
10
- key: string; id: string; ids: string[]; url: string; sha256?: string;
11
- dependencies: readonly string[]; metadata: ExtensionMetadata; category?: CatalogCategory;
12
- }
13
- export function reviewURL(value: unknown, what?: string, allowHTTP?: boolean): string;
14
- export function parseExtensionCatalog(data: unknown): CatalogEntry[];
15
- export function loadExtensionCatalog(url: string, signal?: AbortSignal): Promise<CatalogEntry[]>;
16
-
17
- export function parseExtensionMetadata(source: string): ExtensionMetadata;
18
- export function getExtensionDescription(metadata: ExtensionMetadata, locale?: string): string;
19
- export function unsandboxedRequirement(metadata: ExtensionMetadata): 'required' | 'optional' | 'not-needed' | 'unknown';
20
- export function decodeExtensionDataURL(url: string): string;
21
- export function loadExtensionInfo(url: string, signal?: AbortSignal): Promise<{source: string; metadata: ExtensionMetadata}>;
22
-
23
- export type SelectionState = 'loaded' | 'selected' | 'dependency' | 'unselected';
24
- export interface ExtensionSelection {
25
- selected: Set<string>; explicit: Set<string>; required: Set<string>;
26
- requiredBy: Map<string, Set<string>>; loaded: Set<string>;
27
- ordered: Array<{id: string}>; stateOf(id: string): SelectionState;
28
- }
29
- export function resolveExtensionSelection(
30
- entries: Array<{id: string; dependencies?: readonly string[]}>,
31
- chosen?: Iterable<string>, loaded?: Iterable<string>
32
- ): ExtensionSelection;
33
-
34
- export interface DecisionStorage {
35
- readonly fallbackLoading: LoadingMode;
36
- read(project: string): Promise<Map<string, ReviewDecision>>;
37
- write(project: string, decisions: Map<string, ReviewDecision>): Promise<boolean>;
38
- forget(project: string): Promise<boolean>;
39
- }
40
- export function createDecisionStorage(options?: {fallbackLoading?: LoadingMode}): DecisionStorage;
41
- export interface PreviewCache {
42
- read(url: string): Promise<Blob | null>;
43
- write(url: string, blob: Blob): Promise<boolean>;
44
- }
45
- export function createPreviewCache(): PreviewCache;
46
-
47
- export type ReviewMode = 'add' | 'open';
48
- export function isTrusted(entry: ReviewEntry): boolean;
49
- export function allRequireUnsandboxed(entries: ReviewEntry[]): boolean;
50
- export const loadingModes: readonly LoadingMode[];
51
- export function loadingChoices(entry: ReviewEntry): LoadingMode[];
52
- export function executionChoices(entry: ReviewEntry, mode: ReviewMode): ExecutionDecision[];
53
- export function defaultDecision(entry: ReviewEntry, mode: ReviewMode, fallbackLoading?: LoadingMode): ReviewDecision;
54
- export function initialDecisions(entries: ReviewEntry[], mode: ReviewMode,
55
- options?: {recorded?: ReadonlyMap<string, ReviewDecision>; fallbackLoading?: LoadingMode}
56
- ): Map<string, ReviewDecision>;
57
- export function requiresReview(entries: ReviewEntry[]): boolean;
58
- export function contradictsDeclaration(entry: ReviewEntry, decision: ReviewDecision): boolean;
59
-
60
- export interface ExtensionWaitDialog {
61
- show(info: {url?: string; attempt?: number; attempts?: number}): void;
62
- hide(): void;
63
- dispose(): void;
64
- }
65
- export function createExtensionWaitDialog(
66
- document: Document, locale?: string, options?: {delayMs?: number}
67
- ): ExtensionWaitDialog;
68
-
69
- export const messages: Record<string, Record<string, string>>;
70
- export function formatMessage(locale: string, key: string, values?: Record<string, string | number>): string;
1
+ export type * from './review-types.js';
2
+ export * from './catalog.js';
3
+ export * from './metadata.js';
4
+ export * from './selection.js';
5
+ export * from './storage.js';
6
+ export * from './decisions.js';
7
+ export type { ExtensionWaitDialog } from './wait-dialog.js';
8
+ export { createExtensionWaitDialog } from './wait-dialog.js';
9
+ export { messages, formatMessage } from './messages.js';