Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/components/SeedPhraseWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useState } from "react";
import { Alert } from "antd";
import localStorage from "../util/localStorage";

const WARNING_MESSAGE =
"GridPlus will never ask for your seed phrase, private keys, or recovery words. If asked, you may be on a phishing site.";

export const SeedPhraseWarning = ({ style }: { style?: React.CSSProperties }) => {
const [visible, setVisible] = useState(
!localStorage.getSeedWarningAcknowledged()
);

if (!visible) return null;

return (
<Alert
message={WARNING_MESSAGE}
type="warning"
showIcon
closable
afterClose={() => {
localStorage.setSeedWarningAcknowledged();
setVisible(false);
}}
style={{ marginBottom: "16px", textAlign: "left", ...style }}
/>
);
};
2 changes: 2 additions & 0 deletions src/components/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { Alert, Button, Card, Col, Input, Row, Modal } from "antd";
import { DesktopOutlined, LinkOutlined } from "@ant-design/icons";
import { Settings } from "./index";
import { SeedPhraseWarning } from "./SeedPhraseWarning";
import { constants } from "../util/helpers";
import { NameEditor } from "./NameEditor";
import { LoginData } from "../types/authentication";
Expand Down Expand Up @@ -362,6 +363,7 @@ class Connect extends React.Component<ConnectProps, ConnectState> {
/>
</div>
) : null}
<SeedPhraseWarning style={{ margin: "10px 0" }} />
{this.renderMsg()}
{tooLong ? (
<p>
Expand Down
2 changes: 2 additions & 0 deletions src/components/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import React from "react";
import { useFeature } from "../hooks/useFeature";
import { PageContent } from "./index";
import { LandingCard } from "./LandingCard";
import { SeedPhraseWarning } from "./SeedPhraseWarning";

const Landing = ({ goToPage }) => {
const { USES_AUTO_ABI } = useFeature();
Expand All @@ -37,6 +38,7 @@ const Landing = ({ goToPage }) => {
justifyItems: "center",
}}
>
<SeedPhraseWarning />
<div
style={{
display: "flex",
Expand Down
2 changes: 2 additions & 0 deletions src/components/pair.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Card, Input } from 'antd'
import { PageContent } from './index'
import { SeedPhraseWarning } from './SeedPhraseWarning';
import { AppContext } from '../store/AppContext';
const SUBMIT_LEN = 8; // 8 characters in a code

Expand Down Expand Up @@ -64,6 +65,7 @@ class Pair extends React.Component<any, any> {
const content = (
<center>
<Card title="Enter Secret" bordered={true} id='secret-card'>
<SeedPhraseWarning />
<p></p>
<p>Please enter the pairing secret displayed on your Lattice screen:</p>
<Input
Expand Down
2 changes: 2 additions & 0 deletions src/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Button, Card, Col, Collapse, Input, Radio, Row, Space, Table } from 'antd'
import { WarningOutlined } from '@ant-design/icons';
import { PageContent } from './index'
import { SeedPhraseWarning } from './SeedPhraseWarning';
import omit from "lodash/omit"
import { constants, getBtcPurpose } from '../util/helpers';
import localStorage from '../util/localStorage';
Expand Down Expand Up @@ -213,6 +214,7 @@ class Settings extends React.Component<any, any> {
renderCard() {
return (
<div>
<SeedPhraseWarning />
{this.renderKeyringsSetting()}
{this.renderCustomEndpointSetting()}
{this.renderBitcoinVersionSetting()}
Expand Down
12 changes: 12 additions & 0 deletions src/util/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ const removeRootStoreItem = (key) =>

// #endregion

// #region -- Seed Phrase Warning Functions (sessionStorage - resets each browser session)

const SEED_WARNING_KEY = "gridplus_seed_phrase_warning_ack";
const getSeedWarningAcknowledged = (): boolean =>
window.sessionStorage.getItem(SEED_WARNING_KEY) === "true";
const setSeedWarningAcknowledged = (): void =>
window.sessionStorage.setItem(SEED_WARNING_KEY, "true");

// #endregion

// #region -- Settings Functions

const getSettings = () => getRootStoreItem("settings");
Expand Down Expand Up @@ -151,6 +161,8 @@ const exports = {
getRootStoreItem,
setRootStoreItem,
removeRootStoreItem,
getSeedWarningAcknowledged,
setSeedWarningAcknowledged,
getSettings,
setSettings,
getLoginId,
Expand Down