-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from arconnectio/staging
ArConnect 1.7.0
- Loading branch information
Showing
19 changed files
with
704 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "arconnect", | ||
"displayName": "ArConnect", | ||
"version": "1.6.1", | ||
"version": "1.7.1", | ||
"description": "__MSG_extensionDescription__", | ||
"author": "th8ta", | ||
"packageManager": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Card, Spacer, Text } from "@arconnect/components"; | ||
import browser from "webextension-polyfill"; | ||
import { useMemo, useState } from "react"; | ||
import styled from "styled-components"; | ||
|
||
export default function Message({ message }: Props) { | ||
// message decode type | ||
const [decodeType, setDecodeType] = useState("UTF-8"); | ||
const availableDecodeTypes = [ | ||
"utf-8", | ||
"hex", | ||
"ibm866", | ||
"mac", | ||
"windows-1251", | ||
"gbk", | ||
"utf-16" | ||
]; | ||
|
||
// current message | ||
const msg = useMemo(() => { | ||
if (typeof message === "undefined") return ""; | ||
const messageBytes = new Uint8Array(message); | ||
|
||
// handle hex | ||
if (decodeType === "hex") { | ||
return [...new Uint8Array(messageBytes.buffer)] | ||
.map((v) => "0x" + v.toString(16).padStart(2, "0")) | ||
.join(" "); | ||
} | ||
|
||
// handle other types | ||
return new TextDecoder(decodeType).decode(messageBytes); | ||
}, [message, decodeType]); | ||
|
||
return ( | ||
<> | ||
<MessageHeader> | ||
<Text noMargin>{browser.i18n.getMessage("signature_message")}</Text> | ||
<EncodingSelect onChange={(e) => setDecodeType(e.target.value)}> | ||
{availableDecodeTypes.map((type, i) => ( | ||
<option value={type} key={i} selected={type === decodeType}> | ||
{type} | ||
</option> | ||
))} | ||
</EncodingSelect> | ||
</MessageHeader> | ||
<Spacer y={0.3} /> | ||
<Card smallPadding> | ||
<MessageText>{msg}</MessageText> | ||
</Card> | ||
</> | ||
); | ||
} | ||
|
||
interface Props { | ||
message?: number[]; | ||
} | ||
|
||
const MessageHeader = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
p, | ||
select { | ||
font-size: 0.95rem; | ||
} | ||
`; | ||
|
||
const EncodingSelect = styled.select` | ||
font-weight: 500; | ||
color: rgb(${(props) => props.theme.secondaryText}); | ||
outline: none; | ||
border: none; | ||
padding: 0; | ||
margin: 0; | ||
background-color: transparent; | ||
`; | ||
|
||
const MessageText = styled(Text).attrs({ | ||
noMargin: true | ||
})` | ||
font-size: 0.9rem; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.