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 {render} from 'react-dom'
|
||||
import {normalizeRelayURL} from 'nostr-tools/relay'
|
||||
import {generatePrivateKey} from 'nostr-tools/keys'
|
||||
|
||||
import {getPermissionsString, readPermissions} from './common'
|
||||
|
||||
@@ -98,11 +99,14 @@ function Options() {
|
||||
<label>
|
||||
<div>private key: </div>
|
||||
<div style={{marginLeft: '10px'}}>
|
||||
<input
|
||||
style={{width: '500px'}}
|
||||
value={key}
|
||||
onChange={handleKeyChange}
|
||||
/>
|
||||
<div style={{display: 'flex'}}>
|
||||
<input
|
||||
style={{width: '500px'}}
|
||||
value={key}
|
||||
onChange={handleKeyChange}
|
||||
/>
|
||||
{key === '' && <button onClick={generate}>generate</button>}
|
||||
</div>
|
||||
<button
|
||||
disabled={!(key.match(/^[a-f0-9]{64}$/) || key === '')}
|
||||
onClick={saveKey}
|
||||
@@ -152,6 +156,10 @@ function Options() {
|
||||
setKey(key)
|
||||
}
|
||||
|
||||
async function generate(e) {
|
||||
setKey(generatePrivateKey())
|
||||
}
|
||||
|
||||
async function saveKey() {
|
||||
await browser.storage.local.set({
|
||||
private_key: key
|
||||
|
||||
Reference in New Issue
Block a user