Skip to content

Commit 3b8f47f

Browse files
authored
UI work for mnemonic phrase screen, url whitelisting improvements (#8)
* content script update * whitelist PR preview env * adding UI work for mnemonic phrase screen plus some url whitelisting improvemnents * rm debugger
1 parent 753bc18 commit 3b8f47f

File tree

20 files changed

+225
-23
lines changed

20 files changed

+225
-23
lines changed

background/backgroundComponents/externalMessageListener/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import StellarSdk from "stellar-sdk";
22

33
import { ExternalRequest as Request } from "api/types";
44
import { EXTERNAL_SERVICE_TYPES } from "statics";
5+
import { removeQueryParam } from "helpers";
56
import { Sender, SendResponseInterface } from "../types";
67
import { responseQueue, uiData, transactionQueue } from "../messageListener";
78

@@ -21,7 +22,7 @@ export const externalMessageListener = (
2122
const { tab } = sender;
2223
const tabUrl = tab?.url ? tab.url : "";
2324

24-
if (whitelist.includes(tabUrl)) {
25+
if (whitelist.includes(removeQueryParam(tabUrl))) {
2526
if (uiData.publicKey) {
2627
// okay, the requester checks out and we have public key, send it
2728
sendResponse({ publicKey: uiData.publicKey });
@@ -31,7 +32,6 @@ export const externalMessageListener = (
3132

3233
// otherwise, we need to confirm either url or password. Maybe both
3334
const encodeOrigin = btoa(JSON.stringify(tab));
34-
3535
window.open(
3636
chrome.runtime.getURL(`/index.html#/grant-access?${encodeOrigin}`),
3737
"Lyra: Connect",

background/backgroundComponents/messageListener.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import StellarSdk from "stellar-sdk";
44
import { fromMnemonic, generateMnemonic } from "stellar-hd-wallet";
55
import { SERVICE_TYPES, APPLICATION_STATE, SERVER_URL } from "statics";
66
import { Response as Request } from "api/types";
7+
import { removeQueryParam } from "helpers";
78
import { externalMessageListener } from "./externalMessageListener";
89
import { Sender, SendResponseInterface } from "./types";
910

@@ -183,18 +184,20 @@ const initMessageListener = () => {
183184

184185
const grantAccess = () => {
185186
const { url = "" } = request;
187+
const sanitizedUrl = removeQueryParam(url);
186188

187189
// TODO: right now we're just grabbing the last thing in the queue, but this should be smarter.
188190
// Maybe we need to search through responses to find a matching reponse :thinking_face
189191
const response = responseQueue.pop();
190192
const whitelistStr = localStorage.getItem(WHITELIST_ID) || "";
191193
const whitelist = whitelistStr.split(",");
192-
whitelist.push(url);
194+
whitelist.push(sanitizedUrl);
193195

194196
localStorage.setItem(WHITELIST_ID, whitelist.join());
195197

196198
if (typeof response === "function") {
197199
response(url);
200+
sendResponse({});
198201
} else {
199202
sendResponse({ error: "Access was denied" });
200203
}
@@ -240,6 +243,7 @@ const initMessageListener = () => {
240243
const transactionResponse = responseQueue.pop();
241244
if (typeof transactionResponse === "function") {
242245
transactionResponse(response);
246+
sendResponse({});
243247
}
244248
}
245249
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"buffer": "^5.6.0",
2121
"eslint-loader": "^4.0.2",
2222
"fetch": "^1.1.0",
23+
"file-loader": "^6.0.0",
2324
"lodash": "^4.17.15",
2425
"react": "^16.12.0",
2526
"react-copy-to-clipboard": "^5.0.2",

public/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
name="description"
99
content="Web site created using create-react-app"
1010
/>
11+
<style>
12+
@import url("https://fonts.googleapis.com/css2?family=Muli:ital,wght@0,200;0,400;0,700;1,200;1,400;1,700&display=swap");
13+
</style>
1114
<title>React App</title>
1215
</head>
1316
<body>

src/App.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ import { combineReducers } from "redux";
55
import { Provider } from "react-redux";
66
import styled, { createGlobalStyle } from "styled-components";
77

8+
import { COLOR_PALETTE } from "styles";
89
import { reducer as auth } from "ducks/authServices";
9-
import Menu from "components/Menu";
1010
import Router from "./Router";
1111

1212
const GlobalStyle = createGlobalStyle`
13+
html, body, #root {
14+
height: 100%;
15+
}
1316
body {
17+
background: ${COLOR_PALETTE.background};
1418
overscroll-behavior: none;
15-
font-family: sans-serif;
16-
width: 357px;
17-
height: 600px;
19+
font-family: 'Muli', sans-serif;
1820
margin: 0;
1921
}
2022
`;
2123

2224
const Wrapper = styled.div`
23-
text-align: center;
25+
display: flex;
26+
flex-flow: column;
27+
height: 100%;
28+
text-align: left;
2429
`;
2530

2631
const store = configureStore({
@@ -36,7 +41,6 @@ export function App() {
3641
<Provider store={store}>
3742
<Wrapper>
3843
<GlobalStyle />
39-
<Menu />
4044
<Router />
4145
</Wrapper>
4246
</Provider>

src/assets/copy.png

213 Bytes
Loading

src/assets/download.png

243 Bytes
Loading

src/assets/spy.png

6.37 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import Header from "./Header";
4+
5+
const H1 = styled.h1`
6+
font-weight: 200;
7+
font-size: 2.5rem;
8+
line-height: 3.4rem;
9+
margin: 1rem 0;
10+
`;
11+
12+
const Screen = styled.div`
13+
align-content: center;
14+
align-items: center;
15+
display: flex;
16+
justify-content: center;
17+
padding: 100px 170px;
18+
`;
19+
20+
const HalfScreen = styled.div`
21+
padding: 0 30px;
22+
width: 355px;
23+
24+
:nth-child(1) {
25+
margin-top: -20px;
26+
}
27+
`;
28+
29+
const Fullscreen = ({
30+
header,
31+
icon: [src, alt],
32+
children,
33+
}: {
34+
header: string;
35+
icon: [string, string];
36+
children: JSX.Element;
37+
}) => {
38+
return (
39+
<>
40+
<Header />
41+
<Screen>
42+
<HalfScreen>
43+
<img src={src} alt={alt} />
44+
<H1>{header}</H1>
45+
</HalfScreen>
46+
<HalfScreen>{children}</HalfScreen>
47+
</Screen>
48+
</>
49+
);
50+
};
51+
52+
export default Fullscreen;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import { COLOR_PALETTE } from "styles";
4+
5+
const HeaderEl = styled.header`
6+
background: ${COLOR_PALETTE.primaryGradient};
7+
box-sizing: border-box;
8+
font-family: "Muli";
9+
display: flex;
10+
height: 6.2rem;
11+
justify-content: space-between;
12+
padding: 26px 54px;
13+
text-align: left;
14+
`;
15+
16+
const HeaderH1 = styled.h1`
17+
color: #fff;
18+
font-size: 2rem;
19+
font-weight: 200;
20+
line-height: 41px;
21+
margin: 0;
22+
`;
23+
24+
const NetworkEl = styled.h3`
25+
opacity: 0.5;
26+
color: #fff;
27+
font-size: 1rem;
28+
font-weight: 800;
29+
line-height: 21px;
30+
`;
31+
32+
const Header = () => (
33+
<HeaderEl>
34+
<HeaderH1>Lyra</HeaderH1>
35+
<NetworkEl>Test net</NetworkEl>
36+
</HeaderEl>
37+
);
38+
39+
export default Header;

0 commit comments

Comments
 (0)