Skip to content
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

lots of various improvements.. #283

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1931272
minor configuration updates
warren-bank Jan 13, 2022
a623dee
work in progress..
warren-bank Jan 14, 2022
59e01e2
work in progress..
warren-bank Jan 14, 2022
c9b0c40
work in progress..
warren-bank Jan 14, 2022
6af07f7
work in progress..
warren-bank Jan 15, 2022
4b7beb1
work in progress..
warren-bank Jan 15, 2022
70ec3f1
work in progress..
warren-bank Jan 15, 2022
06222cc
work in progress..
warren-bank Jan 16, 2022
a4e23fb
work in progress..
warren-bank Jan 16, 2022
00cba76
v3.3.0 w/ Cloudflare and hCaptcha providers
warren-bank Jan 16, 2022
6fe4c6c
update jest configs for testing and fix all tests to pass
warren-bank Jan 17, 2022
578a97b
v3.3.1 w/ minified ES5
warren-bank Jan 17, 2022
929cabd
v3.3.2 w/ minified ES5
warren-bank Jan 18, 2022
b9df538
minor configuration updates
warren-bank Jan 18, 2022
cf7144c
refactor and improve the dist/.bin build scripts
warren-bank Jan 20, 2022
2f3fad0
work in progress..
warren-bank Jan 20, 2022
e101fc7
hCaptcha sends issuing requests from 'onCompleted' hook function
warren-bank Jan 20, 2022
615f189
minor css tweak to popup window
warren-bank Jan 21, 2022
37a5271
minor updates to the 'dist/.bin' build scripts
warren-bank Jan 22, 2022
706a9e7
minor updates to the 'dist/.bin' build scripts
warren-bank Jan 26, 2022
baa5e80
add popup menu buttons to backup and restore tokens in local storage
warren-bank Jan 26, 2022
b889333
minor updates to the 'dist/.bin' build scripts
warren-bank Jan 26, 2022
8d57b84
fix hCaptcha redemption
warren-bank Jan 27, 2022
1f84b01
minor refactoring
warren-bank Jan 27, 2022
bf6d1ae
address race-condition: delay blocking async code by next-tick timer
warren-bank Jan 28, 2022
48f5e14
revert hCaptcha and refactor Cloudflare
warren-bank Jan 28, 2022
71e4b54
detect and fix incorrect requests on Cloudflare issuing domain
warren-bank Jan 29, 2022
3e39527
fix: use feature detection so browser compatability isn't reduced
warren-bank Jan 29, 2022
84ea20b
fix a conditional statement that may effect Cloudflare token issuing
warren-bank Jan 30, 2022
29febe8
minor refactoring
warren-bank Jan 30, 2022
8283f46
add static helper method: "getNormalizedFormData"
warren-bank Jan 31, 2022
0ab56ce
fix the ability to restore tokens from a JSON text file
warren-bank Feb 1, 2022
7057859
add i18n translations using IBM Watson Language Translator service
warren-bank Feb 24, 2022
6ee36f8
minor html/css tweak to popup window
warren-bank Feb 24, 2022
333f32b
accomodate for changes to Cloudflare provider backend
warren-bank Mar 20, 2022
ad517dd
CF: normalize name of querystring parameter in request to issue tokens
warren-bank Mar 20, 2022
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto

*.cmd text eol=crlf
*.bat text eol=crlf
*.sh text eol=lf
15 changes: 12 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/node_modules/
/lib/

/dist/lib/
/dist/PrivacyPass/
/dist/PrivacyPass.pem
/dist/PrivacyPass.crx*
/dist/PrivacyPass.xpi
/dist/.bin/**/temp/

/public/_locales/debug.en.txt

*.swp
/node_modules
/dist
/lib
26 changes: 26 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2017-2020, Privacy Pass Team, Cloudflare, Inc., and other contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ npm ci
$ npm run build
```

After that, the `dist` folder will contain all files required by the extension.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the name to PrivacyPass? I think the name PrivacyPass doesn't indicate that the files in the directory are generated files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because when Chrome is used to pack an extension, both the name of the .crx and the .pem are expected to be the same as the input directory (all siblings)..

.gitignore allows the .pem to be permanently homed where Chrome expects it to be.. without ever being commit to version control.. and likewise, the generated .crx and .xpi files won't either

this naming convention is associated with the scripts in the .bin directory.. if you already have tools that you use to package your extensions, then.. you:

  1. won't want/need the .bin directory
    • though I find these scripts useful
  2. won't want to rename the output directory.. as you tooling will already be configured to use the old path

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option.. which might be preferable.. would be to:

  • move the .bin directory to dist/.bin
  • configure webpack to output to dist/PrivacyPass
  • configure .gitignore to exclude: dist/PrivacyPass and dist/PrivacyPass.[pem|crx|xpi]

so all output.. and my scripts to pack the output into extensions.. would be confined under dist

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update:
That last suggestion seemed (to me) as a much cleaner option.. so I just pushed a commit to make those changes.

After that, the `dist/PrivacyPass` folder will contain all files required by the extension.

## Development Installation

Expand All @@ -47,7 +47,7 @@ After that, the `dist` folder will contain all files required by the extension.
- Build by following the [Build Instruction](#build-instruction).
- Open Firefox and go to `about:debugging#/runtime/this-firefox`.
- Click on 'Load Temporary Add-on' button.
- Select `manifest.json` from `dist` folder.
- Select `manifest.json` from `dist/PrivacyPass` folder.
- Check extension logo appears in the top-right corner and 0 passes
are stored (by clicking on it).
- Go to a web page supporting Privacy Pass where internet challenges
Expand All @@ -68,7 +68,7 @@ After that, the `dist` folder will contain all files required by the extension.
- Open Chrome and go to `chrome://extensions`.
- Turn on the Developer mode on the top-right corner.
- Click on 'Load unpacked' button.
- Select the `dist` folder.
- Select the `dist/PrivacyPass` folder.
- Check extension logo appears in the top-right corner and follow
the same instruction as in Firefox. (If you cannot see the extension logo,
it's probably just not pinned to the toolbar yest)
Expand Down
5 changes: 5 additions & 0 deletions dist/.bin/.env/7zip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off

set ZIP7_HOME=C:\PortableApps\7-Zip\16.02\App\7-Zip64

set PATH=%ZIP7_HOME%;%PATH%
6 changes: 6 additions & 0 deletions dist/.bin/.env/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off

set PERL_HOME=C:\PortableApps\perl\5.10.1
set MAKE_HOME=C:\PortableApps\make

set PATH=%PERL_HOME%;%MAKE_HOME%;%PATH%
6 changes: 6 additions & 0 deletions dist/.bin/.env/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

PERL_HOME='/c/PortableApps/perl/5.10.1'
MAKE_HOME='/c/PortableApps/make'

export PATH="${PERL_HOME}:${MAKE_HOME}:${PATH}"
3 changes: 3 additions & 0 deletions dist/.bin/.env/build_development.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

set NODE_ENV=development
3 changes: 3 additions & 0 deletions dist/.bin/.env/build_development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

export NODE_ENV='development'
3 changes: 3 additions & 0 deletions dist/.bin/.env/build_production.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

set NODE_ENV=production
3 changes: 3 additions & 0 deletions dist/.bin/.env/build_production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

export NODE_ENV='production'
10 changes: 10 additions & 0 deletions dist/.bin/.env/chrome_crx2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

rem :: ===============================
rem :: version of Chrome < 64.0.3242.0
rem :: ===============================
rem :: https://sourceforge.net/projects/portableapps/files/Iron%20Portable/
rem :: https://sourceforge.net/projects/portableapps/files/Iron%20Portable/IronPortable_61.0.3200.0.paf.exe/download
set CHROME_HOME=C:\PortableApps\SRWare Iron\61.0.3200.0\App\Iron

set PATH=%CHROME_HOME%;%PATH%
10 changes: 10 additions & 0 deletions dist/.bin/.env/chrome_crx2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# ===============================
# version of Chrome < 64.0.3242.0
# ===============================
# https://sourceforge.net/projects/portableapps/files/Iron%20Portable/
# https://sourceforge.net/projects/portableapps/files/Iron%20Portable/IronPortable_61.0.3200.0.paf.exe/download
CHROME_HOME='/c/PortableApps/SRWare Iron/61.0.3200.0/App/Iron'

export PATH="${CHROME_HOME}:${PATH}"
16 changes: 16 additions & 0 deletions dist/.bin/.env/chrome_crx3.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off

rem :: ================================
rem :: version of Chrome >= 64.0.3242.0
rem :: ================================
rem :: https://sourceforge.net/projects/portableapps/files/Google%20Chrome%20Portable/
rem :: https://sourceforge.net/projects/portableapps/files/Google%20Chrome%20Portable/GoogleChromePortable64_97.0.4692.71_online.paf.exe/download
set CHROME_HOME=C:\PortableApps\Google Chrome\97.0.4692.71\App\Chrome-bin
rem :: https://sourceforge.net/projects/portableapps/files/Iron%20Portable/
rem :: https://sourceforge.net/projects/portableapps/files/Iron%20Portable/IronPortable_85.0.4350.0.paf.exe/download
set CHROME_HOME=C:\PortableApps\SRWare Iron\85.0.4350.0\App\Iron
rem :: http://download1.srware.net/old/
rem :: http://download1.srware.net/old/iron/win/85/IronPortable64.exe
set CHROME_HOME=C:\PortableApps\SRWare Iron\85.0.4350.0\Iron

set PATH=%CHROME_HOME%;%PATH%
16 changes: 16 additions & 0 deletions dist/.bin/.env/chrome_crx3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# ================================
# version of Chrome >= 64.0.3242.0
# ================================
# https://sourceforge.net/projects/portableapps/files/Google%20Chrome%20Portable/
# https://sourceforge.net/projects/portableapps/files/Google%20Chrome%20Portable/GoogleChromePortable64_97.0.4692.71_online.paf.exe/download
CHROME_HOME='/c/PortableApps/Google Chrome/97.0.4692.71/App/Chrome-bin'
# https://sourceforge.net/projects/portableapps/files/Iron%20Portable/
# https://sourceforge.net/projects/portableapps/files/Iron%20Portable/IronPortable_85.0.4350.0.paf.exe/download
CHROME_HOME='/c/PortableApps/SRWare Iron/85.0.4350.0/App/Iron'
# http://download1.srware.net/old/
# http://download1.srware.net/old/iron/win/85/IronPortable64.exe
CHROME_HOME='/c/PortableApps/SRWare Iron/85.0.4350.0/Iron'

export PATH="${CHROME_HOME}:${PATH}"
3 changes: 3 additions & 0 deletions dist/.bin/.env/constants.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

set ext_name=PrivacyPass
3 changes: 3 additions & 0 deletions dist/.bin/.env/constants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

export ext_name='PrivacyPass'
5 changes: 5 additions & 0 deletions dist/.bin/.env/openssl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

OPENSSL_HOME='/c/PortableApps/OpenSSL/1.1.0'

export PATH="${OPENSSL_HOME}:${PATH}"
12 changes: 12 additions & 0 deletions dist/.bin/build/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off

call "%~dp0..\.env\%~nx0"

cd /D "%~dp0..\..\.."

call npm run build

if not defined BUILD_ALL (
echo.
pause
)
9 changes: 9 additions & 0 deletions dist/.bin/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "${DIR}/../.env/build.sh"

cd "${DIR}/../../.."

npm run build
4 changes: 4 additions & 0 deletions dist/.bin/build/build_development.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

call "%~dp0..\.env\%~nx0"
call "%~dp0.\build.bat"
6 changes: 6 additions & 0 deletions dist/.bin/build/build_development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "${DIR}/../.env/build_development.sh"
source "${DIR}/build.sh"
4 changes: 4 additions & 0 deletions dist/.bin/build/build_production.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

call "%~dp0..\.env\%~nx0"
call "%~dp0.\build.bat"
6 changes: 6 additions & 0 deletions dist/.bin/build/build_production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "${DIR}/../.env/build_production.sh"
source "${DIR}/build.sh"
13 changes: 13 additions & 0 deletions dist/.bin/build_all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off

set BUILD_ALL=1

call "%~dp0.\build\build.bat"
call "%~dp0.\pack extensions\chromium\crx3\pack_crx3_with_chrome.bat"
call "%~dp0.\pack extensions\firefox\pack_xpi_with_7zip.bat"

call "%~dp0.\inject ES6 polyfills\inject_es6_polyfills.bat"
call "%~dp0.\pack extensions\chromium\crx2\pack_crx2_with_chrome.bat"

echo.
pause
32 changes: 32 additions & 0 deletions dist/.bin/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# ------------------------------------------------------------------------------
# configuration

# 'USE_OPENSSL' determines how CRX2 and CRX3 extensions are built
# - any non-empty value will use:
# OpenSSL
# - an empty value will use:
# 2x different versions of Chrome
# 1x older for CRX2: < 64.0.3242.0
# 1x newer for CRX3: >= 64.0.3242.0
USE_OPENSSL='1'

# ------------------------------------------------------------------------------

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

"${DIR}/build/build.sh"
if [ -n "$USE_OPENSSL" ];then
"${DIR}/pack extensions/chromium/crx3/pack_crx3_with_openssl.sh"
else
"${DIR}/pack extensions/chromium/crx3/pack_crx3_with_chrome.sh"
fi
"${DIR}/pack extensions/firefox/pack_xpi_with_zip.sh"

"${DIR}/inject ES6 polyfills/inject_es6_polyfills.sh"
if [ -n "$USE_OPENSSL" ];then
"${DIR}/pack extensions/chromium/crx2/pack_crx2_with_openssl.sh"
else
"${DIR}/pack extensions/chromium/crx2/pack_crx2_with_chrome.sh"
fi
4 changes: 4 additions & 0 deletions dist/.bin/build_all_development.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

call "%~dp0.\.env\build_development.bat"
call "%~dp0.\build_all.bat"
6 changes: 6 additions & 0 deletions dist/.bin/build_all_development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "${DIR}/.env/build_development.sh"
source "${DIR}/build_all.sh"
4 changes: 4 additions & 0 deletions dist/.bin/build_all_production.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

call "%~dp0.\.env\build_production.bat"
call "%~dp0.\build_all.bat"
6 changes: 6 additions & 0 deletions dist/.bin/build_all_production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "${DIR}/.env/build_production.sh"
source "${DIR}/build_all.sh"
6 changes: 6 additions & 0 deletions dist/.bin/inject ES6 polyfills/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### ES6 Polyfills

* adds [core-js](https://github.com/zloirock/core-js) to both the [background](../../../public/manifest.json) and [popup](../../../public/popup.html) pages
- using a local copy of a recent browser build, which was saved from [cdnjs](https://cdnjs.com/libraries/core-js)
* only needed to add support for very old browsers, which do not understand features that have since been added to the javascript (aka: ecmascript) scripting language
- for Chrome, this is only recommended for extensions packed in CRX2 format
74 changes: 74 additions & 0 deletions dist/.bin/inject ES6 polyfills/inject_es6_polyfills.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@echo off
setlocal enabledelayedexpansion

call "%~dp0..\.env\constants.bat"
call "%~dp0..\.env\build.bat"

if not defined ext_name (
echo script configuration is invalid:
echo missing name of browser extension
exit /b 1
)

set ext_dir="%~dp0..\..\%ext_name%"

if not exist %ext_dir% (
echo Extension directory does not exist.
echo Perhaps the Typescript compiler build failed?
echo Quitting without making any changes.
exit /b 1
)

cd /D %ext_dir%

if exist "%cd%\lib" (
echo "lib" directory already exists in extension directory.
echo Has polyfill has already been injected?
echo Quitting without making any changes.
exit /b 1
)

xcopy /E /I /Q "%~dp0.\lib" "lib"

set filepath=manifest.json
set "old_text="background.js""
set "new_text="lib/core-js.js", "background.js""
set flags=
call :perform_file_search_replace "%filepath%" "!old_text!" "!new_text!" "%flags%"

set filepath=popup.html
set "old_text=<script"
set "new_text=<script src="lib/core-js.js"></script><script"
set flags=
call :perform_file_search_replace "%filepath%" "!old_text!" "!new_text!" "%flags%"

goto :done

:perform_file_search_replace
set filepath=%~1
set old_text=%2
set new_text=%3
set flags=%~4

rem :: trim double-quotes from text without using shell because ~N variable expansion breaks when string contains certain special characters
set old_text=!old_text:~1,-1!
set new_text=!new_text:~1,-1!

rem :: https://stackoverflow.com/a/1258256
rem :: add backslash to escape double-quotes in text, or perl won't see them
set old_text=!old_text:"=\"!
set new_text=!new_text:"=\"!

perl -pi.bak -e "s|!old_text!|!new_text!|%flags%" "%filepath%"

if exist "%filepath%.bak" del "%filepath%.bak"
goto :eof

:done

if not defined BUILD_ALL (
echo.
pause
)

endlocal
Loading