Add Nostr `bunker` slice to redux store
This commit is contained in:
parent
38bc1641c5
commit
1223e3b9b6
|
@ -0,0 +1,42 @@
|
||||||
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary authorization details to establish a bunker connection with an app.
|
||||||
|
* Will be upgraded to a `BunkerConnection` once the connection is established.
|
||||||
|
*/
|
||||||
|
interface BunkerAuthorization {
|
||||||
|
/**
|
||||||
|
* Authorization secret generated by the bunker.
|
||||||
|
* The app should return it to us in its `connect` call to establish a connection.
|
||||||
|
*/
|
||||||
|
secret: string;
|
||||||
|
/** User pubkey. Events will be signed by this pubkey. */
|
||||||
|
pubkey: string;
|
||||||
|
/** Secret key for this connection. NIP-46 responses will be signed by this key. */
|
||||||
|
bunkerSeckey: Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bunker connection maps an OAuth token from Mastodon API to a user pubkey and bunker keypair.
|
||||||
|
* The user pubkey is used to determine whether to use keys from localStorage or a browser extension,
|
||||||
|
* and the bunker keypair is used to sign and encrypt NIP-46 messages.
|
||||||
|
*/
|
||||||
|
interface BunkerConnection {
|
||||||
|
/** User pubkey. Events will be signed by this pubkey. */
|
||||||
|
pubkey: string;
|
||||||
|
/** Mastodon API access token associated with this connection. */
|
||||||
|
accessToken: string;
|
||||||
|
/** Pubkey of the app authorized to sign events with this connection. */
|
||||||
|
authorizedPubkey: string;
|
||||||
|
/** Secret key for this connection. NIP-46 responses will be signed by this key. */
|
||||||
|
bunkerSeckey: Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createSlice({
|
||||||
|
name: 'bunker',
|
||||||
|
initialState: {
|
||||||
|
authorizations: [] as BunkerAuthorization[],
|
||||||
|
connections: [] as BunkerConnection[],
|
||||||
|
},
|
||||||
|
reducers: {},
|
||||||
|
});
|
Loading…
Reference in New Issue