on master help sign in
Prelogin works
1a5f0c1iko
backend/Main.purs+26−14
@@ -4,29 +4,41 @@ import Prelude
4
4
5import BW as WB
5import BW as WB
6import Bridge (Sub(..))
6import Bridge (Sub(..))
7+import Bridge as Bridge
8+import Control.Promise (toAff)
9+import Data.Argonaut as A
10+import Data.Either (Either(..))
11+import Data.Maybe (Maybe(..))
7−import Data.Nullable (null)
12+import Data.Nullable (null, toNullable)
8import Effect (Effect)
13import Effect (Effect)
14+import Effect.Aff (joinFiber, runAff, runAff_)
9import Effect.Console (log)
15import Effect.Console (log)
10import Elm as Elm
16import Elm as Elm
11import FFI as FFI
17import FFI as FFI
18+import Foreign as F
12
19
13
20
14main :: Effect Unit
21main :: Effect Unit
15main = do
22main = do
16− bwAPI <- WB.getAPI
17− { base : null,
18− webVault : null,
19− api : null,
20− identity : null,
21− icons : null,
22− notifications : null,
23− events : null,
24− keyConnector : null
25− }
26−
27 app <- FFI.startElm "elm"
23 app <- FFI.startElm "elm"
24+ Elm.subscribe app \(Bridge.Login (Bridge.Cmd_Login {email, server})) -> do
28− Elm.subscribe app \c -> log $ "Got cmd"
25+ log $ "Got cmd"
29− Elm.send app Hello
26+ bwAPI <- WB.getAPI
27+ { base : toNullable $ Just server,
28+ webVault : null,
29+ api : null,
30+ identity : null,
31+ icons : null,
32+ notifications : null,
33+ events : null,
34+ keyConnector : null
35+ }
36+ runAff_ (\res -> case res of
37+ Left _ -> log "Error"
38+ Right x -> log $ show x
39+ ) $ toAff $ bwAPI.postPrelogin {email}
40+ pure unit
30
41
42+ Elm.send app Hello
31
43
32 log "🍝"
44 log "🍝"
bw/src/BW.js+2−2
@@ -195,7 +195,7 @@ class BrowserPlatformUtilsService {
195 return device.replace("extension", "");
195 return device.replace("extension", "");
196 }
196 }
197 getClientType() {
197 getClientType() {
198− return ClientType.Browser;
198+ return "browser";
199 }
199 }
200 isFirefox() {
200 isFirefox() {
201 return this.getDevice() === DeviceType.FirefoxExtension;
201 return this.getDevice() === DeviceType.FirefoxExtension;
@@ -266,7 +266,7 @@ class BrowserPlatformUtilsService {
266 });
266 });
267 }
267 }
268 isDev() {
268 isDev() {
269− return process.env.ENV === "development";
269+ return false;
270 }
270 }
271 isSelfHost() {
271 isSelfHost() {
272 return false;
272 return false;
bw/src/BW.purs+73−73
@@ -9,8 +9,8 @@ import Data.Nullable (Nullable)
9import Effect (Effect)
9import Effect (Effect)
10
10
11type PreloginResponse = {
11type PreloginResponse = {
12− "Kdf" :: Int, -- seems to be always PBKDF2_SHA256
12+ kdf :: Int, -- seems to be always PBKDF2_SHA256
13− "KdfIterations" :: Int
13+ kdfIterations :: Int
14}
14}
15
15
16type PreloginRequest = {
16type PreloginRequest = {
@@ -18,63 +18,63 @@ type PreloginRequest = {
18}
18}
19
19
20type ProfileResponse = {
20type ProfileResponse = {
21− "Id" :: String,
21+ id :: String,
22− "Name" :: String,
22+ name :: String,
23− "Email" :: String,
23+ email :: String,
24− "EmailVerified" :: Boolean,
24+ emailVerified :: Boolean,
25− "MasterPasswordHint" :: String,
25+ masterPasswordHint :: String,
26− "Premium" :: Boolean,
26+ premiumPersonally :: Boolean,
27− "PremiumFromOrganization" :: Boolean,
27+ premiumFromOrganization :: Boolean,
28− "Culture" :: String,
28+ culture :: String,
29− "TwoFactorEnabled" :: Boolean,
29+ twoFactorEnabled :: Boolean,
30− "Key" :: String,
30+ key :: String,
31− "PrivateKey" :: String,
31+ privateKey :: String,
32− "SecurityStamp" :: String,
32+ securityStamp :: String,
33− "ForcePasswordReset" :: Boolean,
33+ forcePasswordReset :: Boolean,
34− "UsesKeyConnector" :: Boolean,
34+ usesKeyConnector :: Boolean,
35− "Organizations" :: List ProfileOrganizationResponse,
35+ organizations :: List ProfileOrganizationResponse,
36− "Providers" :: List ProfileProviderResponse,
36+ providers :: List ProfileProviderResponse,
37− "ProviderOrganizations" :: List ProfileProviderOrganizationResponse
37+ providerOrganizations :: List ProfileProviderOrganizationResponse
38}
38}
39
39
40type ProfileOrganizationResponse = {
40type ProfileOrganizationResponse = {
41− "Id" :: String,
41+ id :: String,
42− "Name" :: String,
42+ name :: String,
43− "UsePolicies" :: Boolean,
43+ usePolicies :: Boolean,
44− "UseGroups" :: Boolean,
44+ useGroups :: Boolean,
45− "UseDirectory" :: Boolean,
45+ useDirectory :: Boolean,
46− "UseEvents" :: Boolean,
46+ useEvents :: Boolean,
47− "UseTotp" :: Boolean,
47+ useTotp :: Boolean,
48− "Use2fa" :: Boolean,
48+ use2fa :: Boolean,
49− "UseApi" :: Boolean,
49+ useApi :: Boolean,
50− "UseSso" :: Boolean,
50+ useSso :: Boolean,
51− "UseKeyConnector" :: Boolean,
51+ useKeyConnector :: Boolean,
52− "UseResetPassword" :: Boolean,
52+ useResetPassword :: Boolean,
53− "SelfHost" :: Boolean,
53+ selfHost :: Boolean,
54− "UsersGetPremium" :: Boolean,
54+ usersGetPremium :: Boolean,
55− "Seats" :: Int,
55+ seats :: Int,
56− "MaxCollections" :: Int,
56+ maxCollections :: Int,
57− "MaxStorageGb" :: Nullable Int,
57+ maxStorageGb :: Nullable Int,
58− "Key" :: String,
58+ key :: String,
59− "HasPublicAndPrivateKeys" :: Boolean,
59+ hasPublicAndPrivateKeys :: Boolean,
60− "Status" :: OrganizationUserStatusType,
60+ status :: OrganizationUserStatusType,
61− "Type" :: OrganizationUserType,
61+ type :: OrganizationUserType,
62− "Enabled" :: Boolean,
62+ enabled :: Boolean,
63− "SsoBound" :: Boolean,
63+ ssoBound :: Boolean,
64− "Identifier" :: String,
64+ identifier :: String,
65− "permissions" :: PermissionsApi,
65+ permissions :: PermissionsApi,
66− "ResetPasswordEnrolled" :: Boolean,
66+ resetPasswordEnrolled :: Boolean,
67− "UserId" :: String,
67+ userId :: String,
68− "ProviderId" :: String,
68+ providerId :: String,
69− "ProviderName" :: String,
69+ providerName :: String,
70− "FamilySponsorshipFriendlyName" :: String,
70+ familySponsorshipFriendlyName :: String,
71− "FamilySponsorshipAvailable" :: Boolean,
71+ familySponsorshipAvailable :: Boolean,
72− "PlanProductType" :: ProductType,
72+ planProductType :: ProductType,
73− "KeyConnectorEnabled" :: Boolean,
73+ keyConnectorEnabled :: Boolean,
74− "KeyConnectorUrl" :: String,
74+ keyConnectorUrl :: String,
75− "FamilySponsorshipLastSyncDate" :: Nullable Date,
75+ familySponsorshipLastSyncDate :: Nullable Date,
76− "FamilySponsorshipValidUntil" :: Nullable Date,
76+ familySponsorshipValidUntil :: Nullable Date,
77− "FamilySponsorshipToDelete" :: Nullable Boolean
77+ familySponsorshipToDelete :: Nullable Boolean
78 }
78 }
79
79
80organizationUserStatusTypeInvited = 0 :: OrganizationUserStatusType
80organizationUserStatusTypeInvited = 0 :: OrganizationUserStatusType
@@ -90,22 +90,22 @@ organizationUserTypeCustom = 4 :: OrganizationUserType
90type OrganizationUserType = Int
90type OrganizationUserType = Int
91
91
92type PermissionsApi = {
92type PermissionsApi = {
93− "AccessEventLogs" :: Boolean,
93+ accessEventLogs :: Boolean,
94− "AccessImportExport" :: Boolean,
94+ accessImportExport :: Boolean,
95− "AccessReports" :: Boolean,
95+ accessReports :: Boolean,
96− "ManageAllCollections" :: Boolean,
96+ manageAllCollections :: Boolean,
97− "ManageAssignedCollections" :: Boolean,
97+ createNewCollections :: Boolean,
98− "CreateNewCollections" :: Boolean,
98+ editAnyCollection :: Boolean,
99− "EditAnyCollection" :: Boolean,
99+ deleteAnyCollection :: Boolean,
100− "DeleteAnyCollection" :: Boolean,
100+ manageAssignedCollections :: Boolean,
101− "EditAssignedCollections" :: Boolean,
101+ editAssignedCollections :: Boolean,
102− "DeleteAssignedCollections" :: Boolean,
102+ deleteAssignedCollections :: Boolean,
103− "ManageCiphers" :: Boolean,
103+ manageCiphers :: Boolean,
104− "ManageGroups" :: Boolean,
104+ manageGroups :: Boolean,
105− "ManageSso" :: Boolean,
105+ manageSso :: Boolean,
106− "ManagePolicies" :: Boolean,
106+ managePolicies :: Boolean,
107− "ManageUsers" :: Boolean,
107+ manageUsers :: Boolean,
108− "ManageResetPassword" :: Boolean
108+ manageResetPassword :: Boolean
109}
109}
110
110
111productTypeFree = 0 :: ProductType
111productTypeFree = 0 :: ProductType
@@ -151,6 +151,6 @@ type Urls = {
151type ApiService = {
151type ApiService = {
152 postPrelogin :: PreloginRequest -> Promise PreloginResponse,
152 postPrelogin :: PreloginRequest -> Promise PreloginResponse,
153 getProfile :: Unit -> Promise ProfileResponse
153 getProfile :: Unit -> Promise ProfileResponse
154− }
154+}
155
155
156foreign import getAPI :: Urls -> Effect ApiService
156foreign import getAPI :: Urls -> Effect ApiService
spago.dhall+1
@@ -21,6 +21,7 @@ to generate this file without the comments in this block.
21 , "console"
21 , "console"
22 , "effect"
22 , "effect"
23 , "either"
23 , "either"
24+ , "foreign"
24 , "maybe"
25 , "maybe"
25 , "newtype"
26 , "newtype"
26 , "nullable"
27 , "nullable"