Skip to content
Permalink
Browse files

feat: add sessions & signing support (#13)

  • Loading branch information...
satazor committed Jun 15, 2019
1 parent 9e324ac commit 65a47be6d0f77eedcc1249ac5f04fa9f16f3f577
Showing with 4,158 additions and 2,343 deletions.
  1. +10 −0 demo/.eslintrc.json
  2. +1,193 −990 demo/package-lock.json
  3. +1 −0 demo/package.json
  4. +7 −9 demo/src/App.js
  5. +0 −9 demo/src/App.test.js
  6. +0 −1 demo/src/idm-wallet
  7. +0 −7 demo/src/index.js
  8. +0 −7 demo/src/logo.svg
  9. +0 −135 demo/src/serviceWorker.js
  10. +13 −13 demo/src/shared/components/lock-screen/LockScreen.js
  11. +9 −9 demo/src/shared/components/setup-locker/SetupLocker.js
  12. +10 −10 demo/src/shared/components/setup-locker/steps/SetupIdleTimer.js
  13. +19 −19 demo/src/shared/components/setup-locker/steps/SetupMasterLock.js
  14. +6 −4 demo/src/shared/components/timer/Timer.js
  15. +7 −9 demo/src/shared/components/wallet/Wallet.js
  16. +8 −203 demo/src/shared/components/wallet/wallet-content/WalletContent.js
  17. +158 −0 demo/src/shared/components/wallet/wallet-content/sections/Identities.js
  18. +59 −0 demo/src/shared/components/wallet/wallet-content/sections/Locker.js
  19. +120 −0 demo/src/shared/components/wallet/wallet-content/sections/Sessions.js
  20. +9 −0 demo/src/shared/components/wallet/wallet-content/sections/index.js
  21. +233 −162 package-lock.json
  22. +8 −4 package.json
  23. +4 −4 src/__tests__/index.test.js
  24. +4 −0 src/__tests__/mocks/index.js
  25. +3 −3 src/didm/__tests__/index.test.js
  26. +92 −0 src/didm/methods/__tests__/ipid.js
  27. +187 −0 src/identities/identity/apps.js
  28. +0 −9 src/identities/identity/backup.js
  29. +28 −68 src/identities/identity/devices.js
  30. +59 −20 src/identities/identity/index.js
  31. +14 −99 src/identities/identity/profile.js
  32. +21 −0 src/identities/identity/utils/asserts/apps.js
  33. +21 −0 src/identities/identity/utils/asserts/devices.js
  34. +3 −0 src/identities/identity/utils/asserts/index.js
  35. +88 −0 src/identities/identity/utils/asserts/profile.js
  36. +6 −0 src/identities/identity/utils/constants/apps.js
  37. +17 −0 src/identities/identity/utils/constants/devices.js
  38. +15 −0 src/identities/identity/utils/constants/profile.js
  39. +23 −6 src/identities/index.js
  40. +10 −4 src/index.js
  41. +8 −0 src/locker/__tests__/index.test.js
  42. +25 −15 src/locker/index.js
  43. +1 −1 src/locker/locks/__tests__/index.test.js
  44. +4 −4 src/locker/locks/__tests__/mocks/index.js
  45. +24 −10 src/locker/locks/__tests__/passphrase.test.js
  46. +9 −6 src/locker/locks/index.js
  47. +28 −68 src/locker/locks/passphrase.js
  48. 0 src/locker/locks/{util → utils}/asserts.js
  49. 0 src/locker/locks/{util → utils}/passphrase-strength.js
  50. +2 −3 src/secret/index.js
  51. +411 −0 src/sessions/__tests__/index.test.js
  52. +113 −0 src/sessions/__tests__/mocks/index.js
  53. +227 −0 src/sessions/index.js
  54. +105 −0 src/sessions/session/__tests__/index.test.js
  55. +49 −0 src/sessions/session/__tests__/mocks/index.js
  56. +130 −0 src/sessions/session/index.js
  57. +8 −0 src/sessions/session/utils/asserts.js
  58. +3 −0 src/sessions/session/utils/storage-keys.js
  59. +5 −9 src/storage/__tests__/index.test.js
  60. +8 −11 src/storage/__tests__/mocks/index.js
  61. +35 −51 src/storage/index.js
  62. +0 −46 src/utils/__tests__/aes-gcm.test.js
  63. +0 −53 src/utils/__tests__/mocks/index.js
  64. +0 −18 src/utils/__tests__/shat.test.js
  65. +0 −28 src/utils/aes-gcm.js
  66. +1 −1 src/utils/constants.js
  67. +62 −0 src/utils/crypto/cypher.js
  68. +26 −0 src/utils/crypto/hasher.js
  69. +4 −0 src/utils/crypto/index.js
  70. +102 −0 src/utils/crypto/keys.js
  71. +3 −0 src/utils/crypto/random.js
  72. +24 −11 src/utils/did.js
  73. +0 −187 src/utils/errors.js
  74. +21 −0 src/utils/errors/base.js
  75. +7 −0 src/utils/errors/crypto.js
  76. +19 −0 src/utils/errors/did.js
  77. +19 −0 src/utils/errors/didm.js
  78. +21 −0 src/utils/errors/identities.js
  79. +13 −0 src/utils/errors/identity/apps.js
  80. +7 −0 src/utils/errors/identity/backup.js
  81. +25 −0 src/utils/errors/identity/devices.js
  82. +18 −0 src/utils/errors/identity/index.js
  83. +25 −0 src/utils/errors/identity/profile.js
  84. +20 −0 src/utils/errors/index.js
  85. +21 −0 src/utils/errors/locker.js
  86. +29 −0 src/utils/errors/locks/index.js
  87. +13 −0 src/utils/errors/session/index.js
  88. +9 −0 src/utils/errors/sessions.js
  89. +9 −0 src/utils/errors/storage.js
  90. +0 −17 src/utils/sha.js
@@ -0,0 +1,10 @@
{
"root": true,
"extends": [
"eslint-config-moxy/es9",
"eslint-config-moxy/addons/babel-parser",
"eslint-config-moxy/addons/es-modules",
"eslint-config-moxy/addons/browser",
"eslint-config-moxy/addons/react"
]
}

Large diffs are not rendered by default.

@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"idm-wallet": "file:..",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-scripts": "2.1.5"
@@ -1,17 +1,15 @@
import React, { Component } from 'react';

import Wallet from './shared/components/wallet/Wallet';

import './App.css';

class App extends Component {
render() {
return (
<div className="App">
<Wallet />
</div>
);
}
render() {
return (
<div className="App">
<Wallet />
</div>
);
}
}

export default App;

This file was deleted.

This file was deleted.

@@ -2,12 +2,5 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();

This file was deleted.

This file was deleted.

@@ -11,7 +11,7 @@ class LockScreen extends Component {

render() {
const { loading, error } = this.state;

if (loading) {
return <div>...Loading...</div>;
}
@@ -20,7 +20,7 @@ class LockScreen extends Component {
<div>
<h1>Lock Screen</h1>
<input
type="text"
type="text"
id={ LOCK_TYPE }
name={ LOCK_TYPE }
onChange={ this.handleInputChange }
@@ -30,6 +30,15 @@ class LockScreen extends Component {
);
}

unlock = (lockType, challenge) => {
const { locker } = this.props;

this.setState({ loading: true });

locker.getLock(lockType).unlock(challenge)
.catch((error) => this.setState({ loading: false, error }));
};

handleInputChange = (event) => {
this.inputValue = event.target.value;
};
@@ -39,19 +48,10 @@ class LockScreen extends Component {
this.unlock(LOCK_TYPE, this.inputValue);
}
};

unlock = (lockType, challenge) => {
const { locker } = this.props;

this.setState({ loading: true });

locker.getLock(lockType).unlock(challenge)
.catch((error) => this.setState({ loading: false, error }));
};
}

LockScreen.propTyes = {
LockScreen.propTypes = {
locker: PropTypes.object,
};

export default LockScreen;
export default LockScreen;
@@ -1,13 +1,12 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import SetupMasterLock from './steps/SetupMasterLock';
import SetupIdleTimer from './steps/SetupIdleTimer';

class SetupLocker extends Component {
state = {
step: 1,
}
};

render() {
return (
@@ -23,12 +22,12 @@ class SetupLocker extends Component {
const { locker } = this.props;

switch (step) {
case 1:
return <SetupMasterLock locker={ locker } onComplete={ this.handleStepComplete } />
case 2:
return <SetupIdleTimer locker={ locker } onComplete={ this.handleStepComplete } />
default:
return null;
case 1:
return <SetupMasterLock locker={ locker } onComplete={ this.handleStepComplete } />;
case 2:
return <SetupIdleTimer locker={ locker } onComplete={ this.handleStepComplete } />;
default:
return null;
}
}

@@ -41,11 +40,12 @@ class SetupLocker extends Component {
}

this.setState({ step: step + 1 });
}
};
}

SetupLocker.propTypes = {
locker: PropTypes.object.isRequired,
onComplete: PropTypes.func.isRequired,
};

export default SetupLocker;
@@ -6,7 +6,7 @@ const TIME_BASE = 60 * 1000;
class SetupIdleTimer extends Component {
state = {
loading: false,
}
};

render() {
const { loading } = this.state;
@@ -19,7 +19,7 @@ class SetupIdleTimer extends Component {
<div>
<h3>Setup an expiration lock in minutes</h3>
<input
type="number"
type="number"
id="expirationTime"
name="expirationTime"
onChange={ this.handleInputChange }
@@ -28,6 +28,14 @@ class SetupIdleTimer extends Component {
);
}

setMaxTime = (value) => {
const { locker, onComplete } = this.props;

locker.idleTimer.setMaxTime(value)
.then(onComplete)
.catch((error) => this.setState({ loading: false, error }));
};

handleInputChange = (event) => {
this.inputValue = event.target.value;
};
@@ -37,14 +45,6 @@ class SetupIdleTimer extends Component {
this.setMaxTime(Math.abs(this.inputValue * TIME_BASE));
}
};

setMaxTime = (value) => {
const { locker, onComplete } = this.props;

locker.idleTimer.setMaxTime(value)
.then(onComplete)
.catch((error) => this.setState({ loading: false, error }));
}
}

SetupIdleTimer.propTypes = {

0 comments on commit 65a47be

Please sign in to comment.
You can’t perform that action at this time.