updates
30
dist/challenge/index.html
vendored
|
@ -2,32 +2,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body { font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 22px; }
|
||||
* { margin: 0px; }
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 22px; padding: 16px; }
|
||||
|
||||
.content { display: flex; align-items: center; justify-content: center; flex-direction: column; }
|
||||
.title { font-size: 22px; line-height: 28px; letter-spacing: -0.48px; font-weight: 700; }
|
||||
.logo { width: 64px; height: 64px; -webkit-user-select: none; user-select: none; margin: 0px 0px 12px 0px; }
|
||||
.logo img { width: 100% !important; height: 100% !important; }
|
||||
.title { font-size: 22px; line-height: 28px; letter-spacing: -0.48px; font-weight: 700; margin: 0px 0px 24px 0px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div class="logo">
|
||||
<img src="../img/icon/app/64x64.png" />
|
||||
</div>
|
||||
<div class="title">Challenge</div>
|
||||
<div id="challenge"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const param = getParam();
|
||||
|
||||
document.getElementById('challenge').innerHTML = param.challenge;
|
||||
|
||||
function getParam () {
|
||||
var a = location.search.replace(/^\?/, '').split('&');
|
||||
var param = {};
|
||||
|
||||
a.forEach((s) => {
|
||||
var kv = s.split('=');
|
||||
param[kv[0]] = kv[1];
|
||||
});
|
||||
return param;
|
||||
};
|
||||
window.addEventListener('message', (e) => {
|
||||
document.getElementById('challenge').innerText = e.data.challenge;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
dist/img/icon/app/1024x1024.png
vendored
Normal file
After Width: | Height: | Size: 251 KiB |
BIN
dist/img/icon/app/128x128.png
vendored
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
dist/img/icon/app/16x16.png
vendored
Normal file
After Width: | Height: | Size: 452 B |
BIN
dist/img/icon/app/256x256.png
vendored
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
dist/img/icon/app/32x32.png
vendored
Normal file
After Width: | Height: | Size: 785 B |
BIN
dist/img/icon/app/512x512.png
vendored
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
dist/img/icon/app/64x64.png
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
|
@ -1,3 +1,5 @@
|
|||
import { UtilData, UtilRouter, dispatcher } from 'Lib';
|
||||
import { authStore } from 'Store';
|
||||
import Extension from 'json/extension.json';
|
||||
|
||||
class Util {
|
||||
|
@ -36,6 +38,12 @@ class Util {
|
|||
/* @ts-ignore */
|
||||
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => callBack(tabs[0]));
|
||||
};
|
||||
|
||||
initWithToken (token: string) {
|
||||
authStore.tokenSet(token);
|
||||
dispatcher.listenEvents();
|
||||
UtilData.createsSubscriptions(() => UtilRouter.go('/create', {}));
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import * as React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import { Button, Input } from 'Component';
|
||||
import { I, C } from 'Lib';
|
||||
import { extensionStore } from 'Store';
|
||||
import { Button, Input, Error } from 'Component';
|
||||
import { I, C, UtilData, UtilRouter, dispatcher, Storage } from 'Lib';
|
||||
import { authStore, extensionStore } from 'Store';
|
||||
import Util from '../lib/util';
|
||||
|
||||
interface State {
|
||||
error: string;
|
||||
|
@ -11,6 +12,9 @@ interface State {
|
|||
const Challenge = observer(class Challenge extends React.Component<I.PageComponent, State> {
|
||||
|
||||
ref: any = null;
|
||||
state = {
|
||||
error: '',
|
||||
};
|
||||
|
||||
constructor (props: I.PageComponent) {
|
||||
super(props);
|
||||
|
@ -19,10 +23,17 @@ const Challenge = observer(class Challenge extends React.Component<I.PageCompone
|
|||
};
|
||||
|
||||
render () {
|
||||
const { error } = this.state;
|
||||
|
||||
return (
|
||||
<form className="page pageChallenge" onSubmit={this.onSubmit}>
|
||||
<Input ref={ref => this.ref = ref} />
|
||||
<Button type="input" color="pink" text="Ok" />
|
||||
<Input ref={ref => this.ref = ref} placeholder="Challenge" />
|
||||
|
||||
<div className="buttons">
|
||||
<Button type="input" color="pink" className="c32" text="Authorize" />
|
||||
</div>
|
||||
|
||||
<Error text={error} />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
@ -30,8 +41,14 @@ const Challenge = observer(class Challenge extends React.Component<I.PageCompone
|
|||
onSubmit (e: any) {
|
||||
e.preventDefault();
|
||||
|
||||
C.AccountLocalLinkSolveChallenge(extensionStore.challengeId, this.ref?.getValue(), (message: any) => {
|
||||
console.log(message);
|
||||
C.AccountLocalLinkSolveChallenge(extensionStore.challengeId, this.ref?.getValue().trim(), (message: any) => {
|
||||
if (message.error.code) {
|
||||
this.setState({ error: message.error.description });
|
||||
return;
|
||||
};
|
||||
|
||||
Storage.set('token', message.token);
|
||||
Util.initWithToken(message.token);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -339,7 +339,6 @@ const Create = observer(class Create extends React.Component<I.PageComponent, St
|
|||
element,
|
||||
horizontal: I.MenuDirection.Center,
|
||||
commonFilter: true,
|
||||
noFlipY: true,
|
||||
onOpen: () => {
|
||||
window.setTimeout(() => { $(element).addClass('isFocused'); });
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import { Label, Button, Error } from 'Component';
|
||||
import { I, C, UtilRouter, UtilData, dispatcher } from 'Lib';
|
||||
import { I, C, UtilRouter, Storage, dispatcher } from 'Lib';
|
||||
import { authStore, commonStore, extensionStore } from 'Store';
|
||||
import Url from 'json/url.json';
|
||||
|
||||
|
@ -53,15 +53,23 @@ const Index = observer(class Index extends React.Component<I.PageComponent, Stat
|
|||
/* @ts-ignore */
|
||||
const manifest = chrome.runtime.getManifest();
|
||||
|
||||
authStore.tokenSet('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZWVkIjoiUkNRbnFkcnYifQ.g22qTAnn7fOD9KB9Z1xQBN3Iy6sSUvPgLSWfQSxcqCw');
|
||||
dispatcher.init(`http://127.0.0.1:${response.ports[1]}`);
|
||||
commonStore.gatewaySet(`http://127.0.0.1:${response.ports[2]}`);
|
||||
|
||||
C.AccountLocalLinkNewChallenge(manifest.name, (message: any) => {
|
||||
extensionStore.challengeId = message.challengeId;
|
||||
const token = Storage.get('token');
|
||||
if (token) {
|
||||
Util.initWithToken(token);
|
||||
} else {
|
||||
C.AccountLocalLinkNewChallenge(manifest.name, (message: any) => {
|
||||
if (message.error.code) {
|
||||
this.setState({ error: message.error.description });
|
||||
return;
|
||||
};
|
||||
|
||||
UtilRouter.go('/challenge', {});
|
||||
});
|
||||
extensionStore.challengeId = message.challengeId;
|
||||
UtilRouter.go('/challenge', {});
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ html.anytypeWebclipper-popup { width: 268px; }
|
|||
|
||||
.isFocused { border-color: $colorIce !important; box-shadow: 0px 0px 0px 1px $colorIce; }
|
||||
|
||||
.page.pageIndex { padding: 50px 16px; text-align: center; }
|
||||
.page.pageIndex, .page.pageChallenge { padding: 50px 16px; text-align: center; }
|
||||
|
||||
.page.pageCreate { padding: 16px; }
|
||||
.page.pageCreate {
|
||||
|
|
|
@ -227,6 +227,8 @@ class App extends React.Component<object, State> {
|
|||
UtilRouter.init(history);
|
||||
|
||||
dispatcher.init(UtilCommon.getElectron().getGlobal('serverAddress'));
|
||||
dispatcher.listenEvents();
|
||||
|
||||
keyboard.init();
|
||||
|
||||
this.registerIpcEvents();
|
||||
|
|
|
@ -5,7 +5,7 @@ import { observable, set } from 'mobx';
|
|||
import Commands from 'protobuf/pb/protos/commands_pb';
|
||||
import Events from 'protobuf/pb/protos/events_pb';
|
||||
import Service from 'protobuf/pb/protos/service/service_grpc_web_pb';
|
||||
import { authStore, commonStore, blockStore, detailStore, dbStore, notificationStore, popupStore } from 'Store';
|
||||
import { authStore, commonStore, blockStore, detailStore, dbStore, notificationStore } from 'Store';
|
||||
import { UtilCommon, UtilObject, I, M, translate, analytics, Renderer, Action, Dataview, Preview, Mapper, Decode, UtilRouter, Storage } from 'Lib';
|
||||
import * as Response from './response';
|
||||
import { ClientReadableStream } from 'grpc-web';
|
||||
|
@ -35,7 +35,6 @@ class Dispatcher {
|
|||
|
||||
init (address: string) {
|
||||
this.service = new Service.ClientCommandsClient(address, null, null);
|
||||
this.listenEvents();
|
||||
|
||||
console.log('[Dispatcher].init Server address: ', address);
|
||||
};
|
||||
|
@ -222,9 +221,10 @@ class Dispatcher {
|
|||
case 'accountLinkChallenge': {
|
||||
const info = data.getClientinfo();
|
||||
const challenge = data.getChallenge();
|
||||
const win = window.open(`./challenge/index.html?challenge=${challenge}`, '', 'width=320,height=320');
|
||||
const win = window.open('./challenge/index.html', '', 'width=320,height=320');
|
||||
|
||||
win.focus();
|
||||
win.addEventListener('load', () => win.postMessage({ info, challenge }, '*'), false);
|
||||
break;
|
||||
};
|
||||
|
||||
|
|