Skip to content

Commit c4bbf39

Browse files
committed
Merge branch 'release/1.3.0' into released
2 parents c4bb16b + 66e0f53 commit c4bbf39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1240
-578
lines changed

Diff for: .circleci/config.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Clone @holoflows/kit
1515
command: |
1616
cd ..
17-
git clone -q --depth=1 https://github.com/project-holoflows/holoflows-kit
17+
git clone -q --depth=1 https://github.com/DimensionDev/holoflows-kit
1818
- restore_cache:
1919
keys:
2020
- v1-holoflows-{{ checksum "~/holoflows-kit/yarn.lock" }}
@@ -83,8 +83,14 @@ jobs:
8383
set -o nounset
8484
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -b "✔ No breaking changes. / ⚠ Has breaking changes!
8585
86+
🆕 New Feature
87+
88+
🔐 Security
89+
8690
🎨 UI Improvements
8791
92+
🐛 Bug Fixes
93+
8894
👩‍💻 Miscellaneous" -replace -draft -prerelease $(git describe HEAD) ~/repo/Maskbook.zip
8995
# -b BODY \ # Set text describing the contents of the release
9096
# -delete \ # Delete release and its git tag in advance if it exists (same as -recreate)

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
.vscode/launch.json
3+
.vscode/tasks.json
24
/.awcache
35
/.tscache
6+
public/polyfill
47
# dependencies
58
/node_modules
69
/.pnp

Diff for: .storybook/webpack.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module.exports = ({ config }) => {
55
{
66
loader: require.resolve('awesome-typescript-loader'),
77
},
8-
{
9-
loader: require.resolve('react-docgen-typescript-loader'),
10-
},
118
],
129
})
1310
config.resolve.extensions.push('.ts', '.tsx')

Diff for: .vscode/launch.json

-15
This file was deleted.

Diff for: README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Maskbook · ![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square) ![Ciecle CI](https://img.shields.io/circleci/project/github/DimensionDev/Maskbook.svg?style=flat-square&logo=circleci) [![Join the chat at https://gitter.im/Maskbook/community](https://badges.gitter.im/Maskbook/community.svg)](https://gitter.im/Maskbook/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![Chrome Web Store](https://img.shields.io/chrome-web-store/v/jkoeaghipilijlahjplgbfiocjhldnap.svg?logo=Maskbook&logoColor=%231c68f3&style=flat-square)
22

3-
43
Encrypt your posts & chats on You-Know-Where. Allow only your friends to decrypt.
54

65
For general introductions, see https://Maskbook.io/
@@ -28,7 +27,7 @@ After `Maskbook` and `@holoflows/kit` gets stable, we will directly add `@holofl
2827
#### Prepare for library @holoflows/kit
2928

3029
- `cd ..`
31-
- `git clone https://github.com/project-holoflows/Holoflows-kit.git`
30+
- `git clone https://github.com/DimensionDev/holoflows-kit.git`
3231
- `cd Holoflows-kit`
3332
- `yarn install`
3433
- `yarn build`

Diff for: config-overrides.js

+37-18
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,60 @@
11
const path = require('path')
22

3-
process.env.NODE_ENV = 'development'
4-
const env = process.env.NODE_ENV
5-
process.env.GENERATE_SOURCEMAP = (env === 'development') + ''
3+
process.env.BROWSER = 'none'
64
module.exports = function override(/** @type{import("webpack").Configuration} */ config, env) {
5+
// CSP bans eval
6+
// And non-inline source-map not working
77
if (env === 'development') config.devtool = 'inline-source-map'
88
config.entry = {
99
app: path.join(__dirname, './src/index.tsx'),
1010
contentscript: path.join(__dirname, './src/content-script.ts'),
1111
backgroundservice: path.join(__dirname, './src/background-service.ts'),
1212
injectedscript: path.join(__dirname, './src/extension/injected-script/index.ts'),
1313
}
14-
config.output.filename = 'static/js/[name].js'
15-
config.output.chunkFilename = 'static/js/[name].chunk.js'
14+
config.output.filename = 'js/[name].js'
15+
config.output.chunkFilename = 'js/[name].chunk.js'
16+
17+
// Leads a loading failure in background service
1618
config.optimization.runtimeChunk = false
1719
config.optimization.splitChunks = undefined
1820

21+
// Dismiss warning for gun.js
1922
config.module.wrappedContextCritical = false
2023
config.module.exprContextCritical = false
2124
config.module.unknownContextCritical = false
2225

23-
// @ts-ignore
2426
config.plugins.push(
2527
new (require('write-file-webpack-plugin'))({
26-
test: /(static\/.*|.+\.png|index\.html|manifest\.json)/,
28+
test: /(webp|jpg|png|shim|polyfill|js\/.*|index\.html|manifest\.json)/,
2729
}),
2830
)
2931
// Write files to /public
30-
config.plugins.push(
31-
new (require('copy-webpack-plugin'))(
32-
[
33-
{
34-
from: path.join(__dirname, './public'),
35-
to: path.join(__dirname, './dist'),
36-
},
37-
],
38-
{ ignore: ['*.html'] },
39-
),
40-
)
32+
const polyfills = [
33+
'node_modules/construct-style-sheets-polyfill/adoptedStyleSheets.js',
34+
'node_modules/webextension-polyfill/dist/browser-polyfill.min.js',
35+
'node_modules/webextension-polyfill/dist/browser-polyfill.min.js.map',
36+
'node_modules/webcrypto-liner/dist/webcrypto-liner.shim.js',
37+
]
38+
const public = path.join(__dirname, './public')
39+
const publicPolyfill = path.join(__dirname, './public/polyfill')
40+
const dist = path.join(__dirname, './dist')
41+
if (env === 'development') {
42+
config.plugins.push(
43+
new (require('copy-webpack-plugin'))(
44+
[...polyfills.map(from => ({ from, to: publicPolyfill })), { from: public, to: dist }],
45+
{ ignore: ['*.html'] },
46+
),
47+
)
48+
} else {
49+
const fs = require('fs')
50+
if (!fs.existsSync(publicPolyfill)) fs.mkdirSync(publicPolyfill)
51+
polyfills.map(x =>
52+
fs.copyFile(x, path.join(publicPolyfill, path.basename(x)), err => {
53+
if (err) throw err
54+
}),
55+
)
56+
}
57+
// Let webpack build to es2017 instead of es5
4158
for (const x of config.module.rules) {
4259
if (!x.oneOf) continue
4360
for (const rule of x.oneOf) {
@@ -61,6 +78,8 @@ module.exports = function override(/** @type{import("webpack").Configuration} */
6178
})
6279
// Disable the eslint linter. We have tslint.
6380
config.module.rules = config.module.rules.filter(x => x.enforce !== 'pre')
81+
// write-file-webpack-plugin conflict with this
82+
// ! Don't upgrade webpack to 5 until they fix this
6483
config.output.futureEmitAssets = false
6584
return config
6685
}

Diff for: package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"name": "maskbook",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"private": true,
55
"dependencies": {
66
"@material-ui/core": "^3.9.2",
77
"@material-ui/icons": "^3.0.2",
8-
"@types/chrome": "^0.0.83",
98
"@types/classnames": "^2.2.7",
109
"@types/gun": "^0.9.1",
1110
"@types/jest": "^24.0.6",
@@ -14,9 +13,10 @@
1413
"@types/react": "16.8.14",
1514
"@types/react-dom": "16.8.4",
1615
"@types/react-jss": "^8.6.3",
16+
"@types/react-router-dom": "^4.3.2",
1717
"@types/tiny-secp256k1": "^1.0.0",
1818
"classnames": "^2.2.6",
19-
"construct-style-sheets-polyfill": "^1.0.3",
19+
"construct-style-sheets-polyfill": "^2.0.1",
2020
"copy-webpack-plugin": "^5.0.0",
2121
"elliptic": "^6.4.1",
2222
"gun": "0.2019.422",
@@ -28,6 +28,7 @@
2828
"react-app-rewired": "^2.1.0",
2929
"react-dom": "^16.8.3",
3030
"react-jss": "^8.6.1",
31+
"react-router-dom": "^5.0.0",
3132
"react-scripts": "3.0.0",
3233
"reflect-metadata": "^0.1.13",
3334
"storybook-addon-material-ui": "0.9.0-alpha.18",
@@ -36,7 +37,9 @@
3637
"tslint": "^5.16.0",
3738
"typed-db": "^1.0.1-1",
3839
"typescript": "^3.4.4",
40+
"web-ext-types": "^3.1.0",
3941
"webcrypto-liner": "0.1.38",
42+
"webextension-polyfill": "^0.4.0",
4043
"write-file-webpack-plugin": "^4.5.0"
4144
},
4245
"scripts": {
@@ -68,7 +71,6 @@
6871
"@types/storybook__addon-knobs": "^5.0.0",
6972
"@types/storybook__addon-links": "^3.3.4",
7073
"@types/storybook__react": "^4.0.1",
71-
"awesome-typescript-loader": "^5.2.1",
72-
"react-docgen-typescript-loader": "^3.1.0"
74+
"awesome-typescript-loader": "^5.2.1"
7375
}
7476
}

Diff for: public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4+
<script src="polyfill/browser-polyfill.min.js"></script>
45
<meta charset="utf-8" />
56
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
67
<style>
@@ -17,5 +18,6 @@
1718
</head>
1819
<body>
1920
<div id="root"></div>
21+
<script src="polyfill/adoptedStyleSheets.js"></script>
2022
</body>
2123
</html>

Diff for: public/manifest.json

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
{
22
"$schema": "http://json.schemastore.org/chrome-manifest",
33
"name": "Maskbook",
4-
"version": "1.2.0",
4+
"version": "1.3.0",
55
"manifest_version": 2,
66
"content_scripts": [
77
{
88
"matches": ["https://www.facebook.com/*"],
9-
"js": ["/static/js/contentscript.js"],
9+
"js": ["polyfill/adoptedStyleSheets.js", "polyfill/browser-polyfill.min.js", "js/contentscript.js"],
1010
"run_at": "document_idle",
1111
"all_frames": true
12-
},
13-
{
14-
"matches": ["https://www.facebook.com/*"],
15-
"js": ["/static/js/injectedscript.js"],
16-
"run_at": "document_start",
17-
"all_frames": true
1812
}
1913
],
2014
"web_accessible_resources": ["*.css", "*.js", "*.jpg", "*.png"],
21-
"permissions": ["https://*.facebook.com/*", "storage", "downloads", "background"],
15+
"permissions": ["https://www.facebook.com/*", "storage", "downloads", "background", "webNavigation"],
2216
"background": {
23-
"scripts": ["/static/js/backgroundservice.js"]
17+
"scripts": ["polyfill/webcrypto-liner.shim.js", "polyfill/browser-polyfill.min.js", "js/backgroundservice.js"]
2418
},
2519
"options_ui": {
26-
"page": "/index.html",
27-
"open_in_tab": true,
28-
"chrome_style": true
20+
"page": "index.html",
21+
"open_in_tab": true
2922
},
3023
"icons": {
31-
"16": "/16x16.png",
32-
"48": "/48x48.png",
33-
"128": "/128x128.png",
34-
"256": "/256x256.png"
24+
"16": "16x16.png",
25+
"48": "48x48.png",
26+
"128": "128x128.png",
27+
"256": "256x256.png"
3528
},
3629
"homepage_url": "https://maskbook.io",
3730
"description": "Encrypt your posts & chats on You-Know-Where. Allow only your friends to decrypt."

Diff for: src/background-service.ts

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
export default undefined
2-
if (
3-
location.href === 'http://localhost:3000/' ||
4-
(location.protocol === 'chrome-extension:' && location.pathname === '/index.html')
5-
) {
6-
} else {
7-
require('./extension/background-script')
1+
import './extension/service'
2+
import { backgroundSetup } from './setup'
3+
import { GetContext } from '@holoflows/kit/es'
4+
backgroundSetup()
5+
6+
if (GetContext() === 'background') {
7+
const script = `{
8+
const script = document.createElement('script')
9+
script.src = "${browser.runtime.getURL('js/injectedscript.js')}"
10+
document.documentElement.appendChild(script)
11+
}`
12+
browser.webNavigation.onCommitted.addListener(
13+
async arg => {
14+
try {
15+
await browser.tabs.executeScript(arg.tabId, {
16+
runAt: 'document_start',
17+
frameId: arg.frameId,
18+
code: script,
19+
})
20+
} catch (e) {
21+
if (e.message.match('non-structured-clonable data')) {
22+
// It's okay we don't need the result, happened on Firefox
23+
} else if (e.message.match('Frame not found, or missing host permission')) {
24+
// It's maybe okay, happened on Firefox
25+
} else console.error('Inject error', e, arg, browser.runtime.getURL('js/injectedscript.js'))
26+
}
27+
},
28+
{ url: [{ hostEquals: 'www.facebook.com' }] },
29+
)
830
}

Diff for: src/components/DataSource/PeopleRef.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import React from 'react'
22
import { Person } from '../../extension/background-script/PeopleService'
33
import { ValueRef } from '@holoflows/kit/es'
44
import { MessageCenter } from '../../utils/messages'
5-
import { PeopleService } from '../../extension/content-script/rpc'
5+
import Services from '../../extension/service'
66

77
const ref = new ValueRef<Person[]>([])
8-
PeopleService.queryPeople().then(p => (ref.value = p))
8+
Services.People.queryPeople().then(p => (ref.value = p))
99
MessageCenter.on('newPerson', p => {
1010
const old = ref.value.filter(x => x.username !== p.username)
1111
ref.value = [...old, p]
1212
})
1313
export function usePeople() {
1414
const [people, setPeople] = React.useState<Person[]>(ref.value)
15-
React.useEffect(() => ref.addListener(val => setPeople(val)), [])
16-
return people.filter(x => x.username !== '$self')
15+
React.useEffect(() => ref.addListener(val => setPeople(val.filter(x => x.username !== '$self'))), [])
16+
return people
1717
}

Diff for: src/components/InjectedComponents/AddToKeyStore.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import AsyncComponent from '../../utils/components/AsyncComponent'
33
import { AdditionalContent } from './AdditionalPostContent'
4-
import { CryptoService } from '../../extension/content-script/rpc'
4+
import Services from '../../extension/service'
55

66
interface Props {
77
provePost: string
@@ -10,7 +10,7 @@ interface Props {
1010
export function AddToKeyStore({ provePost, postBy }: Props) {
1111
return (
1212
<AsyncComponent
13-
promise={async () => CryptoService.verifyOthersProve(provePost, postBy)}
13+
promise={async () => Services.Crypto.verifyOthersProve(provePost, postBy)}
1414
dependencies={[provePost, postBy]}
1515
awaitingComponent={AddToKeyStoreUI.awaiting}
1616
completeComponent={() => AddToKeyStoreUI.success}

0 commit comments

Comments
 (0)