@@ -2,17 +2,21 @@ module BW.Types where
22
33import Prelude
44
5−import Data.ArrayBuffer.Types (ArrayBuffer)
5+import Data.Argonaut (class DecodeJson, class EncodeJson)
66import Data.Date (Date)
7−import Data.Nullable (Nullable)
7+import Data.JNullable (JNullable)
8+import Data.JOpt (JOpt)
89import Data.ShowableJson (ShowableJson)
910import Data.Timestamp (Timestamp(..))
10−import Data.Undefined.NoProblem (Opt)
1111
1212newtype EncryptedString
1313 = EncryptedString String
1414
1515derive newtype instance Show EncryptedString
16+derive newtype instance Ord EncryptedString
17+derive newtype instance Eq EncryptedString
18+derive newtype instance EncodeJson EncryptedString
19+derive newtype instance DecodeJson EncryptedString
1620
1721kdfPBKDF2_SHA256 = 0 :: KDF
1822
@@ -35,7 +39,7 @@ type ProfileResponse
3539 , emailVerified :: Boolean
3640 , masterPasswordHint :: String
3741 , premiumPersonally :: Boolean
38− , premiumFromOrganization :: Boolean
42+ -- , premiumFromOrganization :: Boolean
3943 , culture :: String
4044 , twoFactorEnabled :: Boolean
4145 , key :: EncryptedString
@@ -65,7 +69,7 @@ type ProfileOrganizationResponse
6569 , usersGetPremium :: Boolean
6670 , seats :: Int
6771 , maxCollections :: Int
68− , maxStorageGb :: Nullable Int
72+ , maxStorageGb :: JNullable Int
6973 , key :: String
7074 , hasPublicAndPrivateKeys :: Boolean
7175 , status :: OrganizationUserStatusType
@@ -83,9 +87,9 @@ type ProfileOrganizationResponse
8387 , planProductType :: ProductType
8488 , keyConnectorEnabled :: Boolean
8589 , keyConnectorUrl :: String
86− , familySponsorshipLastSyncDate :: Nullable Date
87− , familySponsorshipValidUntil :: Nullable Date
88− , familySponsorshipToDelete :: Nullable Boolean
90+ , familySponsorshipLastSyncDate :: JNullable Timestamp
91+ , familySponsorshipValidUntil :: JNullable Timestamp
92+ , familySponsorshipToDelete :: JNullable Boolean
8993 }
9094
9195organizationUserStatusTypeInvited = 0 :: OrganizationUserStatusType
@@ -185,7 +189,7 @@ type ProfileProviderOrganizationResponse
185189 , usersGetPremium :: Boolean
186190 , seats :: Int
187191 , maxCollections :: Int
188− , maxStorageGb :: Nullable Int
192+ , maxStorageGb :: JNullable Int
189193 , key :: String
190194 , hasPublicAndPrivateKeys :: Boolean
191195 , status :: OrganizationUserStatusType
@@ -203,20 +207,20 @@ type ProfileProviderOrganizationResponse
203207 , planProductType :: ProductType
204208 , keyConnectorEnabled :: Boolean
205209 , keyConnectorUrl :: String
206− , familySponsorshipLastSyncDate :: Nullable Date
207− , familySponsorshipValidUntil :: Nullable Date
208− , familySponsorshipToDelete :: Nullable Boolean
210+ , familySponsorshipLastSyncDate :: JNullable Timestamp
211+ , familySponsorshipValidUntil :: JNullable Timestamp
212+ , familySponsorshipToDelete :: JNullable Boolean
209213 }
210214
211215type Urls
212− = { base :: Nullable String
213− , webVault :: Nullable String
214− , api :: Nullable String
215− , identity :: Nullable String
216− , icons :: Nullable String
217− , notifications :: Nullable String
218− , events :: Nullable String
219− , keyConnector :: Nullable String
216+ = { base :: JNullable String
217+ , webVault :: JNullable String
218+ , api :: JNullable String
219+ , identity :: JNullable String
220+ , icons :: JNullable String
221+ , notifications :: JNullable String
222+ , events :: JNullable String
223+ , keyConnector :: JNullable String
220224 }
221225
222226type PasswordTokenRequest
@@ -231,7 +235,7 @@ type DeviceRequest
231235 = { type :: DeviceType
232236 , name :: String
233237 , identifier :: String
234− , pushToken :: Nullable String
238+ , pushToken :: JNullable String
235239 }
236240
237241deviceTypeAndroid = 0 :: DeviceType
@@ -314,18 +318,26 @@ hashPurposeLocalAuthorization = 2 :: HashPurpose
314318type HashPurpose
315319 = Int
316320
317−newtype Hash
318− = Hash String
321+newtype StringHash
322+ = StringHash String
319323
320324newtype AccessToken
321325 = AccessToken String
322326
323327derive newtype instance Show AccessToken
328+derive newtype instance Eq AccessToken
329+derive newtype instance Ord AccessToken
330+derive newtype instance EncodeJson AccessToken
331+derive newtype instance DecodeJson AccessToken
324332
325333newtype RefreshToken
326334 = RefreshToken String
327335
328336derive newtype instance Show RefreshToken
337+derive newtype instance Eq RefreshToken
338+derive newtype instance Ord RefreshToken
339+derive newtype instance EncodeJson RefreshToken
340+derive newtype instance DecodeJson RefreshToken
329341
330342
331343type IdentityTokenResponse
@@ -336,12 +348,12 @@ type IdentityTokenResponse
336348 , resetMasterPassword :: Boolean
337349 , privateKey :: EncryptedString
338350 , key :: EncryptedString
339− , twoFactorToken :: Nullable String
351+ , twoFactorToken :: JNullable String
340352 , kdf :: KDF
341353 , kdfIterations :: Int
342− , forcePasswordReset :: Nullable Boolean
343− , apiUseKeyConnector :: Nullable Boolean
344− , keyConnectorUrl :: Nullable String
354+ , forcePasswordReset :: JNullable Boolean
355+ , apiUseKeyConnector :: JNullable Boolean
356+ , keyConnectorUrl :: JNullable String
345357 }
346358
347359newtype Email
@@ -352,8 +364,8 @@ type SyncResponse
352364 , folders :: Array FolderResponse
353365 , collections :: Array CollectionDetailsResponse
354366 , ciphers :: Array CipherResponse
355− , domains :: Nullable DomainsResponse
356− , policies :: Nullable (Array PolicyResponse)
367+ , domains :: JNullable DomainsResponse
368+ , policies :: JNullable (Array PolicyResponse)
357369 , sends :: Array SendResponse
358370 }
359371
@@ -365,33 +377,33 @@ type FolderResponse
365377
366378type CollectionDetailsResponse
367379 = { id :: String
368− , organizationId :: Nullable String
380+ , organizationId :: JNullable String
369381 , name :: String
370− , externalId :: Nullable String
382+ , externalId :: JNullable String
371383 , readOnly :: Boolean
372384 }
373385
374386type CipherResponse
375387 = { id :: String
376− , organizationId :: Nullable String
377− , folderId :: Nullable String
388+ , organizationId :: JNullable String
389+ , folderId :: JNullable String
378390 , type :: CipherType
379391 , name :: EncryptedString
380− , notes :: Nullable EncryptedString
381− , fields :: Nullable (Array FieldApi)
382− , login :: Nullable LoginApi
383− , card :: Nullable CardApi
384− , identity :: Nullable IdentityApi
385− , secureNote :: Nullable SecureNoteApi
392+ , notes :: JNullable EncryptedString
393+ , fields :: JNullable (Array FieldApi)
394+ , login :: JNullable LoginApi
395+ , card :: JNullable CardApi
396+ , identity :: JNullable IdentityApi
397+ , secureNote :: JNullable SecureNoteApi
386398 , favorite :: Boolean
387399 , edit :: Boolean
388400 , viewPassword :: Boolean
389401 , organizationUseTotp :: Boolean
390402 , revisionDate :: Timestamp
391− , attachments :: Nullable (Array AttachmentResponse)
392− , passwordHistory :: Nullable (Array PasswordHistoryResponse)
393− , collectionIds :: Nullable (Array String)
394− , deletedDate :: Nullable String
403+ , attachments :: JNullable (Array AttachmentResponse)
404+ , passwordHistory :: JNullable (Array PasswordHistoryResponse)
405+ , collectionIds :: JNullable (Array String)
406+ , deletedDate :: JNullable String
395407 , reprompt :: CipherRepromptType
396408 }
397409
@@ -410,7 +422,7 @@ type FieldApi
410422 = { name :: String
411423 , value :: String
412424 , type :: FieldType
413− , linkedId :: Nullable LinkedIdType
425+ , linkedId :: JNullable LinkedIdType
414426 }
415427
416428fieldTypeText = 0 :: FieldType
@@ -482,18 +494,18 @@ type LinkedIdType
482494 = Int
483495
484496type LoginApi
485− = { uris :: Opt (Array LoginUriApi)
486− , username :: Nullable EncryptedString
487− , password :: Nullable EncryptedString
488− , passwordRevisionDate :: Nullable String
489− , totp :: Nullable EncryptedString
497+ = { uris :: JOpt (Array LoginUriApi)
498+ , username :: JNullable EncryptedString
499+ , password :: JNullable EncryptedString
500+ , passwordRevisionDate :: JNullable String
501+ , totp :: JNullable EncryptedString
490502 -- This thing is undefined in some cases for some reson. Just ignoring it
491− , autofillOnPageLoad :: Opt (Nullable Boolean)
503+ , autofillOnPageLoad :: JOpt (JNullable Boolean)
492504 }
493505
494506type LoginUriApi
495507 = { uri :: String
496− , match :: Nullable UriMatchType
508+ , match :: JNullable UriMatchType
497509 }
498510
499511uriMatchTypeDomain = 0 :: UriMatchType
@@ -512,12 +524,12 @@ type UriMatchType
512524 = Int
513525
514526type CardApi
515− = { cardholderName :: Nullable String
516− , brand :: Nullable String
517− , number :: Nullable String
518− , expMonth :: Nullable String
519− , expYear :: Nullable String
520− , code :: Nullable String
527+ = { cardholderName :: JNullable String
528+ , brand :: JNullable String
529+ , number :: JNullable String
530+ , expMonth :: JNullable String
531+ , expYear :: JNullable String
532+ , code :: JNullable String
521533 }
522534
523535type IdentityApi
@@ -580,7 +592,7 @@ type GlobalDomainResponse
580592
581593type PolicyResponse
582594 = { id :: String
583− , organizationId :: Nullable String
595+ , organizationId :: JNullable String
584596 , type :: PolicyType
585597 , data :: ShowableJson
586598 , enabled :: Boolean
@@ -616,15 +628,15 @@ type SendResponse
616628 , accessId :: String
617629 , type :: SendType
618630 , name :: String
619− , notes :: Nullable String
620− , file :: Nullable SendFileApi
621− , text :: Nullable SendTextApi
631+ , notes :: JNullable String
632+ , file :: JNullable SendFileApi
633+ , text :: JNullable SendTextApi
622634 , key :: String
623− , maxAccessCount :: Nullable Int
635+ , maxAccessCount :: JNullable Int
624636 , accessCount :: Int
625637 , revisionDate :: String
626638 , expirationDate :: String
627− , deletionDate :: Nullable String
639+ , deletionDate :: JNullable String
628640 , password :: String
629641 , disable :: Boolean
630642 , hideEmail :: Boolean