Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portal Downstream #8

Merged
merged 52 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
95e6e31
Update README
martindale Jan 5, 2020
9c9a91b
Standardize towards app.js
martindale Jan 23, 2020
aaaaa10
Fix creation of new Components without DOM
martindale Jan 27, 2020
ba2179d
Add new FabricElement, init lifecycle event
martindale Jan 27, 2020
1505558
Updates for downstream
martindale Jan 29, 2020
15d6d17
Add support for `integrity`
martindale Jan 30, 2020
3981cc7
Add SPA handlers
martindale Jan 30, 2020
0a2b80a
Re-bind SPA events, handle browser navigation
martindale Feb 1, 2020
d883904
Pin bcoin to optional-http
martindale Feb 4, 2020
c63dc82
Merge branch 'develop' of github.com:martindale/web into develop
martindale Feb 5, 2020
a2b0c3a
Change headers for GET requests
martindale Feb 11, 2020
812e216
Reduce app verbosity
martindale Feb 20, 2020
575696e
Begin Forge patches
martindale Feb 22, 2020
af37282
Merge branch 'get-fixes' of github.com:martindale/web into forge-demo
martindale Feb 22, 2020
b4db54b
Enable logging middleware for verbosity 2 and less
martindale Feb 24, 2020
3021d16
Import latest Server elements
martindale Mar 30, 2020
744e20a
Remove blob-to-buffer
martindale Mar 31, 2020
f3e9df3
Update example, various components for testing
martindale Apr 2, 2020
67a9a8a
Clean up tests
martindale Apr 2, 2020
0d6d64d
Bind new events, warn on lack of Resource defs
martindale Apr 27, 2020
619b753
Remove erroneous state from Router, render state
martindale May 20, 2020
1f53f16
Sweep of latest changes, tests
martindale May 20, 2020
41aa0b1
Add "connected" event to Bridge
martindale May 20, 2020
94ecfbe
Switch to #peering-develop-async for @fabric/core
martindale May 20, 2020
d0b22e6
Add tests for WebSockets
martindale Jun 21, 2020
4f85127
Remove extraneous dependency
martindale Jun 21, 2020
8147809
Add package-lock.json
martindale Nov 25, 2020
6f353d6
Begin to clean up tests
martindale Nov 25, 2020
3093ab6
Add various testing packages, update Example
martindale Nov 25, 2020
0db1b8f
Bump latest soundtrack
martindale Apr 11, 2021
68b033a
Update to `message-relay` branch of Fabric
martindale Oct 16, 2021
6869b8a
Update Server to reflect new API changes
martindale Oct 20, 2021
028474c
Update deprecations, package-lock.json
martindale Oct 21, 2021
b9f3655
If no app or app store, return null for all GET requests
martindale Oct 22, 2021
4f22015
Clean up tests, tighten Server definition
martindale Oct 28, 2021
0fc1e7f
Update package-lock.json with latest Fabric
martindale Oct 28, 2021
1a7ce25
Add SLIP-44 importer
martindale Nov 7, 2021
0bd90a7
Handle more errors when compiled without a local SPA
martindale Nov 29, 2021
2ed863f
Update Travis
martindale Nov 29, 2021
d4661d0
Add new class "Remote"
martindale Dec 12, 2021
248543f
Add P2P_SESSION_ACK constant
martindale Dec 20, 2021
55f30b0
Update @fabric/core
martindale Dec 20, 2021
ab432dd
Update to RC1
martindale Jan 19, 2022
ac98ccc
Merge branch 'develop-exchange' into portal-develop
martindale Jan 19, 2022
6c869a3
Update package-lock.json
martindale Jan 27, 2022
6a06b94
Update to latest Fabric API
martindale Jan 27, 2022
760f673
Add handlers for Generics
martindale Feb 4, 2022
a18b863
Allow `host` parameter to replace `authority`
martindale Feb 4, 2022
f463a44
Update package-lock.json
martindale Feb 5, 2022
006a7ac
Add to Bridge support for automatic reconnects
martindale Feb 6, 2022
fc1df2a
Add Identity components from downstream
martindale Mar 15, 2022
5a8b7f9
Switch to @fabric/core to `swaps-develop`
martindale Mar 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '10'
- '12.20.2'
script:
- npm run test
- npm run report:coverage
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# `@fabric/http`
![Project Status](https://img.shields.io/badge/status-experimental-rainbow.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/FabricLabs/web.svg?branch=master&style=flat-square)](https://travis-ci.org/FabricLabs/web)
[![Coverage Status](https://img.shields.io/codecov/c/github/FabricLabs/web.svg?style=flat-square)](https://codecov.io/gh/FabricLabs/web)
[![GitHub contributors](https://img.shields.io/github/contributors/FabricLabs/web.svg?style=flat-square)](https://github.com/FabricLabs/web/graphs/contributors)
[![Community](https://img.shields.io/matrix/hub:fabric.pub.svg?style=flat-square)](https://chat.fabric.pub)

Fabric module for serving the legacy web.

## Quick Start
Expand Down
106 changes: 106 additions & 0 deletions components/FabricIdentity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import * as defaults from '../settings/state';

import merge from 'lodash.merge';
import FabricComponent from '../types/component';

// Components
import {
Button,
// Card,
// Container,
Icon,
// Item,
// Grid,
Menu,
Modal,
// Segment
} from 'semantic-ui-react';

import SeedEntryForm from './SeedEntryForm';

class FabricIdentity extends FabricComponent {
constructor (props) {
super(props);

this.settings = merge({
explain: false,
modalOpen: false,
keys: []
}, props);

// TODO: prepare Fabric
// i.e., use _state here, then import from getter and apply properties
// _from_ @react
this.state = {
explain: true,
identity: null,
integrity: 'sha256-deadbeefbabe',
status: 'PAUSED'
};

return this;
}

handleChange (e, v) {
console.log('change:', e, v);
// this.setState({ seed: e });
}

handleClose () {
this.setState({ modalOpen: false });
}

render () {
return (
<>
<Menu.Item className='borderless'>
<Button icon onClick={this._handleCardClick.bind(this)} labelPosition='left'>
<span>{/*<strong>Identity:</strong> */}<code>{this.state.identity || 'anonymous'}</code></span>
<Icon name='user' />
</Button>
</Menu.Item>
<Modal open={this.state.modalOpen} onClose={this.handleClose.bind(this)} closeIcon>
<Modal.Header>Login</Modal.Header>
<Modal.Content>
<SeedEntryForm handleClose={this.handleClose.bind(this)} handleChange={this.handleChange.bind(this)} />
</Modal.Content>
</Modal>
</>
);
}

isVisible () {
if (this.state.explain) return true;
return false;
}

_handleCardClick () {
this.setState({ modalOpen: true });
}

_handleRestoreButtonClick () {
this.setState({ modalOpen: true });
}

_handleGeneratorButtonClick () {
this.setState({ modalOpen: true });
}

_handleGenerateKeyPress (e) {
if (e.charCode === 32 || e.charCode === 13) {
// Prevent the default action to stop scrolling when space is pressed
e.preventDefault();
console.log('Button received click with keyboard');
}
}

_handleRestoreKeyPress (e) {
if (e.charCode === 32 || e.charCode === 13) {
// Prevent the default action to stop scrolling when space is pressed
e.preventDefault();
console.log('Button received click with keyboard');
}
}
}

export default FabricIdentity;
153 changes: 153 additions & 0 deletions components/FabricIdentityManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Dependencies
import merge from 'lodash.merge';
import TrezorConnect from 'trezor-connect';

import FabricComponent from '../types/component';

// Components
import {
Button,
Card,
Form,
// Container,
Icon,
// Grid,
// Menu,
// Segment
} from 'semantic-ui-react';

import IdentityPicker from './IdentityPicker';
import SeedEntryForm from './SeedEntryForm';

class FabricIdentityManager extends FabricComponent {
constructor (props) {
super(props);

this.settings = merge({
explain: false,
keys: []
}, props);

// TODO: prepare Fabric
// i.e., use _state here, then import from getter and apply properties
// _from_ @react
this.state = {
explain: true,
hash: null,
identities: [],
integrity: 'sha256-deadbeefbabe',
status: 'PAUSED',
step: 1
};

return this;
}

handleChange = input => event => {
this.setState({[input]: event.target.value})
}

setStep () {
const { step } = this.state;
this.setState({ step });
}

nextStep () {
const { step } = this.state;
this.setState({
step: step + 1
});
}

previoustStep () {
const { step } = this.state;
this.setState({
step: step - 1
});
}

start () {
TrezorConnect.manifest({
email: 'labs@fabric.pub',
appUrl: 'https://hub.fabric.pub'
});

this.setState({ status: 'STARTED' });
return this;
}

render () {
const { step } = this.state;
const { firstName, lastName, email, age, city, country } = this.state;
const values = { firstName, lastName, email, age, city, country };

let element = null;

switch (step) {
case 1:
element = (
<IdentityPicker nextStep={this.nextStep.bind(this)} setStep={this.setStep.bind(this)} handleChange={this.handleChange.bind(this)} values={values} />
);
break;
case 2:
element = (
<SeedEntryForm nextStep={this.nextStep.bind(this)} setStep={this.setStep.bind(this)} handleChange={this.handleChange.bind(this)} values={values} />
);
break;
case 3:
element = (
<IdentityPicker nextStep={this.nextStep.bind(this)} setStep={this.setStep.bind(this)} handleChange={this.handleChange.bind(this)} values={values} />
);
break;
case 4:
element = (
<IdentityPicker nextStep={this.nextStep.bind(this)} setStep={this.setStep.bind(this)} handleChange={this.handleChange.bind(this)} values={values} />
);
break;
}

return (
<>
<Card fluid>
<Card.Content attached='top'>
<Form>
<Form.Group inline widths='equal'>
<Form.Field>
<Form.Input disabled value={this.state.hash} />
</Form.Field>
<Form.Field>
<Button.Group floated='right'>
<Button><Icon name='history' /></Button>
<Button><Icon name='refresh' /></Button>
</Button.Group>
{/*
<Button.Group>
<Button><Icon name='info' /></Button>
<Button><Icon name='star' /></Button>
</Button.Group>
*/}
</Form.Field>
</Form.Group>
</Form>
</Card.Content>
<Card.Content hidden={(!this.isVisible())}>
<Card.Header>Identity Manager</Card.Header>
<Card.Meta>
<div><strong>Status:</strong> <pre>{this.state.status}</pre></div>
<div><strong>State:</strong> <pre>{JSON.stringify(this.state, null, ' ')}</pre></div>
</Card.Meta>
<Card.Description>Get started by restoring from an existing seed phrase or generating a new one.</Card.Description>
</Card.Content>
<Card.Content extra attached='bottom'>{element}</Card.Content>
</Card>
</>
);
}

isVisible () {
if (this.state.explain) return true;
return false;
}
}

export default FabricIdentityManager;
54 changes: 54 additions & 0 deletions components/IdentityPicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { Component } from 'react';
import { Icon, Form, Button } from 'semantic-ui-react';

class IdentityPicker extends Component {
render () {
const { values } = this.props;

return (
<Form>
<Button.Group fluid>
<Button icon color='green' onClick={this._handleGeneratorButtonClick.bind(this)} onKeyPress={this._handleGenerateKeyPress.bind(this)} labelPosition='left'>Generate <Icon name='leaf' /></Button>
<Button.Or />
<Button icon color='blue' onClick={this._handleRestoreButtonClick.bind(this)} onKeyPress={this._handleRestoreKeyPress.bind(this)} labelPosition='right'>Restore from Seed Phrase <Icon name='right chevron' /></Button>
</Button.Group>
<Button type='submit' onClick={this.saveAndContinue.bind(this)}>Save And Continue</Button>
</Form>
);
}

saveAndContinue (e) {
e.preventDefault();
this.props.nextStep();
}

_handleRestoreButtonClick () {
this.setState({ step: 'SEED_RESTORE_START' });
}

_handleGeneratorButtonClick () {
this.setState({ step: 'SEED_GENERATE_START' });
}

_handleGenerateClick () {
console.log('generate request click');
}

_handleGenerateKeyPress (e) {
if (e.charCode === 32 || e.charCode === 13) {
// Prevent the default action to stop scrolling when space is pressed
e.preventDefault();
console.log('Button received click with keyboard');
}
}

_handleRestoreKeyPress (e) {
if (e.charCode === 32 || e.charCode === 13) {
// Prevent the default action to stop scrolling when space is pressed
e.preventDefault();
console.log('Button received click with keyboard');
}
}
}

export default IdentityPicker;
Loading