on master help sign in
Added update APIs
commitd9a653a417d1634ade1474b7c742d4dbca34834e authoriko <ilyakooo0@gmail.com> dateTue 9 Aug 2022, 09:59 (4 years ago) parentd539085
3 files changed+15−1
backend/BW.js+9 backend/BW.purs+2 backend/BW/Types.purs+4−1
backend/BW.js+9
@@ -16,6 +16,9 @@ import { I18nService } from "../../deps/bw/libs/shared/dist/src/services/i18n.se
1616import { StateService as BaseStateService } from "../../deps/bw/libs/shared/dist/src/services/state.service";
1717import { PasswordTokenRequest } from "../../deps/bw/libs/shared/dist/src/models/request/identityToken/passwordTokenRequest";
1818import { TokenRequestTwoFactor } from "../../deps/bw/libs/common/src/models/request/identityToken/tokenRequestTwoFactor.ts";
19+import { CipherRequest } from "../../deps/bw/libs/common/src/models/request/cipherRequest";
20+import { Cipher } from "../../deps/bw/libs/common/src/models/domain/cipher";
21+import { CipherData } from "../../deps/bw/libs/common/src/models/data/cipherData";
1922
2023function sanitize(obj) {
2124 return JSON.parse(JSON.stringify(obj));
@@ -72,6 +75,8 @@ export function getServices() {
7275 )
7376 ),
7477 getSync: () => api.getSync().then(sanitize),
78+ postCipher: (cipher) => api.postCipher(makeCipherRequest(cipher)),
79+ putCipher: (id) => (cipher) => api.putCipher(id, makeCipherRequest(cipher)),
7580 }
7681 },
7782 crypto: bg.cryptoService,
@@ -79,6 +84,10 @@ export function getServices() {
7984 }
8085}
8186
87+function makeCipherRequest(cipher) {
88+ return new CipherRequest(new Cipher(new CipherData(cipher)))
89+}
90+
8291class MainBackground {
8392 // messagingService; //: MessagingServiceAbstraction;
8493 // storageService; //: StorageServiceAbstraction;
backend/BW.purs+2
@@ -29,6 +29,8 @@ type ApiService
2929 -- TODO: There can really be more request and response types. Maybe handle this later.
3030 , postIdentityToken :: PasswordTokenRequest -> Promise (IdentityCaptchaResponse |+| IdentityTokenResponse)
3131 , getSync :: Unit -> Promise SyncResponse
32+ , postCipher :: CipherResponse -> Promise CipherResponse
33+ , putCipher :: CipherId -> CipherResponse -> Promise CipherResponse
3234 }
3335
3436cryptoFunctionsTypeSha1 = "sha1" :: CryptoFunctionsType
backend/BW/Types.purs+4−1
@@ -385,8 +385,11 @@ type CollectionDetailsResponse
385385 , readOnly :: Boolean
386386 }
387387
388+
389+type CipherId = String
390+
388391type CipherResponse
389− = { id :: String
392+ = { id :: CipherId
390393 , organizationId :: JNullable String
391394 , folderId :: JNullable String
392395 , type :: CipherType