File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ const minimalConfig = {
1515 name : "Untitled Identity" ,
1616} ;
1717
18+ function createDefaultIdentity ( ) {
19+ const appName = process . env . ssb_appname || "ssb" ;
20+ const defaultIdentityPath = path . join ( os . homedir ( ) , "." + appName , "secret" ) ;
21+
22+ if ( ! fs . existsSync ( defaultIdentityPath ) ) {
23+ fs . ensureDirSync ( path . basename ( defaultIdentityPath ) )
24+ const defaultKeys = ssbKeys . loadOrCreateSync ( defaultIdentityPath ) ;
25+ }
26+ }
27+
1828function getDefaultIdentity ( ) {
1929 const appName = process . env . ssb_appname || "ssb" ;
2030 const defaultIdentityPath = path . join ( os . homedir ( ) , "." + appName , "secret" ) ;
@@ -264,4 +274,5 @@ module.exports = {
264274 set,
265275 importFromKeys,
266276 importFromWords,
277+ createDefaultIdentity,
267278} ;
Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ const {
3131} = require ( "./lib/app-lifecycle.js" ) ;
3232const Identities = require ( "./lib/identities.js" ) ;
3333
34+ if ( process . defaultApp ) {
35+ if ( process . argv . length >= 2 ) {
36+ electron . app . setAsDefaultProtocolClient ( "ssb" , process . execPath , [
37+ Path . resolve ( process . argv [ 1 ] ) ,
38+ ] ) ;
39+ }
40+ } else {
41+ electron . app . setAsDefaultProtocolClient ( "ssb" ) ;
42+ }
43+
3444quitIfAlreadyRunning ( ) ;
3545
3646const config = {
@@ -54,7 +64,14 @@ electron.app.on("ready", () => {
5464 ) {
5565 openIdentitiesManager ( ) ;
5666 } else {
57- const identities = Identities . list ( ) ;
67+ let identities = Identities . list ( ) ;
68+
69+ if ( identities . length === 0 ) {
70+ console . log ( `No identities, oops...` )
71+ Identities . createDefaultIdentity ( )
72+ console . log ( `Default identity created!` )
73+ identities = Identities . list ( ) ;
74+ }
5875
5976 for ( const identity of identities ) {
6077 const configuration = Identities . configurationForIdentity (
You can’t perform that action at this time.
0 commit comments