asyar-sdk 4.15.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -21
- package/dist/ExtensionContext.d.ts.map +1 -1
- package/dist/ExtensionContext.js +6 -0
- package/dist/ExtensionContext.js.map +1 -1
- package/dist/ExtensionContextCore.d.ts +2 -0
- package/dist/ExtensionContextCore.d.ts.map +1 -1
- package/dist/ExtensionContextCore.js +3 -0
- package/dist/ExtensionContextCore.js.map +1 -1
- package/dist/cli/commands/attach.js +4 -13
- package/dist/cli/commands/attach.js.map +1 -1
- package/dist/cli/commands/build.js +29 -41
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/detach.js +1 -1
- package/dist/cli/commands/detach.js.map +1 -1
- package/dist/cli/commands/dev.js +12 -21
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/doctor.js +9 -19
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/link.js +63 -78
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/pack.d.ts +11 -0
- package/dist/cli/commands/pack.d.ts.map +1 -0
- package/dist/cli/commands/pack.js +140 -0
- package/dist/cli/commands/pack.js.map +1 -0
- package/dist/cli/commands/publish.d.ts.map +1 -1
- package/dist/cli/commands/publish.js +117 -144
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/validate.js +2 -11
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lib/auth.js +149 -170
- package/dist/cli/lib/auth.js.map +1 -1
- package/dist/cli/lib/config.js +3 -4
- package/dist/cli/lib/config.js.map +1 -1
- package/dist/cli/lib/extensionRepo.d.ts.map +1 -1
- package/dist/cli/lib/extensionRepo.js +5 -4
- package/dist/cli/lib/extensionRepo.js.map +1 -1
- package/dist/cli/lib/gatedPermissions.d.ts +1 -1
- package/dist/cli/lib/gatedPermissions.d.ts.map +1 -1
- package/dist/cli/lib/gatedPermissions.js +8 -0
- package/dist/cli/lib/gatedPermissions.js.map +1 -1
- package/dist/cli/lib/github.d.ts +7 -0
- package/dist/cli/lib/github.d.ts.map +1 -1
- package/dist/cli/lib/github.js +82 -86
- package/dist/cli/lib/github.js.map +1 -1
- package/dist/cli/lib/manifest.d.ts +88 -2
- package/dist/cli/lib/manifest.d.ts.map +1 -1
- package/dist/cli/lib/manifest.js +574 -29
- package/dist/cli/lib/manifest.js.map +1 -1
- package/dist/cli/lib/packaging.d.ts +12 -0
- package/dist/cli/lib/packaging.d.ts.map +1 -0
- package/dist/cli/lib/packaging.js +132 -0
- package/dist/cli/lib/packaging.js.map +1 -0
- package/dist/cli/lib/platform.js +3 -4
- package/dist/cli/lib/platform.js.map +1 -1
- package/dist/cli/lib/publishGitGuard.d.ts +51 -0
- package/dist/cli/lib/publishGitGuard.d.ts.map +1 -0
- package/dist/cli/lib/publishGitGuard.js +124 -0
- package/dist/cli/lib/publishGitGuard.js.map +1 -0
- package/dist/cli/lib/readme.d.ts +22 -0
- package/dist/cli/lib/readme.d.ts.map +1 -0
- package/dist/cli/lib/readme.js +104 -0
- package/dist/cli/lib/readme.js.map +1 -0
- package/dist/cli/lib/store.js +53 -64
- package/dist/cli/lib/store.js.map +1 -1
- package/dist/cli/lib/storeIcon.d.ts +12 -0
- package/dist/cli/lib/storeIcon.d.ts.map +1 -0
- package/dist/cli/lib/storeIcon.js +83 -0
- package/dist/cli/lib/storeIcon.js.map +1 -0
- package/dist/cli/lib/workerCompat.js +1 -1
- package/dist/cli/lib/workerCompat.js.map +1 -1
- package/dist/cli/lib/zip.d.ts +6 -1
- package/dist/cli/lib/zip.d.ts.map +1 -1
- package/dist/cli/lib/zip.js +21 -5
- package/dist/cli/lib/zip.js.map +1 -1
- package/dist/contracts/IAiService.d.ts +24 -0
- package/dist/contracts/IAiService.d.ts.map +1 -1
- package/dist/contracts/aiProvider.d.ts +98 -0
- package/dist/contracts/aiProvider.d.ts.map +1 -0
- package/dist/contracts/aiProvider.js +6 -0
- package/dist/contracts/aiProvider.js.map +1 -0
- package/dist/contracts/fileSearch.d.ts +47 -0
- package/dist/contracts/fileSearch.d.ts.map +1 -0
- package/dist/contracts/fileSearch.js +7 -0
- package/dist/contracts/fileSearch.js.map +1 -0
- package/dist/contracts/runs.d.ts +7 -0
- package/dist/contracts/runs.d.ts.map +1 -1
- package/dist/contracts/webReader.d.ts +50 -0
- package/dist/contracts/webReader.d.ts.map +1 -0
- package/dist/contracts/webReader.js +6 -0
- package/dist/contracts/webReader.js.map +1 -0
- package/dist/contracts/webSearch.d.ts +63 -0
- package/dist/contracts/webSearch.d.ts.map +1 -0
- package/dist/contracts/webSearch.js +6 -0
- package/dist/contracts/webSearch.js.map +1 -0
- package/dist/contracts.d.ts +5 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/icons/iconData.d.ts.map +1 -1
- package/dist/icons/iconData.js +10 -0
- package/dist/icons/iconData.js.map +1 -1
- package/dist/ipc/namespaces.d.ts +1 -1
- package/dist/ipc/namespaces.d.ts.map +1 -1
- package/dist/ipc/namespaces.js +3 -0
- package/dist/ipc/namespaces.js.map +1 -1
- package/dist/ipc/namespaces.test.js +3 -0
- package/dist/ipc/namespaces.test.js.map +1 -1
- package/dist/services/AiServiceProxy.d.ts +13 -0
- package/dist/services/AiServiceProxy.d.ts.map +1 -1
- package/dist/services/AiServiceProxy.js +104 -0
- package/dist/services/AiServiceProxy.js.map +1 -1
- package/dist/services/AiServiceProxy.test.js +129 -0
- package/dist/services/AiServiceProxy.test.js.map +1 -1
- package/dist/services/CalendarServiceProxy.d.ts +16 -0
- package/dist/services/CalendarServiceProxy.d.ts.map +1 -0
- package/dist/services/CalendarServiceProxy.js +65 -0
- package/dist/services/CalendarServiceProxy.js.map +1 -0
- package/dist/services/FilesServiceProxy.d.ts +4 -0
- package/dist/services/FilesServiceProxy.d.ts.map +1 -1
- package/dist/services/FilesServiceProxy.js +32 -0
- package/dist/services/FilesServiceProxy.js.map +1 -1
- package/dist/services/FilesServiceProxy.test.js +36 -0
- package/dist/services/FilesServiceProxy.test.js.map +1 -1
- package/dist/services/ICalendarService.d.ts +99 -0
- package/dist/services/ICalendarService.d.ts.map +1 -0
- package/dist/services/ICalendarService.js +2 -0
- package/dist/services/ICalendarService.js.map +1 -0
- package/dist/services/IFilesService.d.ts +7 -0
- package/dist/services/IFilesService.d.ts.map +1 -1
- package/dist/services/IMediaService.d.ts +38 -0
- package/dist/services/IMediaService.d.ts.map +1 -0
- package/dist/services/IMediaService.js +2 -0
- package/dist/services/IMediaService.js.map +1 -0
- package/dist/services/IShellService.d.ts +7 -0
- package/dist/services/IShellService.d.ts.map +1 -1
- package/dist/services/IShortcutsService.d.ts +24 -0
- package/dist/services/IShortcutsService.d.ts.map +1 -0
- package/dist/services/IShortcutsService.js +2 -0
- package/dist/services/IShortcutsService.js.map +1 -0
- package/dist/services/MediaServiceProxy.d.ts +12 -0
- package/dist/services/MediaServiceProxy.d.ts.map +1 -0
- package/dist/services/MediaServiceProxy.js +34 -0
- package/dist/services/MediaServiceProxy.js.map +1 -0
- package/dist/services/NetworkServiceProxy.d.ts +5 -1
- package/dist/services/NetworkServiceProxy.d.ts.map +1 -1
- package/dist/services/NetworkServiceProxy.js +16 -0
- package/dist/services/NetworkServiceProxy.js.map +1 -1
- package/dist/services/NetworkServiceProxy.test.js +42 -0
- package/dist/services/NetworkServiceProxy.test.js.map +1 -1
- package/dist/services/ShellServiceProxy.d.ts.map +1 -1
- package/dist/services/ShellServiceProxy.js +1 -0
- package/dist/services/ShellServiceProxy.js.map +1 -1
- package/dist/services/ShellServiceProxy.test.js +8 -0
- package/dist/services/ShellServiceProxy.test.js.map +1 -1
- package/dist/services/ShortcutsServiceProxy.d.ts +11 -0
- package/dist/services/ShortcutsServiceProxy.d.ts.map +1 -0
- package/dist/services/ShortcutsServiceProxy.js +29 -0
- package/dist/services/ShortcutsServiceProxy.js.map +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -1
- package/dist/types/CommandType.d.ts +5 -1
- package/dist/types/CommandType.d.ts.map +1 -1
- package/dist/types/ExtensionType.d.ts +36 -8
- package/dist/types/ExtensionType.d.ts.map +1 -1
- package/dist/types/NetworkType.d.ts +18 -0
- package/dist/types/NetworkType.d.ts.map +1 -1
- package/dist/view.test.js +3 -0
- package/dist/view.test.js.map +1 -1
- package/dist/worker.aiProvider.test.d.ts +2 -0
- package/dist/worker.aiProvider.test.d.ts.map +1 -0
- package/dist/worker.aiProvider.test.js +161 -0
- package/dist/worker.aiProvider.test.js.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.fileSearch.test.d.ts +2 -0
- package/dist/worker.fileSearch.test.d.ts.map +1 -0
- package/dist/worker.fileSearch.test.js +188 -0
- package/dist/worker.fileSearch.test.js.map +1 -0
- package/dist/worker.js +267 -0
- package/dist/worker.js.map +1 -1
- package/dist/worker.test.js +3 -0
- package/dist/worker.test.js.map +1 -1
- package/dist/worker.webReader.test.d.ts +2 -0
- package/dist/worker.webReader.test.d.ts.map +1 -0
- package/dist/worker.webReader.test.js +208 -0
- package/dist/worker.webReader.test.js.map +1 -0
- package/dist/worker.webSearch.test.d.ts +2 -0
- package/dist/worker.webSearch.test.d.ts.map +1 -0
- package/dist/worker.webSearch.test.js +111 -0
- package/dist/worker.webSearch.test.js.map +1 -0
- package/package.json +3 -3
- package/dist/cli/lib/manifestActionsCompat.d.ts +0 -14
- package/dist/cli/lib/manifestActionsCompat.d.ts.map +0 -1
- package/dist/cli/lib/manifestActionsCompat.js +0 -22
- package/dist/cli/lib/manifestActionsCompat.js.map +0 -1
package/dist/cli/lib/manifest.js
CHANGED
|
@@ -23,19 +23,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.VALID_RUNTIMES = exports.VALID_PLATFORMS = exports.VALID_PERMISSIONS = void 0;
|
|
26
|
+
exports.VALID_RUNTIMES = exports.VALID_PLATFORMS = exports.VALID_PERMISSIONS = exports.ICON_OBJECT_MIN_SDK = exports.ICON_TILE_COLORS = void 0;
|
|
27
27
|
exports.readManifest = readManifest;
|
|
28
28
|
exports.validateManifest = validateManifest;
|
|
29
29
|
exports.lintManifest = lintManifest;
|
|
30
30
|
exports.validateRequireAnyOf = validateRequireAnyOf;
|
|
31
31
|
exports.validateArguments = validateArguments;
|
|
32
32
|
exports.validateSearchBarAccessory = validateSearchBarAccessory;
|
|
33
|
+
exports.validateWebSearchEngines = validateWebSearchEngines;
|
|
34
|
+
exports.validateWebReaders = validateWebReaders;
|
|
35
|
+
exports.validateAiProviders = validateAiProviders;
|
|
33
36
|
exports.validatePreferences = validatePreferences;
|
|
37
|
+
exports.validateFileSearchProviders = validateFileSearchProviders;
|
|
34
38
|
const fs = __importStar(require("node:fs"));
|
|
35
39
|
const path = __importStar(require("node:path"));
|
|
36
40
|
const semver = __importStar(require("semver"));
|
|
41
|
+
const node_net_1 = require("node:net");
|
|
37
42
|
const knownRuntimes_1 = require("./knownRuntimes");
|
|
38
|
-
|
|
43
|
+
exports.ICON_TILE_COLORS = [
|
|
44
|
+
'red',
|
|
45
|
+
'orange',
|
|
46
|
+
'green',
|
|
47
|
+
'teal',
|
|
48
|
+
'blue',
|
|
49
|
+
'purple',
|
|
50
|
+
'pink',
|
|
51
|
+
'gray',
|
|
52
|
+
];
|
|
53
|
+
/** First SDK whose launcher reads the object form of `icon`. */
|
|
54
|
+
exports.ICON_OBJECT_MIN_SDK = '4.17.0';
|
|
39
55
|
const VALID_PREFERENCE_TYPES = [
|
|
40
56
|
'textfield',
|
|
41
57
|
'password',
|
|
@@ -68,6 +84,7 @@ exports.VALID_PERMISSIONS = [
|
|
|
68
84
|
'shell:open-url',
|
|
69
85
|
'shell:open-path',
|
|
70
86
|
'network',
|
|
87
|
+
'network:lan',
|
|
71
88
|
'network:secrets',
|
|
72
89
|
'selection:read',
|
|
73
90
|
'storage:read',
|
|
@@ -83,6 +100,13 @@ exports.VALID_PERMISSIONS = [
|
|
|
83
100
|
'application:read',
|
|
84
101
|
'entitlements:read',
|
|
85
102
|
'power:inhibit',
|
|
103
|
+
'media:control',
|
|
104
|
+
'calendar:read',
|
|
105
|
+
'calendar:write',
|
|
106
|
+
'reminders:read',
|
|
107
|
+
'reminders:write',
|
|
108
|
+
'shortcuts:read',
|
|
109
|
+
'shortcuts:run',
|
|
86
110
|
'systemEvents:read',
|
|
87
111
|
'app:frontmost-watch',
|
|
88
112
|
'timers:schedule',
|
|
@@ -104,10 +128,14 @@ exports.VALID_PERMISSIONS = [
|
|
|
104
128
|
'process:kill',
|
|
105
129
|
'files:search',
|
|
106
130
|
'files:read',
|
|
131
|
+
'files:search-provider',
|
|
107
132
|
'notes:read',
|
|
108
133
|
'notes:write',
|
|
109
134
|
'mcp',
|
|
110
135
|
'ai',
|
|
136
|
+
'ai:web-search',
|
|
137
|
+
'ai:web-reader',
|
|
138
|
+
'ai:provider',
|
|
111
139
|
];
|
|
112
140
|
exports.VALID_PLATFORMS = ['macos', 'windows', 'linux'];
|
|
113
141
|
/**
|
|
@@ -124,12 +152,128 @@ function readManifest(cwd) {
|
|
|
124
152
|
try {
|
|
125
153
|
return JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
126
154
|
}
|
|
127
|
-
catch
|
|
155
|
+
catch {
|
|
128
156
|
throw new Error('manifest.json is not valid JSON');
|
|
129
157
|
}
|
|
130
158
|
}
|
|
159
|
+
function parseIpv4(value) {
|
|
160
|
+
const parts = value.split('.');
|
|
161
|
+
if (parts.length !== 4)
|
|
162
|
+
return null;
|
|
163
|
+
const octets = parts.map((part) => (/^(0|[1-9]\d{0,2})$/.test(part) ? Number(part) : -1));
|
|
164
|
+
if (octets.some((part) => part < 0 || part > 255))
|
|
165
|
+
return null;
|
|
166
|
+
return octets.reduce((result, part) => (result << 8n) | BigInt(part), 0n);
|
|
167
|
+
}
|
|
168
|
+
function parseIpv6(value) {
|
|
169
|
+
if (value.includes('.') || value.includes('%') || value.split('::').length > 2)
|
|
170
|
+
return null;
|
|
171
|
+
const [leftRaw, rightRaw] = value.split('::');
|
|
172
|
+
const left = leftRaw ? leftRaw.split(':') : [];
|
|
173
|
+
const right = rightRaw ? rightRaw.split(':') : [];
|
|
174
|
+
if (!value.includes('::') && left.length !== 8)
|
|
175
|
+
return null;
|
|
176
|
+
if (value.includes('::') && left.length + right.length >= 8)
|
|
177
|
+
return null;
|
|
178
|
+
const groups = [...left, ...Array(8 - left.length - right.length).fill('0'), ...right];
|
|
179
|
+
if (groups.length !== 8 || groups.some((group) => !/^[0-9a-fA-F]{1,4}$/.test(group))) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return groups.reduce((result, group) => (result << 16n) | BigInt(`0x${group}`), 0n);
|
|
183
|
+
}
|
|
184
|
+
function parsedIp(value) {
|
|
185
|
+
const version = (0, node_net_1.isIP)(value);
|
|
186
|
+
if (version === 4)
|
|
187
|
+
return { bits: 32, number: parseIpv4(value) };
|
|
188
|
+
if (version === 6)
|
|
189
|
+
return { bits: 128, number: parseIpv6(value) };
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function inCidr(value, network, bits, prefix) {
|
|
193
|
+
const mask = prefix === 0 ? 0n : ((1n << BigInt(bits)) - 1n) << BigInt(bits - prefix);
|
|
194
|
+
return (value & mask) === (network & mask);
|
|
195
|
+
}
|
|
196
|
+
function unsafeOrNonLanIp(ip) {
|
|
197
|
+
if (ip.bits === 32) {
|
|
198
|
+
const isPrivate = inCidr(ip.number, 0x0a000000n, 32, 8) ||
|
|
199
|
+
inCidr(ip.number, 0xac100000n, 32, 12) ||
|
|
200
|
+
inCidr(ip.number, 0xc0a80000n, 32, 16) ||
|
|
201
|
+
inCidr(ip.number, 0x64400000n, 32, 10);
|
|
202
|
+
const unsafe = inCidr(ip.number, 0x7f000000n, 32, 8) ||
|
|
203
|
+
inCidr(ip.number, 0xa9fe0000n, 32, 16) ||
|
|
204
|
+
inCidr(ip.number, 0xe0000000n, 32, 4) ||
|
|
205
|
+
ip.number === 0x646464c8n;
|
|
206
|
+
return !isPrivate || unsafe;
|
|
207
|
+
}
|
|
208
|
+
const uniqueLocal = inCidr(ip.number, 0xfc00n << 112n, 128, 7);
|
|
209
|
+
const unsafe = ip.number === 1n ||
|
|
210
|
+
inCidr(ip.number, 0xfe80n << 112n, 128, 10) ||
|
|
211
|
+
inCidr(ip.number, 0xff00n << 112n, 128, 8) ||
|
|
212
|
+
ip.number === parseIpv6('fd00:ec2::254');
|
|
213
|
+
return !uniqueLocal || unsafe;
|
|
214
|
+
}
|
|
215
|
+
function validateLanEndpoint(endpoint) {
|
|
216
|
+
let target;
|
|
217
|
+
let portText;
|
|
218
|
+
if (endpoint.startsWith('[')) {
|
|
219
|
+
const close = endpoint.indexOf(']');
|
|
220
|
+
if (close < 0 || endpoint[close + 1] !== ':')
|
|
221
|
+
return 'must use [address/prefix]:port';
|
|
222
|
+
target = endpoint.slice(1, close);
|
|
223
|
+
portText = endpoint.slice(close + 2);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const colon = endpoint.lastIndexOf(':');
|
|
227
|
+
if (colon < 1)
|
|
228
|
+
return 'must include a port';
|
|
229
|
+
target = endpoint.slice(0, colon);
|
|
230
|
+
portText = endpoint.slice(colon + 1);
|
|
231
|
+
}
|
|
232
|
+
if (!/^\d+$/.test(portText) || Number(portText) < 1 || Number(portText) > 65535) {
|
|
233
|
+
return 'has an invalid port';
|
|
234
|
+
}
|
|
235
|
+
const slash = target.indexOf('/');
|
|
236
|
+
if (slash >= 0) {
|
|
237
|
+
const address = target.slice(0, slash);
|
|
238
|
+
const prefixText = target.slice(slash + 1);
|
|
239
|
+
const ip = parsedIp(address);
|
|
240
|
+
if (!ip || !/^\d+$/.test(prefixText))
|
|
241
|
+
return 'has an invalid CIDR';
|
|
242
|
+
const prefix = Number(prefixText);
|
|
243
|
+
if (prefix > ip.bits || !inCidr(ip.number, ip.number, ip.bits, prefix)) {
|
|
244
|
+
return 'has an invalid CIDR';
|
|
245
|
+
}
|
|
246
|
+
const mask = prefix === 0 ? 0n : ((1n << BigInt(ip.bits)) - 1n) << BigInt(ip.bits - prefix);
|
|
247
|
+
if ((ip.number & mask) !== ip.number)
|
|
248
|
+
return 'CIDR must use its canonical network address';
|
|
249
|
+
if (unsafeOrNonLanIp(ip))
|
|
250
|
+
return 'must be a private LAN CIDR';
|
|
251
|
+
const unsafeProbes = ip.bits === 32
|
|
252
|
+
? [0x7f000001n, 0xa9fea9fen, 0x646464c8n, 0xeffffffan]
|
|
253
|
+
: [1n, 0xfe80n << 112n, 0xff00n << 112n, parseIpv6('fd00:ec2::254')];
|
|
254
|
+
if (unsafeProbes.some((probe) => inCidr(probe, ip.number, ip.bits, prefix))) {
|
|
255
|
+
return 'CIDR includes a blocked loopback, link-local, multicast, or metadata address';
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const ip = parsedIp(target);
|
|
260
|
+
if (ip)
|
|
261
|
+
return unsafeOrNonLanIp(ip) ? 'must be a private LAN address' : null;
|
|
262
|
+
try {
|
|
263
|
+
const parsed = new URL(`http://${target}:1`);
|
|
264
|
+
if (!parsed.hostname ||
|
|
265
|
+
parsed.username ||
|
|
266
|
+
parsed.password ||
|
|
267
|
+
target.toLowerCase() === 'localhost') {
|
|
268
|
+
return 'has an invalid host';
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return 'has an invalid host';
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
131
276
|
function validateManifest(manifest, cwd) {
|
|
132
|
-
var _a, _b, _c, _d;
|
|
133
277
|
const errors = [];
|
|
134
278
|
const asUnknown = manifest;
|
|
135
279
|
if (!manifest.id) {
|
|
@@ -176,6 +320,41 @@ function validateManifest(manifest, cwd) {
|
|
|
176
320
|
}
|
|
177
321
|
});
|
|
178
322
|
}
|
|
323
|
+
const lanArgs = manifest.permissionArgs?.['network:lan'];
|
|
324
|
+
const declaresLan = manifest.permissions?.includes('network:lan') ?? false;
|
|
325
|
+
if (declaresLan) {
|
|
326
|
+
if (!manifest.permissions?.includes('network')) {
|
|
327
|
+
errors.push({ field: 'permissions', message: '"network:lan" requires "network"' });
|
|
328
|
+
}
|
|
329
|
+
if (lanArgs !== undefined) {
|
|
330
|
+
// Only validate when present; absent = user manages the allowlist in Settings
|
|
331
|
+
if (!Array.isArray(lanArgs) ||
|
|
332
|
+
lanArgs.length === 0 ||
|
|
333
|
+
!lanArgs.every((entry) => typeof entry === 'string')) {
|
|
334
|
+
errors.push({
|
|
335
|
+
field: 'permissionArgs.network:lan',
|
|
336
|
+
message: 'must be a non-empty array of host-or-CIDR:port strings',
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
for (const endpoint of lanArgs) {
|
|
341
|
+
const reason = validateLanEndpoint(endpoint);
|
|
342
|
+
if (reason) {
|
|
343
|
+
errors.push({
|
|
344
|
+
field: 'permissionArgs.network:lan',
|
|
345
|
+
message: `"${endpoint}" ${reason}`,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (lanArgs !== undefined) {
|
|
353
|
+
errors.push({
|
|
354
|
+
field: 'permissionArgs.network:lan',
|
|
355
|
+
message: 'requires "network:lan" in permissions',
|
|
356
|
+
});
|
|
357
|
+
}
|
|
179
358
|
if (manifest.runtimes) {
|
|
180
359
|
manifest.runtimes.forEach((rt) => {
|
|
181
360
|
if (!exports.VALID_RUNTIMES.includes(rt)) {
|
|
@@ -237,9 +416,9 @@ function validateManifest(manifest, cwd) {
|
|
|
237
416
|
validateCommand(cmd, i, errors);
|
|
238
417
|
});
|
|
239
418
|
}
|
|
240
|
-
const hasBackgroundCommand = (
|
|
241
|
-
const hasViewCommand = (
|
|
242
|
-
const declaresBackground = !!
|
|
419
|
+
const hasBackgroundCommand = (manifest.commands ?? []).some((c) => c.mode === 'background');
|
|
420
|
+
const hasViewCommand = (manifest.commands ?? []).some((c) => c.mode === 'view');
|
|
421
|
+
const declaresBackground = !!manifest.background?.main;
|
|
243
422
|
if ((hasBackgroundCommand || manifest.searchable === true) && !declaresBackground) {
|
|
244
423
|
errors.push({
|
|
245
424
|
field: 'background.main',
|
|
@@ -306,8 +485,13 @@ function validateManifest(manifest, cwd) {
|
|
|
306
485
|
});
|
|
307
486
|
}
|
|
308
487
|
}
|
|
488
|
+
errors.push(...validateIcons(manifest));
|
|
309
489
|
errors.push(...validatePreferences(manifest.preferences, 'preferences'));
|
|
310
|
-
((
|
|
490
|
+
errors.push(...validateWebSearchEngines(manifest.webSearchEngines, 'webSearchEngines', manifest));
|
|
491
|
+
errors.push(...validateWebReaders(manifest.webReaders, 'webReaders', manifest));
|
|
492
|
+
errors.push(...validateAiProviders(manifest.aiProviders, 'aiProviders', manifest));
|
|
493
|
+
errors.push(...validateFileSearchProviders(manifest.fileSearchProviders, 'fileSearchProviders', manifest));
|
|
494
|
+
(manifest.commands ?? []).forEach((cmd, i) => {
|
|
311
495
|
errors.push(...validatePreferences(cmd.preferences, `commands[${i}].preferences`));
|
|
312
496
|
errors.push(...validateArguments(cmd.arguments, `commands[${i}].arguments`));
|
|
313
497
|
errors.push(...validateRequireAnyOf(cmd.requireAnyOf, cmd.arguments, `commands[${i}].requireAnyOf`));
|
|
@@ -316,7 +500,6 @@ function validateManifest(manifest, cwd) {
|
|
|
316
500
|
return errors;
|
|
317
501
|
}
|
|
318
502
|
function lintManifest(manifest, cwd) {
|
|
319
|
-
var _a, _b;
|
|
320
503
|
const errors = validateManifest(manifest, cwd);
|
|
321
504
|
const warnings = [];
|
|
322
505
|
// Check README.md existence and substance
|
|
@@ -337,7 +520,7 @@ function lintManifest(manifest, cwd) {
|
|
|
337
520
|
});
|
|
338
521
|
}
|
|
339
522
|
}
|
|
340
|
-
catch
|
|
523
|
+
catch {
|
|
341
524
|
// ignore fs read error
|
|
342
525
|
}
|
|
343
526
|
}
|
|
@@ -349,20 +532,9 @@ function lintManifest(manifest, cwd) {
|
|
|
349
532
|
message: 'No icon specified in manifest.json. Adding an icon helps users recognize your extension in search and the store.',
|
|
350
533
|
});
|
|
351
534
|
}
|
|
352
|
-
// Removed feature, still tolerated by the launcher until the version named
|
|
353
|
-
// in the message. Advisory: the extension builds and runs, minus those actions.
|
|
354
|
-
if (asRecord.actions !== undefined) {
|
|
355
|
-
warnings.push({ field: 'actions', message: (0, manifestActionsCompat_1.manifestActionsWarning)() });
|
|
356
|
-
}
|
|
357
|
-
((_a = manifest.commands) !== null && _a !== void 0 ? _a : []).forEach((cmd, i) => {
|
|
358
|
-
if (cmd.actions !== undefined) {
|
|
359
|
-
warnings.push({ field: `commands[${i}].actions`, message: (0, manifestActionsCompat_1.manifestActionsWarning)() });
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
535
|
// Check command argument placeholders
|
|
363
|
-
(
|
|
364
|
-
|
|
365
|
-
((_a = cmd.arguments) !== null && _a !== void 0 ? _a : []).forEach((arg, ai) => {
|
|
536
|
+
(manifest.commands ?? []).forEach((cmd, i) => {
|
|
537
|
+
(cmd.arguments ?? []).forEach((arg, ai) => {
|
|
366
538
|
if (!arg.placeholder && (arg.type === 'text' || arg.type === 'number')) {
|
|
367
539
|
warnings.push({
|
|
368
540
|
field: `commands[${i}].arguments[${ai}].placeholder`,
|
|
@@ -387,11 +559,74 @@ const WALKTHROUGH_RULE_TYPES = ['launch', 'count', 'state', 'manual'];
|
|
|
387
559
|
* and the launcher rejects anything that slips through at discovery time —
|
|
388
560
|
* the CLI check exists to fail earlier, with a friendlier message.
|
|
389
561
|
*/
|
|
562
|
+
/** Same rules as `ManifestIcon` in the launcher's `src-tauri/src/icons.rs`. */
|
|
563
|
+
function validateIconValue(icon, field) {
|
|
564
|
+
if (icon === undefined || typeof icon === 'string')
|
|
565
|
+
return [];
|
|
566
|
+
if (typeof icon !== 'object' || icon === null || Array.isArray(icon)) {
|
|
567
|
+
return [{ field, message: 'must be a string or an object' }];
|
|
568
|
+
}
|
|
569
|
+
const keys = Object.keys(icon);
|
|
570
|
+
const unknown = keys.filter((k) => !['source', 'dark', 'tint', 'glyph', 'color'].includes(k));
|
|
571
|
+
if (unknown.length > 0) {
|
|
572
|
+
return [{ field, message: `unknown field(s): ${unknown.join(', ')}` }];
|
|
573
|
+
}
|
|
574
|
+
const o = icon;
|
|
575
|
+
const imageForm = ['source', 'dark', 'tint'].some((k) => k in o);
|
|
576
|
+
const tileForm = ['glyph', 'color'].some((k) => k in o);
|
|
577
|
+
if (imageForm && tileForm) {
|
|
578
|
+
return [{ field, message: 'use either { source, dark, tint } or { glyph, color }, not both' }];
|
|
579
|
+
}
|
|
580
|
+
if (imageForm) {
|
|
581
|
+
if (typeof o.source !== 'string' || !o.source) {
|
|
582
|
+
return [{ field: `${field}.source`, message: 'required' }];
|
|
583
|
+
}
|
|
584
|
+
if ('dark' in o && typeof o.dark !== 'string') {
|
|
585
|
+
return [{ field: `${field}.dark`, message: 'must be a string' }];
|
|
586
|
+
}
|
|
587
|
+
if ('tint' in o && typeof o.tint !== 'boolean') {
|
|
588
|
+
return [{ field: `${field}.tint`, message: 'must be a boolean' }];
|
|
589
|
+
}
|
|
590
|
+
return [];
|
|
591
|
+
}
|
|
592
|
+
if (tileForm) {
|
|
593
|
+
if (typeof o.glyph !== 'string' || !o.glyph.trim()) {
|
|
594
|
+
return [{ field: `${field}.glyph`, message: 'required' }];
|
|
595
|
+
}
|
|
596
|
+
if (!exports.ICON_TILE_COLORS.includes(o.color)) {
|
|
597
|
+
return [
|
|
598
|
+
{ field: `${field}.color`, message: `must be one of: ${exports.ICON_TILE_COLORS.join(', ')}` },
|
|
599
|
+
];
|
|
600
|
+
}
|
|
601
|
+
return [];
|
|
602
|
+
}
|
|
603
|
+
return [{ field, message: 'needs { source } or { glyph, color }' }];
|
|
604
|
+
}
|
|
605
|
+
function validateIcons(manifest) {
|
|
606
|
+
const icons = [];
|
|
607
|
+
const collect = (owner, base) => {
|
|
608
|
+
icons.push([owner.icon, `${base}icon`]);
|
|
609
|
+
(Array.isArray(owner.actions) ? owner.actions : []).forEach((a, i) => icons.push([a?.icon, `${base}actions[${i}].icon`]));
|
|
610
|
+
};
|
|
611
|
+
collect(manifest, '');
|
|
612
|
+
(manifest.commands ?? []).forEach((cmd, i) => collect(cmd, `commands[${i}].`));
|
|
613
|
+
const errors = icons.flatMap(([icon, field]) => validateIconValue(icon, field));
|
|
614
|
+
const usesObject = icons.find(([icon]) => typeof icon === 'object' && icon !== null);
|
|
615
|
+
const minSdk = typeof manifest.asyarSdk === 'string' && semver.validRange(manifest.asyarSdk)
|
|
616
|
+
? semver.minVersion(manifest.asyarSdk)
|
|
617
|
+
: null;
|
|
618
|
+
if (usesObject && (!minSdk || semver.lt(minSdk, exports.ICON_OBJECT_MIN_SDK))) {
|
|
619
|
+
errors.push({
|
|
620
|
+
field: 'asyarSdk',
|
|
621
|
+
message: `${usesObject[1]} uses the object form, which needs "asyarSdk": "^${exports.ICON_OBJECT_MIN_SDK}" or newer so older launchers skip this extension`,
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
return errors;
|
|
625
|
+
}
|
|
390
626
|
function validateWalkthrough(tasks) {
|
|
391
627
|
const errors = [];
|
|
392
628
|
const seen = new Set();
|
|
393
629
|
tasks.forEach((task, i) => {
|
|
394
|
-
var _a, _b;
|
|
395
630
|
const base = `walkthrough[${i}]`;
|
|
396
631
|
if (!task.id || !task.id.trim()) {
|
|
397
632
|
errors.push({ field: `${base}.id`, message: 'required' });
|
|
@@ -423,10 +658,10 @@ function validateWalkthrough(tasks) {
|
|
|
423
658
|
});
|
|
424
659
|
return;
|
|
425
660
|
}
|
|
426
|
-
if ((rule.type === 'launch' || rule.type === 'count') && !
|
|
661
|
+
if ((rule.type === 'launch' || rule.type === 'count') && !rule.target?.trim()) {
|
|
427
662
|
errors.push({ field: `${base}.completion.target`, message: 'required' });
|
|
428
663
|
}
|
|
429
|
-
if (rule.type === 'state' && !
|
|
664
|
+
if (rule.type === 'state' && !rule.probe?.trim()) {
|
|
430
665
|
errors.push({ field: `${base}.completion.probe`, message: 'required' });
|
|
431
666
|
}
|
|
432
667
|
});
|
|
@@ -544,7 +779,6 @@ function validateCommand(cmd, i, errors) {
|
|
|
544
779
|
* `validate_require_any_of` in `extensions/mod.rs`.
|
|
545
780
|
*/
|
|
546
781
|
function validateRequireAnyOf(group, args, pathPrefix) {
|
|
547
|
-
var _a;
|
|
548
782
|
const errors = [];
|
|
549
783
|
if (group === undefined)
|
|
550
784
|
return errors;
|
|
@@ -552,7 +786,7 @@ function validateRequireAnyOf(group, args, pathPrefix) {
|
|
|
552
786
|
errors.push({ field: pathPrefix, message: 'requireAnyOf must be an array of argument names' });
|
|
553
787
|
return errors;
|
|
554
788
|
}
|
|
555
|
-
const declared = new Set((args
|
|
789
|
+
const declared = new Set((args ?? []).map((a) => a.name));
|
|
556
790
|
const seen = new Set();
|
|
557
791
|
for (const name of group) {
|
|
558
792
|
if (!declared.has(name)) {
|
|
@@ -567,7 +801,7 @@ function validateRequireAnyOf(group, args, pathPrefix) {
|
|
|
567
801
|
continue;
|
|
568
802
|
}
|
|
569
803
|
seen.add(name);
|
|
570
|
-
if ((
|
|
804
|
+
if ((args ?? []).find((a) => a.name === name)?.required) {
|
|
571
805
|
errors.push({
|
|
572
806
|
field: pathPrefix,
|
|
573
807
|
message: `requireAnyOf lists '${name}', which is already required — a required argument must always be filled, so it cannot be one of several alternatives`,
|
|
@@ -756,6 +990,226 @@ function validateSearchBarAccessory(acc, pathPrefix) {
|
|
|
756
990
|
}
|
|
757
991
|
return errors;
|
|
758
992
|
}
|
|
993
|
+
function validateWebSearchEngines(engines, fieldPrefix, manifest) {
|
|
994
|
+
const errors = [];
|
|
995
|
+
if (engines === undefined)
|
|
996
|
+
return errors;
|
|
997
|
+
if (!Array.isArray(engines) || engines.length === 0) {
|
|
998
|
+
errors.push({ field: fieldPrefix, message: 'must be a non-empty array' });
|
|
999
|
+
return errors;
|
|
1000
|
+
}
|
|
1001
|
+
if (manifest.type === 'theme') {
|
|
1002
|
+
errors.push({
|
|
1003
|
+
field: fieldPrefix,
|
|
1004
|
+
message: 'Theme extensions must not declare webSearchEngines',
|
|
1005
|
+
});
|
|
1006
|
+
return errors;
|
|
1007
|
+
}
|
|
1008
|
+
if (!manifest.background?.main) {
|
|
1009
|
+
errors.push({
|
|
1010
|
+
field: 'background.main',
|
|
1011
|
+
message: 'required when manifest declares webSearchEngines (search engines run in the headless worker)',
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
const perms = manifest.permissions ?? [];
|
|
1015
|
+
if (!perms.includes('network')) {
|
|
1016
|
+
errors.push({
|
|
1017
|
+
field: 'permissions',
|
|
1018
|
+
message: 'manifest with webSearchEngines requires the "network" permission',
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
if (!perms.includes('ai:web-search')) {
|
|
1022
|
+
errors.push({
|
|
1023
|
+
field: 'permissions',
|
|
1024
|
+
message: 'manifest with webSearchEngines requires the "ai:web-search" permission',
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
const seenIds = new Set();
|
|
1028
|
+
const idRe = /^[a-z0-9_-]{1,64}$/;
|
|
1029
|
+
engines.forEach((item, i) => {
|
|
1030
|
+
const p = `${fieldPrefix}[${i}]`;
|
|
1031
|
+
if (!item || typeof item !== 'object') {
|
|
1032
|
+
errors.push({ field: p, message: 'must be an object' });
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const e = item;
|
|
1036
|
+
if (typeof e.id !== 'string' || !idRe.test(e.id)) {
|
|
1037
|
+
errors.push({ field: `${p}.id`, message: 'must match /^[a-z0-9_-]{1,64}$/' });
|
|
1038
|
+
}
|
|
1039
|
+
else if (seenIds.has(e.id)) {
|
|
1040
|
+
errors.push({ field: `${p}.id`, message: `duplicate engine id "${e.id}"` });
|
|
1041
|
+
}
|
|
1042
|
+
else {
|
|
1043
|
+
seenIds.add(e.id);
|
|
1044
|
+
}
|
|
1045
|
+
if (typeof e.name !== 'string' || e.name.trim().length === 0) {
|
|
1046
|
+
errors.push({ field: `${p}.name`, message: 'required and must be non-empty' });
|
|
1047
|
+
}
|
|
1048
|
+
if (typeof e.homepage === 'string' && !/^https?:\/\//.test(e.homepage)) {
|
|
1049
|
+
errors.push({ field: `${p}.homepage`, message: 'must start with http:// or https://' });
|
|
1050
|
+
}
|
|
1051
|
+
if (typeof e.apiKeyHelpUrl === 'string' && !/^https?:\/\//.test(e.apiKeyHelpUrl)) {
|
|
1052
|
+
errors.push({ field: `${p}.apiKeyHelpUrl`, message: 'must start with http:// or https://' });
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
return errors;
|
|
1056
|
+
}
|
|
1057
|
+
function validateWebReaders(readers, fieldPrefix, manifest) {
|
|
1058
|
+
const errors = [];
|
|
1059
|
+
if (readers === undefined)
|
|
1060
|
+
return errors;
|
|
1061
|
+
if (!Array.isArray(readers) || readers.length === 0) {
|
|
1062
|
+
errors.push({ field: fieldPrefix, message: 'must be a non-empty array' });
|
|
1063
|
+
return errors;
|
|
1064
|
+
}
|
|
1065
|
+
if (manifest.type === 'theme') {
|
|
1066
|
+
errors.push({
|
|
1067
|
+
field: fieldPrefix,
|
|
1068
|
+
message: 'Theme extensions must not declare webReaders',
|
|
1069
|
+
});
|
|
1070
|
+
return errors;
|
|
1071
|
+
}
|
|
1072
|
+
if (!manifest.background?.main) {
|
|
1073
|
+
errors.push({
|
|
1074
|
+
field: 'background.main',
|
|
1075
|
+
message: 'required when manifest declares webReaders (web readers run in the headless worker)',
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
const perms = manifest.permissions ?? [];
|
|
1079
|
+
if (!perms.includes('network')) {
|
|
1080
|
+
errors.push({
|
|
1081
|
+
field: 'permissions',
|
|
1082
|
+
message: 'manifest with webReaders requires the "network" permission',
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
if (!perms.includes('ai:web-reader')) {
|
|
1086
|
+
errors.push({
|
|
1087
|
+
field: 'permissions',
|
|
1088
|
+
message: 'manifest with webReaders requires the "ai:web-reader" permission',
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
const seenIds = new Set();
|
|
1092
|
+
const idRe = /^[a-z0-9_-]{1,64}$/;
|
|
1093
|
+
readers.forEach((item, i) => {
|
|
1094
|
+
const p = `${fieldPrefix}[${i}]`;
|
|
1095
|
+
if (!item || typeof item !== 'object') {
|
|
1096
|
+
errors.push({ field: p, message: 'must be an object' });
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
const r = item;
|
|
1100
|
+
if (typeof r.id !== 'string' || !idRe.test(r.id)) {
|
|
1101
|
+
errors.push({ field: `${p}.id`, message: 'must match /^[a-z0-9_-]{1,64}$/' });
|
|
1102
|
+
}
|
|
1103
|
+
else if (seenIds.has(r.id)) {
|
|
1104
|
+
errors.push({ field: `${p}.id`, message: `duplicate reader id "${r.id}"` });
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
seenIds.add(r.id);
|
|
1108
|
+
}
|
|
1109
|
+
if (typeof r.name !== 'string' || r.name.trim().length === 0) {
|
|
1110
|
+
errors.push({ field: `${p}.name`, message: 'required and must be non-empty' });
|
|
1111
|
+
}
|
|
1112
|
+
if (typeof r.homepage === 'string' && !/^https?:\/\//.test(r.homepage)) {
|
|
1113
|
+
errors.push({ field: `${p}.homepage`, message: 'must start with http:// or https://' });
|
|
1114
|
+
}
|
|
1115
|
+
if (typeof r.apiKeyHelpUrl === 'string' && !/^https?:\/\//.test(r.apiKeyHelpUrl)) {
|
|
1116
|
+
errors.push({ field: `${p}.apiKeyHelpUrl`, message: 'must start with http:// or https://' });
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
return errors;
|
|
1120
|
+
}
|
|
1121
|
+
function validateAiProviders(providers, fieldPrefix, manifest) {
|
|
1122
|
+
const errors = [];
|
|
1123
|
+
if (providers === undefined)
|
|
1124
|
+
return errors;
|
|
1125
|
+
if (!Array.isArray(providers) || providers.length === 0) {
|
|
1126
|
+
errors.push({ field: fieldPrefix, message: 'must be a non-empty array' });
|
|
1127
|
+
return errors;
|
|
1128
|
+
}
|
|
1129
|
+
if (manifest.type === 'theme') {
|
|
1130
|
+
errors.push({
|
|
1131
|
+
field: fieldPrefix,
|
|
1132
|
+
message: 'Theme extensions must not declare aiProviders',
|
|
1133
|
+
});
|
|
1134
|
+
return errors;
|
|
1135
|
+
}
|
|
1136
|
+
if (!manifest.background?.main) {
|
|
1137
|
+
errors.push({
|
|
1138
|
+
field: 'background.main',
|
|
1139
|
+
message: 'required when manifest declares aiProviders (inference providers run in the headless worker)',
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
const perms = manifest.permissions ?? [];
|
|
1143
|
+
if (!perms.includes('network')) {
|
|
1144
|
+
errors.push({
|
|
1145
|
+
field: 'permissions',
|
|
1146
|
+
message: 'manifest with aiProviders requires the "network" permission',
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
if (!perms.includes('ai:provider')) {
|
|
1150
|
+
errors.push({
|
|
1151
|
+
field: 'permissions',
|
|
1152
|
+
message: 'manifest with aiProviders requires the "ai:provider" permission',
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
const seenIds = new Set();
|
|
1156
|
+
const idRe = /^[a-z0-9_-]{1,64}$/;
|
|
1157
|
+
providers.forEach((item, i) => {
|
|
1158
|
+
const p = `${fieldPrefix}[${i}]`;
|
|
1159
|
+
if (!item || typeof item !== 'object') {
|
|
1160
|
+
errors.push({ field: p, message: 'must be an object' });
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const prov = item;
|
|
1164
|
+
if (typeof prov.id !== 'string' || !idRe.test(prov.id)) {
|
|
1165
|
+
errors.push({ field: `${p}.id`, message: 'must match /^[a-z0-9_-]{1,64}$/' });
|
|
1166
|
+
}
|
|
1167
|
+
else if (seenIds.has(prov.id)) {
|
|
1168
|
+
errors.push({ field: `${p}.id`, message: `duplicate provider id "${prov.id}"` });
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
seenIds.add(prov.id);
|
|
1172
|
+
}
|
|
1173
|
+
if (typeof prov.name !== 'string' || prov.name.trim().length === 0) {
|
|
1174
|
+
errors.push({ field: `${p}.name`, message: 'required and must be non-empty' });
|
|
1175
|
+
}
|
|
1176
|
+
if (typeof prov.homepage === 'string' && !/^https?:\/\//.test(prov.homepage)) {
|
|
1177
|
+
errors.push({ field: `${p}.homepage`, message: 'must start with http:// or https://' });
|
|
1178
|
+
}
|
|
1179
|
+
if (typeof prov.apiKeyHelpUrl === 'string' && !/^https?:\/\//.test(prov.apiKeyHelpUrl)) {
|
|
1180
|
+
errors.push({ field: `${p}.apiKeyHelpUrl`, message: 'must start with http:// or https://' });
|
|
1181
|
+
}
|
|
1182
|
+
if (prov.models !== undefined) {
|
|
1183
|
+
if (!Array.isArray(prov.models)) {
|
|
1184
|
+
errors.push({ field: `${p}.models`, message: 'must be an array of models' });
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
const seenModelIds = new Set();
|
|
1188
|
+
prov.models.forEach((m, mi) => {
|
|
1189
|
+
const mp = `${p}.models[${mi}]`;
|
|
1190
|
+
if (!m || typeof m !== 'object') {
|
|
1191
|
+
errors.push({ field: mp, message: 'must be an object' });
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
const modelObj = m;
|
|
1195
|
+
if (typeof modelObj.id !== 'string' || modelObj.id.trim().length === 0) {
|
|
1196
|
+
errors.push({ field: `${mp}.id`, message: 'required and must be non-empty' });
|
|
1197
|
+
}
|
|
1198
|
+
else if (seenModelIds.has(modelObj.id)) {
|
|
1199
|
+
errors.push({ field: `${mp}.id`, message: `duplicate model id "${modelObj.id}"` });
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
seenModelIds.add(modelObj.id);
|
|
1203
|
+
}
|
|
1204
|
+
if (typeof modelObj.name !== 'string' || modelObj.name.trim().length === 0) {
|
|
1205
|
+
errors.push({ field: `${mp}.name`, message: 'required and must be non-empty' });
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
return errors;
|
|
1212
|
+
}
|
|
759
1213
|
function validatePreferences(prefs, pathPrefix) {
|
|
760
1214
|
const errors = [];
|
|
761
1215
|
if (!prefs)
|
|
@@ -833,4 +1287,95 @@ function validatePreferences(prefs, pathPrefix) {
|
|
|
833
1287
|
});
|
|
834
1288
|
return errors;
|
|
835
1289
|
}
|
|
1290
|
+
function validateFileSearchProviders(providers, fieldPrefix, manifest) {
|
|
1291
|
+
const errors = [];
|
|
1292
|
+
if (providers === undefined)
|
|
1293
|
+
return errors;
|
|
1294
|
+
if (!Array.isArray(providers) || providers.length === 0) {
|
|
1295
|
+
errors.push({ field: fieldPrefix, message: 'must be a non-empty array' });
|
|
1296
|
+
return errors;
|
|
1297
|
+
}
|
|
1298
|
+
if (manifest.type === 'theme') {
|
|
1299
|
+
errors.push({
|
|
1300
|
+
field: fieldPrefix,
|
|
1301
|
+
message: 'Theme extensions must not declare fileSearchProviders',
|
|
1302
|
+
});
|
|
1303
|
+
return errors;
|
|
1304
|
+
}
|
|
1305
|
+
if (!manifest.background?.main) {
|
|
1306
|
+
errors.push({
|
|
1307
|
+
field: 'background.main',
|
|
1308
|
+
message: 'required when manifest declares fileSearchProviders (remote search providers run in the headless worker)',
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
const perms = manifest.permissions ?? [];
|
|
1312
|
+
if (!perms.includes('network')) {
|
|
1313
|
+
errors.push({
|
|
1314
|
+
field: 'permissions',
|
|
1315
|
+
message: 'manifest with fileSearchProviders requires the "network" permission',
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
if (!perms.includes('files:search-provider')) {
|
|
1319
|
+
errors.push({
|
|
1320
|
+
field: 'permissions',
|
|
1321
|
+
message: 'manifest with fileSearchProviders requires the "files:search-provider" permission',
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
const seenIds = new Set();
|
|
1325
|
+
const idRe = /^[a-z0-9_-]{1,64}$/;
|
|
1326
|
+
providers.forEach((item, i) => {
|
|
1327
|
+
const itemPrefix = `${fieldPrefix}[${i}]`;
|
|
1328
|
+
if (!item || typeof item !== 'object') {
|
|
1329
|
+
errors.push({ field: itemPrefix, message: 'must be an object' });
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
const prov = item;
|
|
1333
|
+
if (typeof prov.id !== 'string' || !idRe.test(prov.id)) {
|
|
1334
|
+
errors.push({
|
|
1335
|
+
field: `${itemPrefix}.id`,
|
|
1336
|
+
message: 'must match /^[a-z0-9_-]{1,64}$/',
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
else if (seenIds.has(prov.id)) {
|
|
1340
|
+
errors.push({
|
|
1341
|
+
field: `${itemPrefix}.id`,
|
|
1342
|
+
message: `duplicate file search provider id "${prov.id}"`,
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
else {
|
|
1346
|
+
seenIds.add(prov.id);
|
|
1347
|
+
}
|
|
1348
|
+
if (typeof prov.name !== 'string' || prov.name.trim().length === 0) {
|
|
1349
|
+
errors.push({
|
|
1350
|
+
field: `${itemPrefix}.name`,
|
|
1351
|
+
message: 'must be a non-empty string',
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
if (prov.description !== undefined && typeof prov.description !== 'string') {
|
|
1355
|
+
errors.push({
|
|
1356
|
+
field: `${itemPrefix}.description`,
|
|
1357
|
+
message: 'must be a string',
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
if (prov.icon !== undefined && typeof prov.icon !== 'string') {
|
|
1361
|
+
errors.push({
|
|
1362
|
+
field: `${itemPrefix}.icon`,
|
|
1363
|
+
message: 'must be a string',
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
if (prov.requiresAuth !== undefined && typeof prov.requiresAuth !== 'boolean') {
|
|
1367
|
+
errors.push({
|
|
1368
|
+
field: `${itemPrefix}.requiresAuth`,
|
|
1369
|
+
message: 'must be a boolean',
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
if (prov.defaultEnabled !== undefined && typeof prov.defaultEnabled !== 'boolean') {
|
|
1373
|
+
errors.push({
|
|
1374
|
+
field: `${itemPrefix}.defaultEnabled`,
|
|
1375
|
+
message: 'must be a boolean',
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
return errors;
|
|
1380
|
+
}
|
|
836
1381
|
//# sourceMappingURL=manifest.js.map
|