@@ -15,7 +15,6 @@ import Data.JNullable as JNullable
1515import Data.JOpt (JOpt(..), fromJOpt)
1616import Data.Maybe (Maybe(..), fromMaybe, maybe)
1717import Data.Newtype (class Newtype, unwrap, wrap)
18−import Data.Number.Format as Number
1918import Data.String as String
2019import Data.SymmetricCryptoKey (SymmetricCryptoKey)
2120import Data.SymmetricCryptoKey as SymmetricCryptoKey
@@ -27,14 +26,10 @@ import Effect.Aff.Class (class MonadAff, liftAff)
2726import Effect.Class (liftEffect)
2827import Effect.Exception (error)
2928import Effect.Exception as Exc
30−import Effect.Random (random)
31−import Localstorage as Storage
3229import Run (Run)
3330import Run.Reader (Reader, askAt)
34−import Storage (DeviceIDKey(..))
3531import Type.Prelude (Proxy(..))
3632import Untagged.Union (type (|+|))
37−import Web.Storage.Storage (Storage)
3833
3934-- | Creates the master key
4035makePreloginKey
@@ -101,7 +96,6 @@ getLogInRequestToken
10196 , crypto :: Reader CryptoService
10297 , effect :: Effect
10398 , aff :: Aff
104− , storage :: Reader Storage
10599 | r
106100 )
107101 (IdentityCaptchaResponse |+| IdentityTwoFactorResponse |+| IdentityTokenResponse)
@@ -112,8 +106,6 @@ getLogInRequestToken
112106 , captchaResponse
113107 , secondFactor: Bridge.Cmd_Login_secondFactor_Maybe secondFactor
114108 } = do
115− key <- makePreloginKey prelogin email password
116− crypto <- askAt (Proxy :: _ "crypto")
117109 let
118110 twoFactor =
119111 maybe
@@ -125,11 +117,7 @@ getLogInRequestToken
125117 x { provider = bridgeToSecondFactorType provider }
126118 )
127119 secondFactor
128− _localHashedPassword <-
129− liftPromise
130− $ runFn3 crypto.hashPassword password key (nullify hashPurposeLocalAuthorization)
131− StringHash hashedPassword <- liftPromise $ runFn3 crypto.hashPassword password key jnull
132− deviceId <- getDeviceID
120+ StringHash hashedPassword <- bwPasswordStringHash prelogin email password
133121 api :: ApiService <- askAt (Proxy :: _ "api")
134122 liftPromise
135123 $ api.postIdentityToken
@@ -140,7 +128,7 @@ getLogInRequestToken
140128 , device:
141129 { type: deviceTypeUnknownBrowser
142130 , name: "Ubuntu Touch"
143− , identifier: deviceId
131+ , identifier: "42"
144132 , pushToken: jnull
145133 }
146134 }
@@ -492,21 +480,3 @@ encryptNullable
492480encryptNullable x = case unwrap x of
493481 Nothing -> pure jnull
494482 Just y -> nullify <$> encrypt y
495−
496−getDeviceID ::
497− forall r.
498− Run
499− ( effect :: Effect
500− , storage :: Reader Storage
501− | r
502− )
503− String
504−getDeviceID = do
505− storage <- askAt (Proxy :: _ "storage")
506− maybeId <- liftEffect $ Storage.get storage DeviceIDKey
507− case maybeId of
508− Just id -> pure id
509− Nothing -> do
510− id <- map Number.toString $ liftEffect $ random
511− liftEffect $ Storage.store storage DeviceIDKey id
512− pure id