Skip to content

Commit

Permalink
Merge pull request #35 from standardnotes/update
Browse files Browse the repository at this point in the history
feat: update codebase
  • Loading branch information
johnny243 authored Mar 23, 2021
2 parents f07bc8d + 9a194ef commit bddc66b
Show file tree
Hide file tree
Showing 31 changed files with 7,084 additions and 12,385 deletions.
23 changes: 13 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"presets": [ "es2015", "stage-0", "react"],

/* if you want to use babel runtime, uncomment the following line */
// "plugins": ["transform-runtime"],

"env": {
"build": {
"optional": ["optimisation", "minification"]
}
}
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
}
2 changes: 2 additions & 0 deletions .browserlistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> 0.25%
not dead
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/**
dist/**
webpack.*
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"@standardnotes/eslint-config-extensions",
"plugin:react/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 11,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"settings": {
"react": {
"version": "detect"
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ build

# Editor
.idea

ext.json
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ext.json
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

10 changes: 3 additions & 7 deletions app/App.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import "regenerator-runtime/runtime";
import 'regenerator-runtime/runtime';

import React from 'react';
import Home from './components/Home';
import Home from '@Components/Home';

export default class App extends React.Component {
constructor(props) {
super(props);
}

render() {
return (
<div>
<Home />
</div>
);
return <Home />;
}
}
28 changes: 19 additions & 9 deletions app/components/AuthEntry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { totp } from '../lib/otp';
import CountdownPie from './CountdownPie';
import AuthMenu from './AuthMenu';
import PropTypes from 'prop-types';
import { totp } from '@Lib/otp';
import CountdownPie from '@Components/CountdownPie';
import AuthMenu from '@Components/AuthMenu';

export default class AuthEntry extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -29,11 +30,11 @@ export default class AuthEntry extends React.Component {
});

this.timer = setTimeout(this.updateToken, timeLeft * 1000);
};
}

componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
// If the secret changed make sure to recalculate token
if (nextProps.entry.secret !== this.props.entry.secret) {
if (prevProps.entry.secret !== this.props.entry.secret) {
clearTimeout(this.timer);
this.timer = setTimeout(this.updateToken, 0);
}
Expand All @@ -52,17 +53,17 @@ export default class AuthEntry extends React.Component {
name,
value: target.value
});
};
}

copyToken = event => {
copyToken = () => {
const textField = document.createElement('textarea');
textField.innerText = this.state.token;
document.body.appendChild(textField);
textField.select();
document.execCommand('copy');
textField.remove();
this.props.onCopyToken();
};
}

render() {
const { service, account, notes } = this.props.entry;
Expand Down Expand Up @@ -104,3 +105,12 @@ export default class AuthEntry extends React.Component {
);
}
}

AuthEntry.propTypes = {
id: PropTypes.any.isRequired,
entry: PropTypes.object.isRequired,
onEdit: PropTypes.func.isRequired,
onRemove: PropTypes.func.isRequired,
onEntryChange: PropTypes.func,
onCopyToken: PropTypes.func.isRequired
};
16 changes: 11 additions & 5 deletions app/components/AuthMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

export default class AuthMenu extends React.Component {
constructor(props) {
Expand All @@ -13,25 +14,25 @@ export default class AuthMenu extends React.Component {
this.setState({
show: !this.state.show
});
};
}

onEdit = () => {
this.onToggle();
this.props.onEdit();
};
}

onRemove = () => {
this.onToggle();
this.props.onRemove();
};
}

render() {
return (
<div className="auth-menu">
<div className="sk-button" onClick={this.onToggle}>
<div className="sk-label">•••</div>
</div>
{this.state.show && [
{this.state.show && (
<div className="auth-overlay" onClick={this.onToggle} />,
<div className="sk-menu-panel">
<div className="sk-menu-panel-row" onClick={this.onEdit}>
Expand All @@ -41,8 +42,13 @@ export default class AuthMenu extends React.Component {
<div className="sk-label">Remove</div>
</div>
</div>
]}
)}
</div>
);
}
}

AuthMenu.propTypes = {
onEdit: PropTypes.func.isRequired,
onRemove: PropTypes.func.isRequired
};
8 changes: 8 additions & 0 deletions app/components/ConfirmDialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

const ConfirmDialog = ({ title, message, onConfirm, onCancel }) => (
<div className="auth-overlay">
Expand Down Expand Up @@ -27,4 +28,11 @@ const ConfirmDialog = ({ title, message, onConfirm, onCancel }) => (
</div>
);

ConfirmDialog.propTypes = {
title: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
onConfirm: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired
};

export default ConfirmDialog;
9 changes: 7 additions & 2 deletions app/components/Countdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

const animationName = token => `countdown${token}`;
const animation = (token, offset) => `@keyframes ${animationName(token)} {
Expand All @@ -10,7 +11,7 @@ const animation = (token, offset) => `@keyframes ${animationName(token)} {
}
}`;

class Countdown extends React.Component {
export default class Countdown extends React.Component {
componentWillUnmount() {
clearTimeout(this.timer);
}
Expand Down Expand Up @@ -67,4 +68,8 @@ class Countdown extends React.Component {
}
}

export default Countdown;
Countdown.propTypes = {
token: PropTypes.string.isRequired,
left: PropTypes.number.isRequired,
total: PropTypes.number.isRequired
};
9 changes: 7 additions & 2 deletions app/components/CountdownPie.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

const animationName = token => `countdown${token}`;

Expand Down Expand Up @@ -41,7 +42,7 @@ const opaReverseAnimation = (
}
}`;

class CountdownPie extends React.Component {
export default class CountdownPie extends React.Component {
componentWillUnmount() {
clearTimeout(this.timer);
}
Expand Down Expand Up @@ -148,4 +149,8 @@ class CountdownPie extends React.Component {
}
}

export default CountdownPie;
CountdownPie.propTypes = {
token: PropTypes.string.isRequired,
left: PropTypes.number.isRequired,
total: PropTypes.number.isRequired
};
12 changes: 10 additions & 2 deletions app/components/EditEntry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import QRCodeReader from './QRCodeReader';
import { secretPattern } from '../lib/otp';
import PropTypes from 'prop-types';
import QRCodeReader from '@Components/QRCodeReader';
import { secretPattern } from '@Lib/otp';

export default class EditEntry extends React.Component {
static defaultProps = {
Expand Down Expand Up @@ -130,3 +131,10 @@ export default class EditEntry extends React.Component {
);
}
}

EditEntry.propTypes = {
id: PropTypes.number,
entry: PropTypes.object.isRequired,
onSave: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired
};
9 changes: 5 additions & 4 deletions app/components/Home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import update from 'immutability-helper';
import EditEntry from './EditEntry';
import ViewEntries from './ViewEntries';
import ConfirmDialog from './ConfirmDialog';
import DataErrorAlert from './DataErrorAlert';
import EditEntry from '@Components/EditEntry';
import ViewEntries from '@Components/ViewEntries';
import ConfirmDialog from '@Components/ConfirmDialog';
import DataErrorAlert from '@Components/DataErrorAlert';
import { EditorKit, EditorKitDelegate } from 'sn-editor-kit';

const initialState = {
Expand Down Expand Up @@ -53,6 +53,7 @@ export default class Home extends React.Component {
try {
entries = JSON.parse(text);
} finally {
// eslint-disable-next-line no-unsafe-finally
return {
html: `<div><strong>${entries.length}</strong> TokenVault Entries </div>`,
plain: `${entries.length} TokenVault Entries`,
Expand Down
2 changes: 1 addition & 1 deletion app/components/QRCodeReader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import jsQR from 'jsqr';
import { parseKeyUri } from '../lib/otp';
import { parseKeyUri } from '@Lib/otp';

export default class QRCodeReader extends React.Component {
onImageSelected = evt => {
Expand Down
10 changes: 9 additions & 1 deletion app/components/ViewEntries.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import AuthEntry from './AuthEntry';
import PropTypes from 'prop-types';
import AuthEntry from '@Components/AuthEntry';

const ViewEntries = ({ entries, onEdit, onRemove, onCopyToken }) => (
<div className="auth-list">
Expand All @@ -16,4 +17,11 @@ const ViewEntries = ({ entries, onEdit, onRemove, onCopyToken }) => (
</div>
);

ViewEntries.propTypes = {
entries: PropTypes.arrayOf(PropTypes.object),
onEdit: PropTypes.func.isRequired,
onRemove: PropTypes.func.isRequired,
onCopyToken: PropTypes.func.isRequired
};

export default ViewEntries;
22 changes: 11 additions & 11 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<base target="_blank">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="dist.css">
<title>TokenVault</title>
</head>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="dist.css">
<title>TokenVault</title>
</head>

<body>
<script type="text/javascript" src="dist.js"></script>
</body>

<body>
<script type="text/javascript" src="dist.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions app/lib/otp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
bufToHex,
hextoBuf,
hexToBytes
} from './utils';
export { secretPattern, parseKeyUri } from './utils';
} from '@Lib/utils';
export { secretPattern, parseKeyUri } from '@Lib/utils';

class Hotp {
/**
Expand Down
22 changes: 2 additions & 20 deletions dist/dist.js

Large diffs are not rendered by default.

Loading

0 comments on commit bddc66b

Please sign in to comment.