diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..eaeed682
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,5 @@
+* text=auto
+
+*.cmd text eol=crlf
+*.bat text eol=crlf
+*.sh text eol=lf
diff --git a/.gitignore b/.gitignore
index fa3c6e08..c685e391 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..e07341a9
--- /dev/null
+++ b/LICENSE.txt
@@ -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.
diff --git a/README.md b/README.md
index 6b9d2a82..465eedc0 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ $ npm ci
$ npm run build
```
-After that, the `dist` folder will contain all files required by the extension.
+After that, the `dist/PrivacyPass` folder will contain all files required by the extension.
## Development Installation
@@ -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
@@ -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)
diff --git a/dist/.bin/.env/7zip.bat b/dist/.bin/.env/7zip.bat
new file mode 100755
index 00000000..0840f988
--- /dev/null
+++ b/dist/.bin/.env/7zip.bat
@@ -0,0 +1,5 @@
+@echo off
+
+set ZIP7_HOME=C:\PortableApps\7-Zip\16.02\App\7-Zip64
+
+set PATH=%ZIP7_HOME%;%PATH%
diff --git a/dist/.bin/.env/build.bat b/dist/.bin/.env/build.bat
new file mode 100755
index 00000000..7ac1f6bc
--- /dev/null
+++ b/dist/.bin/.env/build.bat
@@ -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%
diff --git a/dist/.bin/.env/build.sh b/dist/.bin/.env/build.sh
new file mode 100755
index 00000000..fb3d1a3b
--- /dev/null
+++ b/dist/.bin/.env/build.sh
@@ -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}"
diff --git a/dist/.bin/.env/build_development.bat b/dist/.bin/.env/build_development.bat
new file mode 100755
index 00000000..c75358d2
--- /dev/null
+++ b/dist/.bin/.env/build_development.bat
@@ -0,0 +1,3 @@
+@echo off
+
+set NODE_ENV=development
diff --git a/dist/.bin/.env/build_development.sh b/dist/.bin/.env/build_development.sh
new file mode 100755
index 00000000..04626cff
--- /dev/null
+++ b/dist/.bin/.env/build_development.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+export NODE_ENV='development'
diff --git a/dist/.bin/.env/build_production.bat b/dist/.bin/.env/build_production.bat
new file mode 100755
index 00000000..e36209d5
--- /dev/null
+++ b/dist/.bin/.env/build_production.bat
@@ -0,0 +1,3 @@
+@echo off
+
+set NODE_ENV=production
diff --git a/dist/.bin/.env/build_production.sh b/dist/.bin/.env/build_production.sh
new file mode 100755
index 00000000..a3f80413
--- /dev/null
+++ b/dist/.bin/.env/build_production.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+export NODE_ENV='production'
diff --git a/dist/.bin/.env/chrome_crx2.bat b/dist/.bin/.env/chrome_crx2.bat
new file mode 100755
index 00000000..cdba0449
--- /dev/null
+++ b/dist/.bin/.env/chrome_crx2.bat
@@ -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%
diff --git a/dist/.bin/.env/chrome_crx2.sh b/dist/.bin/.env/chrome_crx2.sh
new file mode 100755
index 00000000..14a3d46f
--- /dev/null
+++ b/dist/.bin/.env/chrome_crx2.sh
@@ -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}"
diff --git a/dist/.bin/.env/chrome_crx3.bat b/dist/.bin/.env/chrome_crx3.bat
new file mode 100755
index 00000000..b1a8246e
--- /dev/null
+++ b/dist/.bin/.env/chrome_crx3.bat
@@ -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%
diff --git a/dist/.bin/.env/chrome_crx3.sh b/dist/.bin/.env/chrome_crx3.sh
new file mode 100755
index 00000000..905215c7
--- /dev/null
+++ b/dist/.bin/.env/chrome_crx3.sh
@@ -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}"
diff --git a/dist/.bin/.env/constants.bat b/dist/.bin/.env/constants.bat
new file mode 100755
index 00000000..1eae8136
--- /dev/null
+++ b/dist/.bin/.env/constants.bat
@@ -0,0 +1,3 @@
+@echo off
+
+set ext_name=PrivacyPass
diff --git a/dist/.bin/.env/constants.sh b/dist/.bin/.env/constants.sh
new file mode 100755
index 00000000..46ad511c
--- /dev/null
+++ b/dist/.bin/.env/constants.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+export ext_name='PrivacyPass'
diff --git a/dist/.bin/.env/openssl.sh b/dist/.bin/.env/openssl.sh
new file mode 100755
index 00000000..01ced177
--- /dev/null
+++ b/dist/.bin/.env/openssl.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+OPENSSL_HOME='/c/PortableApps/OpenSSL/1.1.0'
+
+export PATH="${OPENSSL_HOME}:${PATH}"
diff --git a/dist/.bin/build/build.bat b/dist/.bin/build/build.bat
new file mode 100755
index 00000000..011d236f
--- /dev/null
+++ b/dist/.bin/build/build.bat
@@ -0,0 +1,12 @@
+@echo off
+
+call "%~dp0..\.env\%~nx0"
+
+cd /D "%~dp0..\..\.."
+
+call npm run build
+
+if not defined BUILD_ALL (
+ echo.
+ pause
+)
diff --git a/dist/.bin/build/build.sh b/dist/.bin/build/build.sh
new file mode 100755
index 00000000..15cc0d49
--- /dev/null
+++ b/dist/.bin/build/build.sh
@@ -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
diff --git a/dist/.bin/build/build_development.bat b/dist/.bin/build/build_development.bat
new file mode 100755
index 00000000..04d8b1ee
--- /dev/null
+++ b/dist/.bin/build/build_development.bat
@@ -0,0 +1,4 @@
+@echo off
+
+call "%~dp0..\.env\%~nx0"
+call "%~dp0.\build.bat"
diff --git a/dist/.bin/build/build_development.sh b/dist/.bin/build/build_development.sh
new file mode 100755
index 00000000..5e442594
--- /dev/null
+++ b/dist/.bin/build/build_development.sh
@@ -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"
diff --git a/dist/.bin/build/build_production.bat b/dist/.bin/build/build_production.bat
new file mode 100755
index 00000000..04d8b1ee
--- /dev/null
+++ b/dist/.bin/build/build_production.bat
@@ -0,0 +1,4 @@
+@echo off
+
+call "%~dp0..\.env\%~nx0"
+call "%~dp0.\build.bat"
diff --git a/dist/.bin/build/build_production.sh b/dist/.bin/build/build_production.sh
new file mode 100755
index 00000000..8f43b00c
--- /dev/null
+++ b/dist/.bin/build/build_production.sh
@@ -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"
diff --git a/dist/.bin/build_all.bat b/dist/.bin/build_all.bat
new file mode 100755
index 00000000..f9ea539f
--- /dev/null
+++ b/dist/.bin/build_all.bat
@@ -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
diff --git a/dist/.bin/build_all.sh b/dist/.bin/build_all.sh
new file mode 100755
index 00000000..9f49190d
--- /dev/null
+++ b/dist/.bin/build_all.sh
@@ -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
diff --git a/dist/.bin/build_all_development.bat b/dist/.bin/build_all_development.bat
new file mode 100755
index 00000000..a41ac5dc
--- /dev/null
+++ b/dist/.bin/build_all_development.bat
@@ -0,0 +1,4 @@
+@echo off
+
+call "%~dp0.\.env\build_development.bat"
+call "%~dp0.\build_all.bat"
diff --git a/dist/.bin/build_all_development.sh b/dist/.bin/build_all_development.sh
new file mode 100755
index 00000000..f6d9b138
--- /dev/null
+++ b/dist/.bin/build_all_development.sh
@@ -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"
diff --git a/dist/.bin/build_all_production.bat b/dist/.bin/build_all_production.bat
new file mode 100755
index 00000000..d710e869
--- /dev/null
+++ b/dist/.bin/build_all_production.bat
@@ -0,0 +1,4 @@
+@echo off
+
+call "%~dp0.\.env\build_production.bat"
+call "%~dp0.\build_all.bat"
diff --git a/dist/.bin/build_all_production.sh b/dist/.bin/build_all_production.sh
new file mode 100755
index 00000000..4197342b
--- /dev/null
+++ b/dist/.bin/build_all_production.sh
@@ -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"
diff --git a/dist/.bin/inject ES6 polyfills/README.md b/dist/.bin/inject ES6 polyfills/README.md
new file mode 100644
index 00000000..49cf612b
--- /dev/null
+++ b/dist/.bin/inject ES6 polyfills/README.md
@@ -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
diff --git a/dist/.bin/inject ES6 polyfills/inject_es6_polyfills.bat b/dist/.bin/inject ES6 polyfills/inject_es6_polyfills.bat
new file mode 100755
index 00000000..65aa1843
--- /dev/null
+++ b/dist/.bin/inject ES6 polyfills/inject_es6_polyfills.bat
@@ -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=