pack-crx 1.0.2 → 1.1.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 +65 -38
- package/build/crx3.pb.d.ts +15 -0
- package/build/index.d.ts +354 -0
- package/build/index.js +113 -0
- package/build/index.js.map +97 -0
- package/package.json +21 -6
- package/bun.lockb +0 -0
- package/src/crx3.pb.js +0 -47
- package/src/index.d.ts +0 -320
- package/src/index.ts +0 -660
- package/tsconfig.json +0 -27
package/package.json
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pack-crx",
|
|
3
|
-
"module": "src/index.ts",
|
|
4
3
|
"type": "module",
|
|
5
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "bun build src/index.ts --outdir build --target node --format esm,cjs",
|
|
7
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
8
|
+
"build:all": "bun run build && bun run build:types"
|
|
9
|
+
},
|
|
10
|
+
"module": "build/index.js",
|
|
11
|
+
"types": "build/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"build"
|
|
14
|
+
],
|
|
6
15
|
"devDependencies": {
|
|
7
16
|
"@types/bun": "latest",
|
|
8
|
-
"@types/node-rsa": "^1.1.4"
|
|
17
|
+
"@types/node-rsa": "^1.1.4",
|
|
18
|
+
"prettier": "^3.8.1",
|
|
19
|
+
"typescript": "^5.9.3"
|
|
9
20
|
},
|
|
10
21
|
"dependencies": {
|
|
11
22
|
"jszip": "^3.10.1",
|
|
12
23
|
"node-rsa": "^1.1.1",
|
|
13
24
|
"pbf": "^4.0.1"
|
|
14
25
|
},
|
|
15
|
-
"types": "src/index.d.ts",
|
|
16
26
|
"license": "MIT",
|
|
17
27
|
"repository": {
|
|
18
28
|
"type": "git",
|
|
@@ -22,5 +32,10 @@
|
|
|
22
32
|
"bugs": {
|
|
23
33
|
"url": "https://github.com/Ant-Throw-Pology/pack-crx"
|
|
24
34
|
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
|
|
35
|
+
"keywords": [
|
|
36
|
+
"crx",
|
|
37
|
+
"crx3",
|
|
38
|
+
"chrome",
|
|
39
|
+
"extension"
|
|
40
|
+
]
|
|
41
|
+
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/src/crx3.pb.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// CrxFileHeader ========================================
|
|
2
|
-
|
|
3
|
-
export var CrxFileHeader = {};
|
|
4
|
-
|
|
5
|
-
CrxFileHeader.read = function (pbf, end) {
|
|
6
|
-
return pbf.readFields(CrxFileHeader._readField, {sha256_with_rsa: [], sha256_with_ecdsa: [], signed_header_data: null}, end);
|
|
7
|
-
};
|
|
8
|
-
CrxFileHeader._readField = function (tag, obj, pbf) {
|
|
9
|
-
if (tag === 2) obj.sha256_with_rsa.push(AsymmetricKeyProof.read(pbf, pbf.readVarint() + pbf.pos));
|
|
10
|
-
else if (tag === 3) obj.sha256_with_ecdsa.push(AsymmetricKeyProof.read(pbf, pbf.readVarint() + pbf.pos));
|
|
11
|
-
else if (tag === 10000) obj.signed_header_data = pbf.readBytes();
|
|
12
|
-
};
|
|
13
|
-
CrxFileHeader.write = function (obj, pbf) {
|
|
14
|
-
if (obj.sha256_with_rsa) for (var i = 0; i < obj.sha256_with_rsa.length; i++) pbf.writeMessage(2, AsymmetricKeyProof.write, obj.sha256_with_rsa[i]);
|
|
15
|
-
if (obj.sha256_with_ecdsa) for (i = 0; i < obj.sha256_with_ecdsa.length; i++) pbf.writeMessage(3, AsymmetricKeyProof.write, obj.sha256_with_ecdsa[i]);
|
|
16
|
-
if (obj.signed_header_data) pbf.writeBytesField(10000, obj.signed_header_data);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// AsymmetricKeyProof ========================================
|
|
20
|
-
|
|
21
|
-
export var AsymmetricKeyProof = {};
|
|
22
|
-
|
|
23
|
-
AsymmetricKeyProof.read = function (pbf, end) {
|
|
24
|
-
return pbf.readFields(AsymmetricKeyProof._readField, {public_key: null, signature: null}, end);
|
|
25
|
-
};
|
|
26
|
-
AsymmetricKeyProof._readField = function (tag, obj, pbf) {
|
|
27
|
-
if (tag === 1) obj.public_key = pbf.readBytes();
|
|
28
|
-
else if (tag === 2) obj.signature = pbf.readBytes();
|
|
29
|
-
};
|
|
30
|
-
AsymmetricKeyProof.write = function (obj, pbf) {
|
|
31
|
-
if (obj.public_key) pbf.writeBytesField(1, obj.public_key);
|
|
32
|
-
if (obj.signature) pbf.writeBytesField(2, obj.signature);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// SignedData ========================================
|
|
36
|
-
|
|
37
|
-
export var SignedData = {};
|
|
38
|
-
|
|
39
|
-
SignedData.read = function (pbf, end) {
|
|
40
|
-
return pbf.readFields(SignedData._readField, {crx_id: null}, end);
|
|
41
|
-
};
|
|
42
|
-
SignedData._readField = function (tag, obj, pbf) {
|
|
43
|
-
if (tag === 1) obj.crx_id = pbf.readBytes();
|
|
44
|
-
};
|
|
45
|
-
SignedData.write = function (obj, pbf) {
|
|
46
|
-
if (obj.crx_id) pbf.writeBytesField(1, obj.crx_id);
|
|
47
|
-
};
|
package/src/index.d.ts
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import type NodeRSA from "node-rsa";
|
|
2
|
-
|
|
3
|
-
interface ChromeBaseManifest {
|
|
4
|
-
// Required keys
|
|
5
|
-
manifest_version: number;
|
|
6
|
-
name: string;
|
|
7
|
-
version: string;
|
|
8
|
-
|
|
9
|
-
// Required by Chrome Web Store
|
|
10
|
-
description?: string;
|
|
11
|
-
icons?: {[x: `${number}`]: string};
|
|
12
|
-
|
|
13
|
-
// Optional
|
|
14
|
-
author?: string;
|
|
15
|
-
background?: {
|
|
16
|
-
service_worker?: string;
|
|
17
|
-
type?: "module";
|
|
18
|
-
};
|
|
19
|
-
chrome_settings_overrides?: {
|
|
20
|
-
alternate_urls?: string[];
|
|
21
|
-
encoding?: string;
|
|
22
|
-
favicon_url?: string;
|
|
23
|
-
homepage?: string;
|
|
24
|
-
image_url?: string;
|
|
25
|
-
image_url_post_params?: string;
|
|
26
|
-
is_default?: boolean;
|
|
27
|
-
keyword?: string;
|
|
28
|
-
name?: string;
|
|
29
|
-
prepopulated_id?: number;
|
|
30
|
-
search_provider?: object;
|
|
31
|
-
search_url?: string;
|
|
32
|
-
search_url_post_params?: string;
|
|
33
|
-
startup_pages?: string[];
|
|
34
|
-
suggest_url?: string;
|
|
35
|
-
suggest_url_post_params?: string;
|
|
36
|
-
};
|
|
37
|
-
chrome_url_overrides?: {
|
|
38
|
-
bookmarks?: string;
|
|
39
|
-
history?: string;
|
|
40
|
-
newtab?: string;
|
|
41
|
-
};
|
|
42
|
-
commands?: {
|
|
43
|
-
[x: string]: {
|
|
44
|
-
description: string;
|
|
45
|
-
suggested_key?: string;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
content_scripts?: {
|
|
49
|
-
matches: string[];
|
|
50
|
-
css?: string[];
|
|
51
|
-
js?: string[];
|
|
52
|
-
run_at?: "document_start" | "document_end" | "document_idle";
|
|
53
|
-
match_about_blank?: boolean;
|
|
54
|
-
match_origin_as_fallback?: boolean;
|
|
55
|
-
world?: "ISOLATED" | "MAIN";
|
|
56
|
-
}[];
|
|
57
|
-
content_security_policy?: {
|
|
58
|
-
extension_pages?: string;
|
|
59
|
-
sandbox?: string;
|
|
60
|
-
};
|
|
61
|
-
cross_origin_embedder_policy?: string;
|
|
62
|
-
cross_origin_opener_policy?: string;
|
|
63
|
-
declarative_net_request?: {
|
|
64
|
-
rule_resources?: {
|
|
65
|
-
id: string;
|
|
66
|
-
enabled: boolean;
|
|
67
|
-
path: string;
|
|
68
|
-
}[];
|
|
69
|
-
};
|
|
70
|
-
default_locale?: string;
|
|
71
|
-
devtools_page?: string;
|
|
72
|
-
export?: {
|
|
73
|
-
allowlist?: string[];
|
|
74
|
-
};
|
|
75
|
-
externally_connectable?: {
|
|
76
|
-
ids?: string[];
|
|
77
|
-
matches?: string[];
|
|
78
|
-
accepts_tls_channel_id?: boolean;
|
|
79
|
-
};
|
|
80
|
-
homepage_url?: string;
|
|
81
|
-
host_permissions?: string[];
|
|
82
|
-
import?: {
|
|
83
|
-
id: string;
|
|
84
|
-
minimum_version?: string;
|
|
85
|
-
}[];
|
|
86
|
-
incognito?: "spanning" | "split" | "not_allowed";
|
|
87
|
-
key?: string;
|
|
88
|
-
minimum_chrome_version?: string;
|
|
89
|
-
oauth2?: {
|
|
90
|
-
client_id: string;
|
|
91
|
-
scopes: string[];
|
|
92
|
-
};
|
|
93
|
-
omnibox?: {
|
|
94
|
-
keyword?: string;
|
|
95
|
-
};
|
|
96
|
-
optional_host_permissions?: string[];
|
|
97
|
-
optional_permissions?: string[];
|
|
98
|
-
options_page?: string;
|
|
99
|
-
options_ui?: {
|
|
100
|
-
page: string;
|
|
101
|
-
open_in_tab?: boolean;
|
|
102
|
-
};
|
|
103
|
-
permissions?: string[];
|
|
104
|
-
requirements?: {
|
|
105
|
-
[x: string]: {features: string[]};
|
|
106
|
-
};
|
|
107
|
-
sandbox?: {
|
|
108
|
-
pages: string[];
|
|
109
|
-
};
|
|
110
|
-
short_name?: string;
|
|
111
|
-
side_panel?: string;
|
|
112
|
-
storage?: {
|
|
113
|
-
managed_schema?: string;
|
|
114
|
-
};
|
|
115
|
-
tts_engine?: {
|
|
116
|
-
voices?: {
|
|
117
|
-
voice_name: string;
|
|
118
|
-
lang?: string;
|
|
119
|
-
event_types?: ("start" | "word" | "sentence" | "marker" | "end" | "error")[];
|
|
120
|
-
}[];
|
|
121
|
-
};
|
|
122
|
-
update_url?: string;
|
|
123
|
-
version_name?: string;
|
|
124
|
-
web_accessible_resources?: ({
|
|
125
|
-
resources: string[];
|
|
126
|
-
} & ({
|
|
127
|
-
matches: string[];
|
|
128
|
-
} | {
|
|
129
|
-
extension_ids: string[];
|
|
130
|
-
}))[];
|
|
131
|
-
|
|
132
|
-
// ChromeOS
|
|
133
|
-
file_browser_handlers?: {
|
|
134
|
-
id: string;
|
|
135
|
-
default_title: string;
|
|
136
|
-
file_filters: string[];
|
|
137
|
-
}[];
|
|
138
|
-
file_handlers?: {
|
|
139
|
-
action: string;
|
|
140
|
-
name: string;
|
|
141
|
-
accept: {
|
|
142
|
-
[x: string]: string[];
|
|
143
|
-
};
|
|
144
|
-
launch_type?: "single-client" | "multiple-clients";
|
|
145
|
-
}[];
|
|
146
|
-
file_system_provider_capabilities?: {
|
|
147
|
-
configurable?: boolean;
|
|
148
|
-
multiple_mounts?: boolean;
|
|
149
|
-
watchable?: boolean;
|
|
150
|
-
source: "file" | "device" | "network";
|
|
151
|
-
};
|
|
152
|
-
input_components?: {
|
|
153
|
-
name: string;
|
|
154
|
-
id?: string;
|
|
155
|
-
language?: string | string[];
|
|
156
|
-
layouts?: string | string[];
|
|
157
|
-
input_view?: string;
|
|
158
|
-
options_page?: string;
|
|
159
|
-
}[];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type ChromeMV2Manifest = ChromeBaseManifest & {
|
|
163
|
-
manifest_version: 2;
|
|
164
|
-
browser_action?: {
|
|
165
|
-
default_icon?: {[x: `${number}`]: string};
|
|
166
|
-
default_title?: string;
|
|
167
|
-
default_popup?: string;
|
|
168
|
-
};
|
|
169
|
-
page_action?: {
|
|
170
|
-
default_icon?: {[x: `${number}`]: string};
|
|
171
|
-
default_title?: string;
|
|
172
|
-
default_popup?: string;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export type ChromeMV3Manifest = ChromeBaseManifest & {
|
|
177
|
-
manifest_version: 3;
|
|
178
|
-
action?: {
|
|
179
|
-
default_icon?: {[x: `${number}`]: string};
|
|
180
|
-
default_title?: string;
|
|
181
|
-
default_popup?: string;
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
export type ChromeManifest = ChromeMV2Manifest | ChromeMV3Manifest;
|
|
186
|
-
|
|
187
|
-
export interface CrxFileHeader {
|
|
188
|
-
sha256_with_rsa?: AsymmetricKeyProof[];
|
|
189
|
-
sha256_with_ecdsa?: AsymmetricKeyProof[];
|
|
190
|
-
signed_header_data?: Uint8Array;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export interface AsymmetricKeyProof {
|
|
194
|
-
public_key?: Uint8Array;
|
|
195
|
-
signature?: Uint8Array;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function packCrx2(privateKey: Uint8Array, publicKey: Uint8Array, contents: Uint8Array, rsa?: NodeRSA): Uint8Array;
|
|
199
|
-
export function packCrx3(privateKey: Uint8Array, publicKey: Uint8Array, contents: Uint8Array, rsa?: NodeRSA): Uint8Array;
|
|
200
|
-
export function generateCrxId(publicKey: Uint8Array): string;
|
|
201
|
-
export function packContents(where: string): Promise<{
|
|
202
|
-
/** The ZIP-encoded data. */
|
|
203
|
-
contents: Uint8Array,
|
|
204
|
-
/** The manifest for the extension, parsed as JSON. */
|
|
205
|
-
manifest: ChromeManifest
|
|
206
|
-
}>;
|
|
207
|
-
export function generateUpdateXML(crxId: string, url: string, version: string, minChromeVersion?: string): string;
|
|
208
|
-
export function generatePrivateKey(bits?: number): Uint8Array;
|
|
209
|
-
export function generatePublicKey(privateKey: Uint8Array): Uint8Array;
|
|
210
|
-
export function convertToPem(key: Uint8Array, type: "private" | "public"): string;
|
|
211
|
-
export function convertFromPem(key: string, type: "private" | "public"): Uint8Array;
|
|
212
|
-
export function unpack(crx: Uint8Array): {
|
|
213
|
-
/** The ZIP data. */
|
|
214
|
-
archive: Uint8Array,
|
|
215
|
-
/** The CRX format version. */
|
|
216
|
-
crxVersion: 2,
|
|
217
|
-
/** The extension's public key. */
|
|
218
|
-
key: Uint8Array,
|
|
219
|
-
/** The signature over the contents of the extension. */
|
|
220
|
-
sign: Uint8Array
|
|
221
|
-
} | {
|
|
222
|
-
/** The ZIP data. */
|
|
223
|
-
archive: Uint8Array,
|
|
224
|
-
/** The CRX format version. */
|
|
225
|
-
crxVersion: 3,
|
|
226
|
-
/** The header for the CRX file, for signatures and things. */
|
|
227
|
-
header: CrxFileHeader
|
|
228
|
-
};
|
|
229
|
-
export interface PackInput {
|
|
230
|
-
/** The ZIP archive of the contents of the extension, or a path to the folder containing the extension. */
|
|
231
|
-
contents?: Uint8Array | string;
|
|
232
|
-
/** The private key for the extension, or a path to it. */
|
|
233
|
-
privateKey?: Uint8Array | string | null;
|
|
234
|
-
/** The size of key to generate, if needed. */
|
|
235
|
-
keySize?: number;
|
|
236
|
-
/** The public key for the extension, or a path to it. */
|
|
237
|
-
publicKey?: Uint8Array | string | null;
|
|
238
|
-
/** The instance of NodeRSA to use. */
|
|
239
|
-
rsa?: NodeRSA;
|
|
240
|
-
/** The extension's ID. */
|
|
241
|
-
id?: string | null;
|
|
242
|
-
/** The outputted CRX file. */
|
|
243
|
-
crx?: Uint8Array | null;
|
|
244
|
-
/** The CRX format version to use. Defaults to 3. */
|
|
245
|
-
crxVersion?: number;
|
|
246
|
-
/** The URL to where the CRX file (not the updates XML) will be hosted. */
|
|
247
|
-
crxUrl?: string;
|
|
248
|
-
/** The [updates XML file](https://developer.chrome.com/docs/extensions/how-to/distribute/host-on-linux). */
|
|
249
|
-
updateXML?: string | null;
|
|
250
|
-
/** The extension's version. */
|
|
251
|
-
extVersion?: string | null;
|
|
252
|
-
/** The minimum Chrome version the extension requires. */
|
|
253
|
-
minChromeVersion?: string | null;
|
|
254
|
-
/** The extension's [manifest](https://developer.chrome.com/docs/extensions/reference/manifest). */
|
|
255
|
-
manifest?: ChromeManifest | null;
|
|
256
|
-
}
|
|
257
|
-
type SetKeys<A extends object, B extends object> = {[x in keyof A | keyof B]: x extends keyof B ? unknown extends B[x] ? x extends keyof A ? A[x] : never : B[x] : x extends keyof A ? A[x] : never};
|
|
258
|
-
|
|
259
|
-
export type TransformPack<I extends PackInput> =
|
|
260
|
-
I["privateKey"] extends string ?
|
|
261
|
-
TransformPack<SetKeys<I, {
|
|
262
|
-
privateKey: Uint8Array | undefined;
|
|
263
|
-
rsa: NodeRSA;
|
|
264
|
-
}>>
|
|
265
|
-
: I["publicKey"] extends string ?
|
|
266
|
-
TransformPack<SetKeys<I, {
|
|
267
|
-
publicKey: Uint8Array | undefined;
|
|
268
|
-
}>>
|
|
269
|
-
: I["updateXML"] extends null ?
|
|
270
|
-
undefined extends I["crxUrl"] ? never : TransformPack<SetKeys<I, {
|
|
271
|
-
updateXML: string;
|
|
272
|
-
id: undefined extends I["id"] ? null : I["id"];
|
|
273
|
-
extVersion: undefined extends I["extVersion"] ? null : I["extVersion"];
|
|
274
|
-
minChromeVersion: undefined extends I["minChromeVersion"] ? null : I["minChromeVersion"];
|
|
275
|
-
}>>
|
|
276
|
-
: I["extVersion"] extends null ?
|
|
277
|
-
TransformPack<SetKeys<I, {
|
|
278
|
-
extVersion: string;
|
|
279
|
-
manifest: undefined extends I["manifest"] ? null : I["manifest"];
|
|
280
|
-
}>>
|
|
281
|
-
: I["minChromeVersion"] extends null ?
|
|
282
|
-
TransformPack<SetKeys<I, {
|
|
283
|
-
minChromeVersion: string | undefined;
|
|
284
|
-
manifest: undefined extends I["manifest"] ? null : I["manifest"];
|
|
285
|
-
}>>
|
|
286
|
-
: I["manifest"] extends null ?
|
|
287
|
-
undefined extends I["contents"] ? never
|
|
288
|
-
: Uint8Array extends I["contents"] ? never
|
|
289
|
-
: TransformPack<SetKeys<I, {
|
|
290
|
-
manifest: ChromeManifest;
|
|
291
|
-
}>>
|
|
292
|
-
: I["crx"] extends null ?
|
|
293
|
-
undefined extends I["contents"] ? never : TransformPack<SetKeys<I, {
|
|
294
|
-
crx: Uint8Array;
|
|
295
|
-
privateKey: undefined extends I["privateKey"] ? null : I["privateKey"];
|
|
296
|
-
publicKey: undefined extends I["publicKey"] ? null : I["publicKey"];
|
|
297
|
-
}>>
|
|
298
|
-
: I["id"] extends null ?
|
|
299
|
-
TransformPack<SetKeys<I, {
|
|
300
|
-
id: string;
|
|
301
|
-
publicKey: undefined extends I["publicKey"] ? null : I["publicKey"];
|
|
302
|
-
}>>
|
|
303
|
-
: I["publicKey"] extends null ?
|
|
304
|
-
TransformPack<SetKeys<I, {
|
|
305
|
-
publicKey: Uint8Array;
|
|
306
|
-
privateKey: undefined extends I["privateKey"] ? null : I["privateKey"];
|
|
307
|
-
}>>
|
|
308
|
-
: I["privateKey"] extends null ?
|
|
309
|
-
TransformPack<SetKeys<I, {
|
|
310
|
-
privateKey: Uint8Array;
|
|
311
|
-
rsa: NodeRSA;
|
|
312
|
-
}>>
|
|
313
|
-
: I["contents"] extends string ?
|
|
314
|
-
TransformPack<SetKeys<I, {
|
|
315
|
-
contents: Uint8Array;
|
|
316
|
-
manifest: ChromeManifest;
|
|
317
|
-
}>>
|
|
318
|
-
: I;
|
|
319
|
-
export function pack<I extends PackInput>(options: I): Promise<TransformPack<I>>;
|
|
320
|
-
export default pack;
|