mirror of https://github.com/voidlizard/hbs2
Drop keyring, pubkey opts from store command
This commit is contained in:
parent
4542e6595f
commit
feb9fdaa30
28
hbs2/Main.hs
28
hbs2/Main.hs
|
@ -68,22 +68,19 @@ newtype OptKeyringFile = OptKeyringFile { unOptKeyringFile :: FilePath }
|
||||||
deriving newtype (Eq,Ord,IsString)
|
deriving newtype (Eq,Ord,IsString)
|
||||||
deriving stock (Data)
|
deriving stock (Data)
|
||||||
|
|
||||||
|
newtype OptGroupkeyFile = OptGroupkeyFile { unOptGroupkeyFile :: FilePath }
|
||||||
|
deriving newtype (Eq,Ord,IsString)
|
||||||
|
deriving stock (Data)
|
||||||
|
|
||||||
newtype OptInit = OptInit { fromOptInit :: Bool }
|
newtype OptInit = OptInit { fromOptInit :: Bool }
|
||||||
deriving newtype (Eq,Ord,Pretty)
|
deriving newtype (Eq,Ord,Pretty)
|
||||||
deriving stock (Data,Generic)
|
deriving stock (Data,Generic)
|
||||||
|
|
||||||
data OptEncryption e = OptEncryption
|
data StoreOpts =
|
||||||
{ encoptGroupkeyFile :: FilePath
|
|
||||||
, encoptKeyringFile :: Maybe FilePath
|
|
||||||
, encoptFromPubKey :: Maybe Text
|
|
||||||
}
|
|
||||||
deriving stock (Data)
|
|
||||||
|
|
||||||
data StoreOpts e =
|
|
||||||
StoreOpts
|
StoreOpts
|
||||||
{ storeInit :: Maybe OptInit
|
{ storeInit :: Maybe OptInit
|
||||||
, storeInputFile :: Maybe OptInputFile
|
, storeInputFile :: Maybe OptInputFile
|
||||||
, storeEncryption :: Maybe (OptEncryption e)
|
, storeGroupkeyFile :: Maybe OptGroupkeyFile
|
||||||
}
|
}
|
||||||
deriving stock (Data)
|
deriving stock (Data)
|
||||||
|
|
||||||
|
@ -212,13 +209,13 @@ runStore opts ss = do
|
||||||
|
|
||||||
handle <- maybe (pure stdin) (flip openFile ReadMode . unOptFile) fname
|
handle <- maybe (pure stdin) (flip openFile ReadMode . unOptFile) fname
|
||||||
|
|
||||||
case (uniLastMay @(OptEncryption MerkleEncryptionType) opts) of
|
case (uniLastMay @OptGroupkeyFile opts) of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
root <- putAsMerkle ss handle
|
root <- putAsMerkle ss handle
|
||||||
print $ "merkle-root: " <+> pretty root
|
print $ "merkle-root: " <+> pretty root
|
||||||
Just encOpts -> do
|
Just gkfile -> do
|
||||||
gk :: GroupKey MerkleEncryptionType 'NaClAsymm
|
gk :: GroupKey MerkleEncryptionType 'NaClAsymm
|
||||||
<- (parseGroupKey . AsGroupKeyFile <$> BS.readFile (encoptGroupkeyFile encOpts))
|
<- (parseGroupKey . AsGroupKeyFile <$> BS.readFile (unOptGroupkeyFile gkfile))
|
||||||
`orDie` "bad groupkey file"
|
`orDie` "bad groupkey file"
|
||||||
|
|
||||||
accKeyh <- maybe (die "can not store access key") pure
|
accKeyh <- maybe (die "can not store access key") pure
|
||||||
|
@ -350,12 +347,7 @@ main = join . customExecParser (prefs showHelpOnError) $
|
||||||
file <- optional $ strArgument ( metavar "FILE" )
|
file <- optional $ strArgument ( metavar "FILE" )
|
||||||
init <- optional $ flag' True ( long "init" <> help "just init storage") <&> OptInit
|
init <- optional $ flag' True ( long "init" <> help "just init storage") <&> OptInit
|
||||||
groupkeyFile <- optional $ strOption ( long "groupkey" <> help "path to groupkey file" )
|
groupkeyFile <- optional $ strOption ( long "groupkey" <> help "path to groupkey file" )
|
||||||
encoptKeyringFile <- optional $ strOption ( long "keyring" <> help "path to keyring file" )
|
pure $ withStore o (runStore ( StoreOpts init file (OptGroupkeyFile <$> groupkeyFile) ))
|
||||||
encoptFromPubKey <- optional $ strOption ( metavar "PUB-KEY-BASE58" )
|
|
||||||
pure do
|
|
||||||
let encOps :: Maybe (OptEncryption MerkleEncryptionType)
|
|
||||||
encOps = groupkeyFile <&> \encoptGroupkeyFile -> OptEncryption{..}
|
|
||||||
withStore o (runStore ( StoreOpts init file encOps ))
|
|
||||||
|
|
||||||
pCat = do
|
pCat = do
|
||||||
o <- common
|
o <- common
|
||||||
|
|
Loading…
Reference in New Issue