Skip to content

Commit

Permalink
Merge 'master' into feat/brave-build-with-chrome-sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Mar 13, 2019
2 parents 6ffb723 + fb5cfae commit cf1147a
Show file tree
Hide file tree
Showing 55 changed files with 2,717 additions and 1,972 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ vendor
build
coverage/
node_modules
add-on/dist
firefox
package-lock.json
58 changes: 19 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
language: node_js
node_js:
- "lts/*"
sudo: false
env:
global:
- secure: "LUZnP+lhVj0zbFe/tSppMvI6jaXyOos84WZehPImMeara9/RRrRk5QpKsUsqr1x/oHzElJnbAX9OD/GOuEI4fyYv9qBXr8CKxBpmjlM2ElY85WcGm9mntRXtvR0iscR3Jg9kPtUBqzVlh1E/mQjs5GR2nLn0Fe34Xwl6TWd3m6c="
- DISPLAY=':99.0'
- FIREFOX_BINARY='./firefox/firefox'
- PATH="./firefox/:${PATH}"
- CXX=g++-4.8
# matrix:
# - FIREFOX_RELEASE='latest'
# - FIREFOX_RELEASE='nightly-latest'
# - FIREFOX_RELEASE='52.0'
# - FIREFOX_RELEASE='esr-latest'

# pulled in by node-webcrypto-ossl@1.0.7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8

- 10.15.1
matrix:
fast_finish: true
# allow_failures:
# - env: FIREFOX_RELEASE='nightly-latest'
# - env: FIREFOX_RELEASE='esr-latest'
allow_failures:
- os: windows
cache:
directories:
- node_modules
#before_script:
# - test $FIREFOX_RELEASE != nightly-latest || wget -O firefox-$FIREFOX_RELEASE.tar.bz2 "https://download.mozilla.org/?product=firefox-$FIREFOX_RELEASE&os=linux64&lang=en-US"
# - test $FIREFOX_RELEASE != latest || wget -O firefox-$FIREFOX_RELEASE.tar.bz2 "https://download.mozilla.org/?product=firefox-$FIREFOX_RELEASE&os=linux64&lang=en-US"
# - test $FIREFOX_RELEASE != '55.0' || wget -O firefox-$FIREFOX_RELEASE.tar.bz2 "https://download.mozilla.org/?product=firefox-$FIREFOX_RELEASE&os=linux64&lang=en-US"
# - test $FIREFOX_RELEASE != esr-latest || wget -O firefox-$FIREFOX_RELEASE.tar.bz2 "https://download.mozilla.org/?product=firefox-$FIREFOX_RELEASE&os=linux64&lang=en-US"
# - tar xvf firefox-$FIREFOX_RELEASE.tar.bz2
# - sh -e /etc/init.d/xvfb start
- npm
- yarn
os:
- linux
- osx
- windows
addons:
homebrew:
packages: jq
install:
- npm run yarn-build
- npm run ci:install
script:
- npm test
- npm run lint
- npm run ci:build
- npm run ci:test
- npm run ci:lint
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
notifications:
email: false
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

29 changes: 22 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
FROM node:10.11.0
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ENV PATH="/usr/src/app/node_modules/.bin:${PATH}"
FROM node:10.15.1

ARG USER_ID
ARG GROUP_ID

RUN curl -s https://ipfs.io/ipfs/QmbukYcmtyU6ZEKt6fepnvrTNa9F6VqsUPMUgNxQjEmphH > /usr/local/bin/jq && chmod +x /usr/local/bin/jq
COPY package.json /usr/src/app/package.json
COPY yarn.lock /usr/src/app/yarn.lock

RUN mkdir -p /home/node/app
WORKDIR /home/node/app

COPY . /home/node/app

RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
userdel -f node && \
if getent group node ; then groupdel node; fi && \
groupadd -g ${GROUP_ID} node && \
useradd -l -u ${USER_ID} -g node node && \
chown -fhR ${USER_ID}:${GROUP_ID} /home/node; fi

USER node

RUN npm run ci:install
COPY . /usr/src/app

ENV PATH="/home/node/app/node_modules/.bin:${PATH}"
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[![](https://img.shields.io/github/release/ipfs/ipfs-companion.svg)](https://github.com/ipfs/ipfs-companion/releases/latest)
[![](https://img.shields.io/badge/mozilla-reviewed-blue.svg)](https://addons.mozilla.org/en-US/firefox/addon/ipfs-companion/)
[![i18n status](https://img.shields.io/badge/i18n-translated-blue.svg)](https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/localization-notes.md)
[![build-status](https://img.shields.io/jenkins/s/http/ci.ipfs.team/job/IPFS%20Shipyard/job/ipfs-companion/job/master.svg)](https://ci.ipfs.team/blue/organizations/jenkins/IPFS%20Shipyard%2Fipfs-companion/activity?branch=master)
[![build-status](https://flat.badgen.net/travis/ipfs-shipyard/ipfs-companion)](https://travis-ci.com/ipfs-shipyard/ipfs-companion)
[![codecov](https://codecov.io/gh/ipfs-shipyard/ipfs-companion/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs-shipyard/ipfs-companion)
[![#ipfs-in-web-browsers](https://img.shields.io/badge/irc-%23ipfs--in--web--browsers-808080.svg)](https://webchat.freenode.net/?channels=ipfs-in-web-browsers)

| <img src="https://unpkg.com/@browser-logos/firefox@2.0.0/firefox_16x16.png" width="16" height="16"> [Firefox](https://www.mozilla.org/firefox/new/) / [Firefox for Android](https://play.google.com/store/apps/details?id=org.mozilla.firefox) | <img src="https://unpkg.com/@browser-logos/chrome@1.0.4/chrome_16x16.png" width="16" height="16"> [Chrome](https://www.google.com/chrome/) / <img src="https://unpkg.com/@browser-logos/brave@3.0.0/brave_16x16.png" width="16" height="16"> [Brave](https://brave.com/) / <img src="https://unpkg.com/@browser-logos/opera@1.1.1/opera_16x16.png" width="16" height="16"> [Opera](https://www.opera.com/)
Expand All @@ -25,6 +26,7 @@
- [Install](#install)
- [Contribute](#contribute)
- [Troubleshooting](#troubleshooting)
- [Privacy Policy](#privacy-policy)
- [License](#license)

## Background
Expand Down Expand Up @@ -67,9 +69,10 @@ More details: [`x-ipfs-path` Header Support in IPFS Companion](https://github.co

#### Redirect Opt-Out

It is possible to opt-out from redirect by
a) suspending extension via global toggle
b) including `x-ipfs-companion-no-redirect` in the URL (as a [hash](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR#x-ipfs-companion-no-redirect) or [query](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-companion-no-redirect) parameter).
It is possible to opt-out from Gateway redirect by:
- a) suspending redirect via global toggle (see [_Disable All Redirects_](#disable-all-redirects) below)
- b) suspending redirect for via per website opt-out (in [_Active Tab_ section of _Browser Action_](#disable-gateway-redirect-per-website) or _Preferences_)
- c) including `x-ipfs-companion-no-redirect` in the URL (as a [hash](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR#x-ipfs-companion-no-redirect) or [query](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-companion-no-redirect) parameter).

### IPFS API as `window.ipfs`

Expand All @@ -78,11 +81,30 @@ Websites can detect if `window.ipfs` exists and opt-in to use it instead of crea
It saves system resources and battery (on mobile), avoids the overhead of peer discovery/connection, enables shared repository access and more!
Make sure to read our [notes on `window.ipfs`](https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/window.ipfs.md), where we explain it in-depth and provide examples on how to use it your own dapp.

### Toggle IPFS Integrations
### Quick Toggles

> ![screenshot of suspend toggle](https://user-images.githubusercontent.com/157609/42685002-18c7cee4-8692-11e8-9171-970866d91ae0.gif)
The Browser Action pop-up provides handy toggles for often used operations.

The Browser Action pop-up provides a toggle for suspending all active IPFS integrations with a single click.
#### Disable Gateway Redirect Per Website

> _Active Tab_ actions include option to opt-out current website from Gateway redirect of any IPFS subresources.
> Disabling redirect for DNSLink website will restore original URL as well:
>
> ![per-site-peek 2019-02-26 00-23](https://user-images.githubusercontent.com/157609/53376094-86557500-395d-11e9-837f-a4712aa19236.gif)
#### Disable All Redirects

> A handy toggle to disable all gateway redirects while keeping all other features enabled:
>
> ![redirect](https://user-images.githubusercontent.com/157609/53376263-0976cb00-395e-11e9-8536-d83d28ffeee9.gif)
#### Suspend IPFS Extension

> The "power" icon can be used to temporarily suspend all IPFS integrations
> (redirects, API status, content scripts, protocol handlers etc).
> Useful during testing. Extension can be re-enabled with a single click:
>
> ![screenshot of suspend toggle](https://user-images.githubusercontent.com/157609/53376196-d6343c00-395d-11e9-83f2-04c16b3a008f.gif)
### IPFS Status and Context Actions

Expand All @@ -100,7 +122,7 @@ The Browser Action pop-up provides a toggle for suspending all active IPFS integ
_(some are disabled by default, use Preferences screen to enable)_

- Requests made via [experimental protocols](https://github.com/ipfs/ipfs-companion/issues/164) are re-routed to HTTP gateway (public or custom):
- `ipns://$cid`
- `ipfs://$cid`
- `ipns://$cid_or_fqdn`
- `dweb:/ipfs/$cid`
- `dweb:/ipns/$cid_or_fqdn`
Expand Down Expand Up @@ -235,6 +257,10 @@ Deny
Feel free to modify it, but get familiar with [ABE rule syntax](https://noscript.net/abe/abe_rules.pdf) first.
## Privacy Policy
See [`docs/privacy-policy.md`](docs/privacy-policy.md)
## License
[IPFS logo](https://github.com/ipfs/logo) belongs to [The IPFS Project](https://github.com/ipfs) and is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/legalcode">CC-BY-SA 3.0</a>.
Expand Down
6 changes: 3 additions & 3 deletions add-on/_locales/da/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"description": "An option description on the Preferences screen (option_customGatewayUrl_description)"
},
"option_customGatewayUrl_warning": {
"message": "IPFS content will be blocked from loading on HTTPS websites unless your gateway URL starts with “http://127.0.0.1”, “http://[::1]” or “https://”",
"message": "IPFS indhold vil være blokeret for download via HTTPS websider med mindre din gateway URL begynder med “http://127.0.0.1”, “http://[::1]” eller “https://”",
"description": "A warning on the Preferences screen, displayed when URL does not belong to Secure Context (option_customGatewayUrl_warning)"
},
"option_useCustomGateway_title": {
Expand Down Expand Up @@ -464,11 +464,11 @@
"description": "Button title for revoking a permission (page_proxyAcl_revoke_button_title)"
},
"page_proxyAccessDialog_title": {
"message": "Should IPFS Companion allow «$1» to access «$2» at the connected node?",
"message": "Bør IPFS Følgesvend tillade «$1» at tilgå «$2» for den forbundne klient?",
"description": "Main title of the access permission dialog (page_proxyAccessDialog_title)"
},
"page_proxyAccessDialog_wildcardCheckbox_label": {
"message": "Apply this decision to all current and future permissions in this scope",
"message": "Anvend denne beslutning for alle nuværende og fremtidige rettigheder for dette anvendelsesområde",
"description": "Label for the apply permissions to all checkbox (page_proxyAccessDialog_wildcardCheckbox_label)"
},
"page_proxyAcl_revoke_all_button_title": {
Expand Down
44 changes: 34 additions & 10 deletions add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "A label for IPFS icon (panel_headerIpfsNodeIconLabel)"
},
"panel_headerActiveToggleTitle": {
"message": "Global toggle: Suspend all IPFS integrations",
"message": "Toggle all IPFS integrations",
"description": "A label for an embedded IPFS node (panel_headerActiveToggleTitle)"
},
"panel_statusOffline": {
Expand Down Expand Up @@ -43,25 +43,41 @@
"message": "Open Web UI",
"description": "A menu item in Browser Action pop-up (panel_openWebui)"
},
"panel_redirectToggle": {
"message": "Redirect to Gateway",
"description": "A menu item in Browser Action pop-up (panel_redirectToggle)"
},
"panel_redirectToggleTooltip": {
"message": "Click to toggle all gateway redirects",
"description": "A menu item in Browser Action pop-up (panel_redirectToggleTooltip)"
},
"panel_toolsSectionHeader": {
"message": "Tools",
"description": "A menu item in Browser Action pop-up (panel_toolsSectionHeader)"
},
"panel_openPreferences": {
"message": "Open Preferences of Browser Extension",
"description": "A menu item in Browser Action pop-up (panel_openPreferences)"
},
"panel_switchToCustomGateway": {
"message": "Switch to Custom Gateway",
"description": "A menu item in Browser Action pop-up (panel_switchToCustomGateway)"
"panel_activeTabSectionHeader": {
"message": "Active Tab",
"description": "A menu item in Browser Action pop-up (panel_activeTabSiteRedirectEnable)"
},
"panel_switchToPublicGateway": {
"message": "Switch to Public Gateway",
"description": "A menu item in Browser Action pop-up (panel_switchToPublicGateway)"
"panel_activeTabSiteRedirectToggle": {
"message": "Redirect on $1",
"description": "A menu item in Browser Action pop-up (panel_activeTabSiteRedirectToggle)"
},
"panel_activeTabSiteRedirectToggleTooltip": {
"message": "Click to toggle gateway redirects on $1",
"description": "A menu item tooltip in Browser Action pop-up (panel_activeTabSiteRedirectToggleTooltip)"
},
"panel_pinCurrentIpfsAddress": {
"message": "Pin IPFS Resource",
"description": "A menu item in Browser Action pop-up (panel_pinCurrentIpfsAddress)"
},
"panel_unpinCurrentIpfsAddress": {
"message": "Unpin IPFS Resource",
"description": "A menu item in Browser Action pop-up (panel_unpinCurrentIpfsAddress)"
"panel_pinCurrentIpfsAddressTooltip": {
"message": "Pinning a CID tells your IPFS node that this data is important and mustn’t be thrown away.",
"description": "A menu item tooltip in Browser Action pop-up (panel_pinCurrentIpfsAddressTooltip)"
},
"panelCopy_currentIpfsAddress": {
"message": "Copy IPFS Path",
Expand Down Expand Up @@ -251,6 +267,14 @@
"message": "Redirect requests for IPFS resources to the Custom gateway",
"description": "An option description on the Preferences screen (option_useCustomGateway_description)"
},
"option_noRedirectHostnames_title": {
"message": "Redirect Opt-Outs",
"description": "An option title on the Preferences screen (option_noRedirectHostnames_title)"
},
"option_noRedirectHostnames_description": {
"message": "List of websites that should not be redirected to the Custom Gateway (includes subresources from other domains). One hostname per line.",
"description": "An option description on the Preferences screen (option_noRedirectHostnames_description)"
},
"option_publicGatewayUrl_title": {
"message": "Default Public Gateway",
"description": "An option title on the Preferences screen (option_publicGatewayUrl_title)"
Expand Down
2 changes: 1 addition & 1 deletion add-on/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
"description": "Ready message copy (page_landingWelcome_welcome_discover)"
},
"page_landingWelcome_installSteps_title": {
"message": "Is your IPFS daemon running?",
"message": "Служба IPFS запущена?",
"description": "Install steps title (page_landingWelcome_installSteps_title)"
},
"page_landingWelcome_installSteps_install": {
Expand Down
10 changes: 5 additions & 5 deletions add-on/_locales/sv/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"description": "A generic placeholder for error notification (notify_inlineErrorMsg)"
},
"notify_startIpfsNodeErrorTitle": {
"message": "Det gick inte att starta IPFS noden",
"message": "Det gick inte att starta IPFS-noden",
"description": "System notification title displayed when starting an IPFS node fails (notify_startIpfsNodeErrorTitle)"
},
"notify_stopIpfsNodeErrorTitle": {
Expand Down Expand Up @@ -240,7 +240,7 @@
"description": "An option description on the Preferences screen (option_customGatewayUrl_description)"
},
"option_customGatewayUrl_warning": {
"message": "IPFS content will be blocked from loading on HTTPS websites unless your gateway URL starts with “http://127.0.0.1”, “http://[::1]” or “https://",
"message": "IPFS-innehåll kommer blockeras från att laddas på HTTPS-webbsidor om inte gateway-URL:en börjar med \"http://127.0.0.1\", \"http://[::1]\" eller \"https://\"",
"description": "A warning on the Preferences screen, displayed when URL does not belong to Secure Context (option_customGatewayUrl_warning)"
},
"option_useCustomGateway_title": {
Expand Down Expand Up @@ -268,7 +268,7 @@
"description": "An option title on the Preferences screen (option_ipfsApiUrl_title)"
},
"option_ipfsApiUrl_description": {
"message": "Hint: this is where /api/v0/config lives",
"message": "Tips: här finns /api/v0/config",
"description": "An option description on the Preferences screen (option_ipfsApiUrl_description)"
},
"option_ipfsApiPollMs_title": {
Expand Down Expand Up @@ -464,11 +464,11 @@
"description": "Button title for revoking a permission (page_proxyAcl_revoke_button_title)"
},
"page_proxyAccessDialog_title": {
"message": "Should IPFS Companion allow «$1» to access «$2» at the connected node?",
"message": "Ska IPFS-kompanjonen tillåta «$1» åtkomst till «$2» på den kopplade noden?",
"description": "Main title of the access permission dialog (page_proxyAccessDialog_title)"
},
"page_proxyAccessDialog_wildcardCheckbox_label": {
"message": "Apply this decision to all current and future permissions in this scope",
"message": "Tillämpa detta beslut för alla nuvarande och framtida behörigheter i denna omfattning.",
"description": "Label for the apply permissions to all checkbox (page_proxyAccessDialog_wildcardCheckbox_label)"
},
"page_proxyAcl_revoke_all_button_title": {
Expand Down
2 changes: 1 addition & 1 deletion add-on/manifest.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_manifest_extensionName__",
"short_name": "__MSG_manifest_shortExtensionName__",
"version": "2.7.0",
"version": "2.7.5",
"description": "__MSG_manifest_extensionDescription__",
"homepage_url": "https://github.com/ipfs-shipyard/ipfs-companion",
"author": "IPFS Community",
Expand Down
20 changes: 8 additions & 12 deletions add-on/src/lib/copier.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const { safeIpfsPath, trimHashAndSearch } = require('./ipfs-path')
const { findValueForContext } = require('./context-menus')

async function copyTextToClipboard (text, notify) {
Expand Down Expand Up @@ -32,21 +31,19 @@ async function copyTextToClipboard (text, notify) {
}
}

function createCopier (getState, getIpfs, notify) {
function createCopier (notify, ipfsPathValidator) {
return {
async copyCanonicalAddress (context, contextType) {
const url = await findValueForContext(context, contextType)
const rawIpfsAddress = safeIpfsPath(url)
await copyTextToClipboard(rawIpfsAddress, notify)
const ipfsPath = ipfsPathValidator.resolveToIpfsPath(url)
await copyTextToClipboard(ipfsPath, notify)
},

async copyRawCid (context, contextType) {
const url = await findValueForContext(context, contextType)
try {
const ipfs = getIpfs()
const url = await findValueForContext(context, contextType)
const rawIpfsAddress = trimHashAndSearch(safeIpfsPath(url))
const directCid = (await ipfs.resolve(rawIpfsAddress, { recursive: true, dhtt: '5s', dhtrc: 1 })).split('/')[2]
await copyTextToClipboard(directCid, notify)
const cid = await ipfsPathValidator.resolveToCid(url)
await copyTextToClipboard(cid, notify)
} catch (error) {
console.error('Unable to resolve/copy direct CID:', error.message)
if (notify) {
Expand All @@ -65,9 +62,8 @@ function createCopier (getState, getIpfs, notify) {

async copyAddressAtPublicGw (context, contextType) {
const url = await findValueForContext(context, contextType)
const state = getState()
const urlAtPubGw = url.replace(state.gwURLString, state.pubGwURLString)
await copyTextToClipboard(urlAtPubGw, notify)
const publicUrl = ipfsPathValidator.resolveToPublicUrl(url)
await copyTextToClipboard(publicUrl, notify)
}
}
}
Expand Down
Loading

0 comments on commit cf1147a

Please sign in to comment.