button to generate key.
fixes https://github.com/fiatjaf/nos2x/issues/11
This commit is contained in:
@@ -2,6 +2,7 @@ import browser from 'webextension-polyfill'
|
|||||||
import React, {useState, useCallback, useEffect} from 'react'
|
import React, {useState, useCallback, useEffect} from 'react'
|
||||||
import {render} from 'react-dom'
|
import {render} from 'react-dom'
|
||||||
import {normalizeRelayURL} from 'nostr-tools/relay'
|
import {normalizeRelayURL} from 'nostr-tools/relay'
|
||||||
|
import {generatePrivateKey} from 'nostr-tools/keys'
|
||||||
|
|
||||||
import {getPermissionsString, readPermissions} from './common'
|
import {getPermissionsString, readPermissions} from './common'
|
||||||
|
|
||||||
@@ -98,11 +99,14 @@ function Options() {
|
|||||||
<label>
|
<label>
|
||||||
<div>private key: </div>
|
<div>private key: </div>
|
||||||
<div style={{marginLeft: '10px'}}>
|
<div style={{marginLeft: '10px'}}>
|
||||||
<input
|
<div style={{display: 'flex'}}>
|
||||||
style={{width: '500px'}}
|
<input
|
||||||
value={key}
|
style={{width: '500px'}}
|
||||||
onChange={handleKeyChange}
|
value={key}
|
||||||
/>
|
onChange={handleKeyChange}
|
||||||
|
/>
|
||||||
|
{key === '' && <button onClick={generate}>generate</button>}
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
disabled={!(key.match(/^[a-f0-9]{64}$/) || key === '')}
|
disabled={!(key.match(/^[a-f0-9]{64}$/) || key === '')}
|
||||||
onClick={saveKey}
|
onClick={saveKey}
|
||||||
@@ -152,6 +156,10 @@ function Options() {
|
|||||||
setKey(key)
|
setKey(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function generate(e) {
|
||||||
|
setKey(generatePrivateKey())
|
||||||
|
}
|
||||||
|
|
||||||
async function saveKey() {
|
async function saveKey() {
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
private_key: key
|
private_key: key
|
||||||
|
|||||||
Reference in New Issue
Block a user