Skip to content

fix: update chrome extension permissions #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ practices.

<hr />

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

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

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

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification.
Expand Down
36 changes: 18 additions & 18 deletions devtools/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
"manifest_version": 2,
"name": "Testing Playground",
"description": "Simple and complete DOM testing playground that encourage good testing practices.",
"version": "1.0.0",
"version_name": "1.0.0",

"version": "1.0.2",
"version_name": "1.0.2",
"minimum_chrome_version": "49",

"icons": {
"16": "icons/16-production.png",
"32": "icons/32-production.png",
"48": "icons/48-production.png",
"128": "icons/128-production.png"
},

"browser_action": {
"default_icon": {
"16": "icons/16-production.png",
Expand All @@ -22,26 +19,29 @@
"128": "icons/128-production.png"
}
},

"web_accessible_resources": ["window/testing-library.js"],

"web_accessible_resources": [
"window/testing-library.js"
],
"devtools_page": "devtools/main.html",

"content_security_policy": "script-src 'self' 'unsafe-eval' 'sha256-6UcmjVDygSSU8p+3s7E7Kz8EG/ARhPADPRUm9P90HLM='; object-src 'self'",

"background": {
"scripts": ["background/background.js"],
"scripts": [
"background/background.js"
],
"persistent": false
},

"permissions": ["<all_urls>", "activeTab", "clipboardWrite"],

"permissions": [
"clipboardWrite"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content-script/contentScript.js"],
"run_at": "document_start",
"all_frames": true
"matches": [
"<all_urls>"
],
"js": [
"content-script/contentScript.js"
],
"run_at": "document_start"
}
]
}
61 changes: 61 additions & 0 deletions scripts/crxmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

# Purpose: Pack a Chromium extension directory into crx format
# src: https://stackoverflow.com/questions/18693962/pack-chrome-extension-on-server-with-only-command-line-interface

if test $# -ne 2; then
echo "Usage: crxmake.sh <extension dir> <pem path>"
exit 1
fi

dir=$1
key=$2
name=$(basename "$dir")
crx="$name.crx"
pub="$name.pub"
sig="$name.sig"
zip="$name.zip"
tosign="$name.presig"
binary_crx_id="$name.crxid"
trap 'rm -f "$pub" "$sig" "$zip" "$tosign" "$binary_crx_id"' EXIT


# zip up the crx dir
cwd=$(pwd -P)
(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)


#extract crx id
openssl rsa -in "$key" -pubout -outform der | openssl dgst -sha256 -binary -out "$binary_crx_id"
truncate -s 16 "$binary_crx_id"

#generate file to sign
(
# echo "$crmagic_hex $version_hex $header_length $pub_len_hex $sig_len_hex"
printf "CRX3 SignedData"
echo "00 12 00 00 00 0A 10" | xxd -r -p
cat "$binary_crx_id" "$zip"
) > "$tosign"

# signature
openssl dgst -sha256 -binary -sign "$key" < "$tosign" > "$sig"

# public key
openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null


crmagic_hex="43 72 32 34" # Cr24
version_hex="03 00 00 00" # 3
header_length="45 02 00 00"
header_chunk_1="12 AC 04 0A A6 02"
header_chunk_2="12 80 02"
header_chunk_3="82 F1 04 12 0A 10"
(
echo "$crmagic_hex $version_hex $header_length $header_chunk_1" | xxd -r -p
cat "$pub"
echo "$header_chunk_2" | xxd -r -p
cat "$sig"
echo "$header_chunk_3" | xxd -r -p
cat "$binary_crx_id" "$zip"
) > "$crx"
echo "Wrote $crx"