Skip to content

Commit f45d6e4

Browse files
authored
fix: update chrome extension permissions (#177)
1 parent 4db92db commit f45d6e4

File tree

3 files changed

+82
-18
lines changed

3 files changed

+82
-18
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ practices.
1212

1313
<hr />
1414

15+
<!-- prettier-ignore-start -->
1516
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
1617
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
1718
<!-- ALL-CONTRIBUTORS-BADGE:END -->
19+
<!-- prettier-ignore-end -->
1820

1921
**Playground for [testing-library/dom]**
2022

@@ -124,6 +126,7 @@ Thanks goes to these people ([emoji key][emojis]):
124126

125127
<!-- markdownlint-enable -->
126128
<!-- prettier-ignore-end -->
129+
127130
<!-- ALL-CONTRIBUTORS-LIST:END -->
128131

129132
This project follows the [all-contributors][all-contributors] specification.

devtools/src/manifest.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
"manifest_version": 2,
33
"name": "Testing Playground",
44
"description": "Simple and complete DOM testing playground that encourage good testing practices.",
5-
"version": "1.0.0",
6-
"version_name": "1.0.0",
7-
5+
"version": "1.0.2",
6+
"version_name": "1.0.2",
87
"minimum_chrome_version": "49",
9-
108
"icons": {
119
"16": "icons/16-production.png",
1210
"32": "icons/32-production.png",
1311
"48": "icons/48-production.png",
1412
"128": "icons/128-production.png"
1513
},
16-
1714
"browser_action": {
1815
"default_icon": {
1916
"16": "icons/16-production.png",
@@ -22,26 +19,29 @@
2219
"128": "icons/128-production.png"
2320
}
2421
},
25-
26-
"web_accessible_resources": ["window/testing-library.js"],
27-
22+
"web_accessible_resources": [
23+
"window/testing-library.js"
24+
],
2825
"devtools_page": "devtools/main.html",
29-
3026
"content_security_policy": "script-src 'self' 'unsafe-eval' 'sha256-6UcmjVDygSSU8p+3s7E7Kz8EG/ARhPADPRUm9P90HLM='; object-src 'self'",
31-
3227
"background": {
33-
"scripts": ["background/background.js"],
28+
"scripts": [
29+
"background/background.js"
30+
],
3431
"persistent": false
3532
},
36-
37-
"permissions": ["<all_urls>", "activeTab", "clipboardWrite"],
38-
33+
"permissions": [
34+
"clipboardWrite"
35+
],
3936
"content_scripts": [
4037
{
41-
"matches": ["<all_urls>"],
42-
"js": ["content-script/contentScript.js"],
43-
"run_at": "document_start",
44-
"all_frames": true
38+
"matches": [
39+
"<all_urls>"
40+
],
41+
"js": [
42+
"content-script/contentScript.js"
43+
],
44+
"run_at": "document_start"
4545
}
4646
]
4747
}

scripts/crxmake.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Purpose: Pack a Chromium extension directory into crx format
4+
# src: https://stackoverflow.com/questions/18693962/pack-chrome-extension-on-server-with-only-command-line-interface
5+
6+
if test $# -ne 2; then
7+
echo "Usage: crxmake.sh <extension dir> <pem path>"
8+
exit 1
9+
fi
10+
11+
dir=$1
12+
key=$2
13+
name=$(basename "$dir")
14+
crx="$name.crx"
15+
pub="$name.pub"
16+
sig="$name.sig"
17+
zip="$name.zip"
18+
tosign="$name.presig"
19+
binary_crx_id="$name.crxid"
20+
trap 'rm -f "$pub" "$sig" "$zip" "$tosign" "$binary_crx_id"' EXIT
21+
22+
23+
# zip up the crx dir
24+
cwd=$(pwd -P)
25+
(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
26+
27+
28+
#extract crx id
29+
openssl rsa -in "$key" -pubout -outform der | openssl dgst -sha256 -binary -out "$binary_crx_id"
30+
truncate -s 16 "$binary_crx_id"
31+
32+
#generate file to sign
33+
(
34+
# echo "$crmagic_hex $version_hex $header_length $pub_len_hex $sig_len_hex"
35+
printf "CRX3 SignedData"
36+
echo "00 12 00 00 00 0A 10" | xxd -r -p
37+
cat "$binary_crx_id" "$zip"
38+
) > "$tosign"
39+
40+
# signature
41+
openssl dgst -sha256 -binary -sign "$key" < "$tosign" > "$sig"
42+
43+
# public key
44+
openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
45+
46+
47+
crmagic_hex="43 72 32 34" # Cr24
48+
version_hex="03 00 00 00" # 3
49+
header_length="45 02 00 00"
50+
header_chunk_1="12 AC 04 0A A6 02"
51+
header_chunk_2="12 80 02"
52+
header_chunk_3="82 F1 04 12 0A 10"
53+
(
54+
echo "$crmagic_hex $version_hex $header_length $header_chunk_1" | xxd -r -p
55+
cat "$pub"
56+
echo "$header_chunk_2" | xxd -r -p
57+
cat "$sig"
58+
echo "$header_chunk_3" | xxd -r -p
59+
cat "$binary_crx_id" "$zip"
60+
) > "$crx"
61+
echo "Wrote $crx"

0 commit comments

Comments
 (0)