diff --git a/hbs2-core/lib/HBS2/Net/Auth/AccessKey.hs b/hbs2-core/lib/HBS2/Net/Auth/AccessKey.hs index eb7f92fd..cb33a652 100644 --- a/hbs2-core/lib/HBS2/Net/Auth/AccessKey.hs +++ b/hbs2-core/lib/HBS2/Net/Auth/AccessKey.hs @@ -72,25 +72,12 @@ instance Serialise (GroupKey e 'NaClAsymm) newtype AsGroupKeyFile a = AsGroupKeyFile a ----- FIXME: integration-regression-test-for-groupkey ----- Добавить тест: сгенерировали groupkey/распарсили groupkey +-- FIXME: integration-regression-test-for-groupkey +-- Добавить тест: сгенерировали groupkey/распарсили groupkey parseGroupKey :: forall e . () => AsGroupKeyFile ByteString -> Maybe (GroupKey e 'NaClAsymm) - -parseGroupKey (AsGroupKeyFile bs) = maybe1 b58_1 Nothing fromCbor - - where - fromCbor s = deserialiseOrFail @(GroupKey e 'NaClAsymm) s - & either (const Nothing) Just - - b58_1 = B8.lines bs & dropWhile hdr - & filter ( not . B8.null ) - & B8.concat - & fromBase58 - & fmap LBS.fromStrict - - hdr s = B8.isPrefixOf "#" s || B8.null s +parseGroupKey (AsGroupKeyFile bs) = parseSerialisableFromBase58 bs instance ( Serialise (GroupKey e s) ) diff --git a/hbs2-core/lib/HBS2/Net/Auth/Credentials.hs b/hbs2-core/lib/HBS2/Net/Auth/Credentials.hs index 535d5508..1f0b88c9 100644 --- a/hbs2-core/lib/HBS2/Net/Auth/Credentials.hs +++ b/hbs2-core/lib/HBS2/Net/Auth/Credentials.hs @@ -125,11 +125,12 @@ parseCredentials :: forall e . ( Signatures e , SerialisedCredentials e ) => AsCredFile ByteString -> Maybe (PeerCredentials e) +parseCredentials (AsCredFile bs) = parseSerialisableFromBase58 bs -parseCredentials (AsCredFile bs) = maybe1 b58_1 Nothing fromCbor - +parseSerialisableFromBase58 :: Serialise a => ByteString -> Maybe a +parseSerialisableFromBase58 bs = maybe1 b58_1 Nothing fromCbor where - fromCbor s = deserialiseOrFail @(PeerCredentials e) s + fromCbor s = deserialiseOrFail s & either (const Nothing) Just b58_1 = B8.lines bs & dropWhile hdr diff --git a/hbs2/Main.hs b/hbs2/Main.hs index 39aa5f3c..5a712b0d 100644 --- a/hbs2/Main.hs +++ b/hbs2/Main.hs @@ -351,7 +351,7 @@ main = join . customExecParser (prefs showHelpOnError) $ init <- optional $ flag' True ( long "init" <> help "just init storage") <&> OptInit groupkeyFile <- optional $ strOption ( long "groupkey" <> help "path to groupkey file" ) encoptKeyringFile <- optional $ strOption ( long "keyring" <> help "path to keyring file" ) - encoptFromPubKey <- optional $ strOption ( metavar "PUB-KEY-BAS58" ) + encoptFromPubKey <- optional $ strOption ( metavar "PUB-KEY-BASE58" ) pure do let encOps :: Maybe (OptEncryption MerkleEncryptionType) encOps = groupkeyFile <&> \encoptGroupkeyFile -> OptEncryption{..} @@ -391,7 +391,7 @@ main = join . customExecParser (prefs showHelpOnError) $ pKeyDel = do - s <- strArgument ( metavar "PUB-KEY-BAS58" ) + s <- strArgument ( metavar "PUB-KEY-BASE58" ) f <- strArgument ( metavar "KEYRING-FILE" ) pure (runKeyDel s f)