mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-18 03:03:31 +00:00
update unlock page
This commit is contained in:
parent
a099f4fc85
commit
5787eff7d5
@ -17,7 +17,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@headlessui/react": "^1.7.15",
|
||||
"@nostr-dev-kit/ndk": "^0.7.4",
|
||||
"@nostr-dev-kit/ndk": "^0.7.5",
|
||||
"@radix-ui/react-popover": "^1.0.6",
|
||||
"@radix-ui/react-tooltip": "^1.0.6",
|
||||
"@tanstack/react-query": "^4.29.19",
|
||||
|
@ -5,8 +5,8 @@ dependencies:
|
||||
specifier: ^1.7.15
|
||||
version: 1.7.15(react-dom@18.2.0)(react@18.2.0)
|
||||
'@nostr-dev-kit/ndk':
|
||||
specifier: ^0.7.4
|
||||
version: 0.7.4(typescript@4.9.5)
|
||||
specifier: ^0.7.5
|
||||
version: 0.7.5(typescript@4.9.5)
|
||||
'@radix-ui/react-popover':
|
||||
specifier: ^1.0.6
|
||||
version: 1.0.6(@types/react-dom@18.2.6)(@types/react@18.2.14)(react-dom@18.2.0)(react@18.2.0)
|
||||
@ -904,8 +904,8 @@ packages:
|
||||
'@nodelib/fs.scandir': 2.1.5
|
||||
fastq: 1.15.0
|
||||
|
||||
/@nostr-dev-kit/ndk@0.7.4(typescript@4.9.5):
|
||||
resolution: {integrity: sha512-wMNv9CREN8j40KERIvfXxCCg08CIP6VPUjlFI+Jg9+MTPoqvt0Vpwo/lD8lhWWJNPwC3RRyr4ywogApB9tevbA==}
|
||||
/@nostr-dev-kit/ndk@0.7.5(typescript@4.9.5):
|
||||
resolution: {integrity: sha512-P3hcvWq0jMlTBiasMtcqP2FclGwVks1LIwhRhyJb5XesLEYvnWh1wBWnx3+UQCj9uuu7fBMkmrY7AAi3CTuaXA==}
|
||||
dependencies:
|
||||
'@noble/hashes': 1.3.1
|
||||
'@noble/secp256k1': 2.0.0
|
||||
@ -937,7 +937,7 @@ packages:
|
||||
resolution: {integrity: sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==}
|
||||
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
|
||||
dependencies:
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
dev: false
|
||||
|
||||
/@pkgjs/parseargs@0.11.0:
|
||||
@ -1814,7 +1814,7 @@ packages:
|
||||
graphemer: 1.4.0
|
||||
ignore: 5.2.4
|
||||
natural-compare-lite: 1.4.0
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
tsutils: 3.21.0(typescript@4.9.5)
|
||||
typescript: 4.9.5
|
||||
transitivePeerDependencies:
|
||||
@ -1883,7 +1883,7 @@ packages:
|
||||
debug: 4.3.4
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
tsutils: 3.21.0(typescript@4.9.5)
|
||||
typescript: 4.9.5
|
||||
transitivePeerDependencies:
|
||||
@ -1903,7 +1903,7 @@ packages:
|
||||
'@typescript-eslint/typescript-estree': 5.61.0(typescript@4.9.5)
|
||||
eslint: 8.44.0
|
||||
eslint-scope: 5.1.1
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
@ -2126,7 +2126,7 @@ packages:
|
||||
postcss: ^8.1.0
|
||||
dependencies:
|
||||
browserslist: 4.21.9
|
||||
caniuse-lite: 1.0.30001513
|
||||
caniuse-lite: 1.0.30001514
|
||||
fraction.js: 4.2.0
|
||||
normalize-range: 0.1.2
|
||||
picocolors: 1.0.0
|
||||
@ -2184,8 +2184,8 @@ packages:
|
||||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
caniuse-lite: 1.0.30001513
|
||||
electron-to-chromium: 1.4.453
|
||||
caniuse-lite: 1.0.30001514
|
||||
electron-to-chromium: 1.4.454
|
||||
node-releases: 2.0.13
|
||||
update-browserslist-db: 1.0.11(browserslist@4.21.9)
|
||||
dev: true
|
||||
@ -2204,7 +2204,7 @@ packages:
|
||||
dependencies:
|
||||
'@npmcli/fs': 3.1.0
|
||||
fs-minipass: 3.0.2
|
||||
glob: 10.3.1
|
||||
glob: 10.3.3
|
||||
lru-cache: 7.18.3
|
||||
minipass: 5.0.0
|
||||
minipass-collect: 1.0.2
|
||||
@ -2245,8 +2245,8 @@ packages:
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/caniuse-lite@1.0.30001513:
|
||||
resolution: {integrity: sha512-pnjGJo7SOOjAGytZZ203Em95MRM8Cr6jhCXNF/FAXTpCTRTECnqQWLpiTRqrFtdYcth8hf4WECUpkezuYsMVww==}
|
||||
/caniuse-lite@1.0.30001514:
|
||||
resolution: {integrity: sha512-ENcIpYBmwAAOm/V2cXgM7rZUrKKaqisZl4ZAI520FIkqGXUxJjmaIssbRW5HVVR5tyV6ygTLIm15aU8LUmQSaQ==}
|
||||
dev: true
|
||||
|
||||
/chalk@2.4.2:
|
||||
@ -2402,7 +2402,7 @@ packages:
|
||||
resolution: {integrity: sha512-cllzD6IU/mzXBs5OdQVWL3+ne5Elpu3Wdm7h5OldMbGXk76yr9XzHlQXWJ4zfs0ZAibe26rkbs4KvMAJm7fIZA==}
|
||||
engines: {node: '>=14.x'}
|
||||
dependencies:
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
dev: false
|
||||
|
||||
/cross-env@7.0.3:
|
||||
@ -2625,8 +2625,8 @@ packages:
|
||||
/eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
/electron-to-chromium@1.4.453:
|
||||
resolution: {integrity: sha512-BU8UtQz6CB3T7RIGhId4BjmjJVXQDujb0+amGL8jpcluFJr6lwspBOvkUbnttfpZCm4zFMHmjrX1QrdPWBBMjQ==}
|
||||
/electron-to-chromium@1.4.454:
|
||||
resolution: {integrity: sha512-pmf1rbAStw8UEQ0sr2cdJtWl48ZMuPD9Sto8HVQOq9vx9j2WgDEN6lYoaqFvqEHYOmGA9oRGn7LqWI9ta0YugQ==}
|
||||
dev: true
|
||||
|
||||
/emoji-regex@8.0.0:
|
||||
@ -3047,7 +3047,7 @@ packages:
|
||||
dependencies:
|
||||
create-esm-loader: 0.2.3
|
||||
npm-run-all: 4.1.5
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
typescript: 5.1.6
|
||||
dev: false
|
||||
|
||||
@ -3325,8 +3325,8 @@ packages:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
||||
/glob@10.3.1:
|
||||
resolution: {integrity: sha512-9BKYcEeIs7QwlCYs+Y3GBvqAMISufUS0i2ELd11zpZjxI5V9iyRj0HgzB5/cLf2NY4vcYBTYzJ7GIui7j/4DOw==}
|
||||
/glob@10.3.3:
|
||||
resolution: {integrity: sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
@ -3334,7 +3334,7 @@ packages:
|
||||
jackspeak: 2.2.1
|
||||
minimatch: 9.0.3
|
||||
minipass: 5.0.0
|
||||
path-scurry: 1.10.0
|
||||
path-scurry: 1.10.1
|
||||
dev: false
|
||||
|
||||
/glob@7.1.6:
|
||||
@ -4243,7 +4243,7 @@ packages:
|
||||
nopt: 6.0.0
|
||||
npmlog: 6.0.2
|
||||
rimraf: 3.0.2
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
tar: 6.1.15
|
||||
which: 2.0.2
|
||||
transitivePeerDependencies:
|
||||
@ -4277,7 +4277,7 @@ packages:
|
||||
dependencies:
|
||||
hosted-git-info: 4.1.0
|
||||
is-core-module: 2.12.1
|
||||
semver: 7.5.3
|
||||
semver: 7.5.4
|
||||
validate-npm-package-license: 3.0.4
|
||||
dev: false
|
||||
|
||||
@ -4532,8 +4532,8 @@ packages:
|
||||
/path-parse@1.0.7:
|
||||
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
|
||||
|
||||
/path-scurry@1.10.0:
|
||||
resolution: {integrity: sha512-tZFEaRQbMLjwrsmidsGJ6wDMv0iazJWk6SfIKnY4Xru8auXgmJkOBa5DUbYFcFD2Rzk2+KDlIiF0GVXNCbgC7g==}
|
||||
/path-scurry@1.10.1:
|
||||
resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
dependencies:
|
||||
lru-cache: 10.0.0
|
||||
@ -5110,8 +5110,8 @@ packages:
|
||||
resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==}
|
||||
hasBin: true
|
||||
|
||||
/semver@7.5.3:
|
||||
resolution: {integrity: sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==}
|
||||
/semver@7.5.4:
|
||||
resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
|
524
src-tauri/Cargo.lock
generated
524
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
||||
import { getPublicKey } from 'nostr-tools';
|
||||
import { useState } from 'react';
|
||||
import { Resolver, useForm } from 'react-hook-form';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@ -30,10 +29,13 @@ const resolver: Resolver<FormValues> = async (values) => {
|
||||
|
||||
export function UnlockScreen() {
|
||||
const navigate = useNavigate();
|
||||
const setPassword = useStronghold((state) => state.setPassword);
|
||||
|
||||
const [passwordInput, setPasswordInput] = useState('password');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [setPrivkey, setPassword] = useStronghold((state) => [
|
||||
state.setPrivkey,
|
||||
state.setPassword,
|
||||
]);
|
||||
|
||||
const { account } = useAccount();
|
||||
const { load } = useSecureStorage();
|
||||
@ -61,22 +63,12 @@ export function UnlockScreen() {
|
||||
setPassword(data.password);
|
||||
|
||||
// load private in secure storage
|
||||
const privkey = await load(account.pubkey, data.password);
|
||||
|
||||
if (!privkey) {
|
||||
setLoading(false);
|
||||
setError('password', {
|
||||
type: 'custom',
|
||||
message: "Can't get private key",
|
||||
});
|
||||
}
|
||||
|
||||
const tempPubkey = getPublicKey(privkey);
|
||||
|
||||
if (tempPubkey === account.pubkey) {
|
||||
// redirect to next step
|
||||
try {
|
||||
const privkey = await load(account.pubkey, data.password);
|
||||
setPrivkey(privkey);
|
||||
// redirect to home
|
||||
navigate('/', { replace: true });
|
||||
} else {
|
||||
} catch {
|
||||
setLoading(false);
|
||||
setError('password', {
|
||||
type: 'custom',
|
||||
|
@ -2,12 +2,18 @@ import { create } from 'zustand';
|
||||
|
||||
interface StrongholdState {
|
||||
password: null | string;
|
||||
privkey: null | string;
|
||||
setPassword: (password: string) => void;
|
||||
setPrivkey: (privkey: string) => void;
|
||||
}
|
||||
|
||||
export const useStronghold = create<StrongholdState>((set) => ({
|
||||
password: null,
|
||||
privkey: null,
|
||||
setPassword: (password: string) => {
|
||||
set({ password: password });
|
||||
},
|
||||
setPrivkey: (privkey: string) => {
|
||||
set({ privkey: privkey });
|
||||
},
|
||||
}));
|
||||
|
@ -2,6 +2,8 @@ import { NDKEvent, NDKKind, NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
|
||||
|
||||
import { useNDK } from '@libs/ndk/provider';
|
||||
|
||||
import { useStronghold } from '@stores/stronghold';
|
||||
|
||||
import { useAccount } from '@utils/hooks/useAccount';
|
||||
import { useSecureStorage } from '@utils/hooks/useSecureStorage';
|
||||
|
||||
@ -10,6 +12,8 @@ export function usePublish() {
|
||||
const { account } = useAccount();
|
||||
const { load } = useSecureStorage();
|
||||
|
||||
const privkey = useStronghold((state) => state.privkey);
|
||||
|
||||
const publish = async ({
|
||||
content,
|
||||
kind,
|
||||
@ -19,10 +23,10 @@ export function usePublish() {
|
||||
kind: NDKKind;
|
||||
tags: string[][];
|
||||
}): Promise<NDKEvent> => {
|
||||
const privkey = await load(account.pubkey);
|
||||
const securePrivkey = await load(account.pubkey);
|
||||
|
||||
const event = new NDKEvent(ndk);
|
||||
const signer = new NDKPrivateKeySigner(privkey);
|
||||
const signer = new NDKPrivateKeySigner(privkey ? privkey : securePrivkey);
|
||||
|
||||
event.content = content;
|
||||
event.kind = kind;
|
||||
|
Loading…
Reference in New Issue
Block a user