soapbox/src/actions/nostr.ts

22 wiersze
537 B
TypeScript
Czysty Zwykły widok Historia

2023-10-04 23:03:26 +00:00
import { nip19 } from 'nostr-tools';
2024-02-11 18:40:14 +00:00
import { signer } from 'soapbox/features/nostr/sign';
2023-10-04 23:03:26 +00:00
import { type AppDispatch } from 'soapbox/store';
import { verifyCredentials } from './auth';
/** Log in with a Nostr pubkey. */
function nostrLogIn() {
return async (dispatch: AppDispatch) => {
if (!signer) {
throw new Error('No Nostr signer available');
}
2024-02-11 18:40:14 +00:00
const pubkey = await signer.getPublicKey();
2023-10-04 23:03:26 +00:00
const npub = nip19.npubEncode(pubkey);
return dispatch(verifyCredentials(npub));
};
}
export { nostrLogIn };