Skip to content

Commit

Permalink
Fix fission-cli type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Jan 25, 2022
1 parent 90dbe16 commit ba6e4ba
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
7 changes: 2 additions & 5 deletions fission-cli/library/Fission/CLI/Connected.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Network.IPFS.Process.Error as IPFS.Process
import qualified Network.IPFS.Timeout.Types as IPFS
import qualified Network.IPFS.Types as IPFS

import Web.DID.Types
import Web.DID.Types as DID

import qualified Web.UCAN.Resolver.Error as UCAN.Resolver

Expand Down Expand Up @@ -155,10 +155,7 @@ mkConnected inCfg ipfsTimeout = do
let
ignoredFiles = Environment.ignored config

cliDID = DID
{ publicKey = Key.Ed25519PublicKey $ Ed25519.toPublic secretKey
, method = Key
}
cliDID = DID.Key $ Key.Ed25519PublicKey $ Ed25519.toPublic secretKey

cfg = Config { httpManager = getField @"httpManager" inCfg, ..}

Expand Down
4 changes: 2 additions & 2 deletions fission-cli/library/Fission/CLI/Handler/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RIO.FilePath
import Network.DNS as DNS
import Servant.Client

import Web.DID.Types
import Web.DID.Types as DID
import qualified Web.UCAN.Types as UCAN


Expand Down Expand Up @@ -96,7 +96,7 @@ setup maybeOS maybeUsername maybeEmail maybeKeyFile = do
Right username -> do
baseURL <- getRemoteBaseUrl
signingPK <- Key.Store.fetchPublic (Proxy @SigningKey)
_ <- WNFS.create (DID Key $ Key.Ed25519PublicKey signingPK) "/"
_ <- WNFS.create (DID.Key $ Key.Ed25519PublicKey signingPK) "/"
Env.init username baseURL Nothing
Display.putOk $ "Done! Welcome to Fission, " <> textDisplay username <> ""

Expand Down
8 changes: 4 additions & 4 deletions fission-cli/library/Fission/CLI/Handler/User/Login.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import qualified Fission.Web.Serialization as Web.Serializatio

-- 🛂 JWT/UCAN

import Web.DID.Types
import Web.DID.Types as DID
import qualified Web.UCAN.Claims.Error as UCAN.Claims
import qualified Web.UCAN.Proof as UCAN.Proof
import qualified Web.UCAN.Resolver.Class as UCAN
Expand Down Expand Up @@ -159,15 +159,15 @@ consume signingSK baseURL optUsername = do
signingPK <- Key.Store.toPublic (Proxy @SigningKey) signingSK

let
myDID = DID Key (Ed25519PublicKey signingPK)
myDID = DID.Key (Ed25519PublicKey signingPK)
topic = PubSub.Topic $ textDisplay targetDID

PubSub.connect baseURL topic \conn -> reattempt 10 do
logDebug @Text "🤝 Device linking handshake: Step 1"
aesConn <- secure conn () \(rsaConn :: Secure.Connection m (RSA.PublicKey, RSA.PrivateKey)) -> reattempt 10 do
let
Secure.Connection {key = (pk, _sk)} = rsaConn
sessionDID = DID Key (RSAPublicKey pk)
sessionDID = DID.Key (RSAPublicKey pk)

logDebug @Text "🤝 Device linking handshake: Step 2"
broadcastApiData conn sessionDID
Expand Down Expand Up @@ -274,7 +274,7 @@ produce signingSK baseURL = do

secure conn () \(rsaConn@Secure.Connection {key = (_, sk)} :: Secure.Connection m (RSA.PublicKey, RSA.PrivateKey)) -> reattempt 10 do
logDebug @Text "🤝 Device linking handshake: Step 2"
requestorTempDID@(DID _ tmpPK) <- listenRaw conn
requestorTempDID@(DID.Key tmpPK) <- listenRaw conn

case tmpPK of
Ed25519PublicKey _ ->
Expand Down
4 changes: 2 additions & 2 deletions fission-cli/library/Fission/CLI/Handler/User/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Fission.User.Username.Types
import Fission.Web.Auth.Token.Types
import Fission.Web.Client as Client

import Web.DID.Types
import Web.DID.Types as DID
import qualified Web.UCAN.Types as UCAN

import Fission.User.Email.Types
Expand Down Expand Up @@ -124,7 +124,7 @@ createAccount maybeUsername maybeEmail = do

exchangePK <- KeyStore.fetchPublic (Proxy @ExchangeKey)
signingPK <- KeyStore.fetchPublic (Proxy @SigningKey)
_ <- WNFS.create (DID Key $ Key.Ed25519PublicKey signingPK) "/"
_ <- WNFS.create (DID.Key $ Key.Ed25519PublicKey signingPK) "/"

let
form = Registration
Expand Down
6 changes: 3 additions & 3 deletions fission-web-server/library/Fission/Web/Server/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,19 @@ instance User.Modifier Server where
runUserUpdate updatePK pkToText uID "_did"
where
updatePK = User.updatePublicKeyDB uID pk now
pkToText pk' = textDisplay (DID Key pk')
pkToText pk' = textDisplay (DID.Key pk')

addExchangeKey uID key now =
runUserUpdate addKey keysToText uID "_exchange"
where
addKey = User.addExchangeKeyDB uID key now
keysToText keys = Text.intercalate "," (textDisplay . DID Key . Key.RSAPublicKey <$> keys)
keysToText keys = Text.intercalate "," (textDisplay . DID.Key . Key.RSAPublicKey <$> keys)

removeExchangeKey uID key now =
runUserUpdate removeKey keysToText uID "_exchange"
where
removeKey = User.removeExchangeKeyDB uID key now
keysToText keys = Text.intercalate "," (textDisplay . DID Key . Key.RSAPublicKey <$> keys)
keysToText keys = Text.intercalate "," (textDisplay . DID.Key . Key.RSAPublicKey <$> keys)

setData userId newCID now = do
runDB (User.getById userId) >>= \case
Expand Down
4 changes: 2 additions & 2 deletions fission-web-server/test/Fission/Test/Web/Server/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import qualified Fission.Web.API.Heroku.Auth.Types as Heroku
import Fission.Web.Server.Auth
import Fission.Web.Server.Auth.Token.Basic.Class
import Fission.Web.Server.Authorization.Types
import Web.DID.Types
import Web.DID.Types as DID

import qualified Fission.Test.Web.Server.Auth.Token as Token

Expand All @@ -41,7 +41,7 @@ spec =

context "DID auth" do
it "uses the encapsulated function" do
didResult `shouldBe` Right (DID Key Ed25519.pk)
didResult `shouldBe` Right (DID.Key Ed25519.pk)

context "heroku auth" do
it "uses the encapsulated function" do
Expand Down

0 comments on commit ba6e4ba

Please sign in to comment.