diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js --- a/lib/types/crypto-types.js +++ b/lib/types/crypto-types.js @@ -21,10 +21,30 @@ }, }; +export type SignedPrekeys = { + +contentPrekey: string, + +contentPrekeySignature: string, + +notifPrekey: string, + +notifPrekeySignature: string, +}; + +export const signedPrekeysValidator: TInterface = + tShape({ + contentPrekey: t.String, + contentPrekeySignature: t.String, + notifPrekey: t.String, + notifPrekeySignature: t.String, + }); + export type OLMOneTimeKeys = { +curve25519: { +[string]: string }, }; +export type OneTimeKeysResult = { + +contentOneTimeKeys: OLMOneTimeKeys, + +notificationsOneTimeKeys: OLMOneTimeKeys, +}; + export type PickledOLMAccount = { +picklingKey: string, +pickledAccount: string, diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -5,6 +5,8 @@ import { identityKeysBlobValidator, type IdentityKeysBlob, + signedPrekeysValidator, + type SignedPrekeys, } from './crypto-types.js'; import { type OlmSessionInitializationInfo, @@ -31,6 +33,20 @@ +oneTimeNotifPrekey: ?string, }; +// This type should not be altered without also updating +// InboundKeyInfoResponse in native/native_rust_library/src/lib.rs +export type InboundKeyInfoResponse = { + +payload: string, + +payloadSignature: string, + +socialProof?: ?string, + +contentPrekey: string, + +contentPrekeySignature: string, + +notifPrekey: string, + +notifPrekeySignature: string, + +username?: ?string, + +walletAddress?: ?string, +}; + export type DeviceOlmOutboundKeys = { +identityKeysBlob: IdentityKeysBlob, +contentInitializationInfo: OlmSessionInitializationInfo, @@ -52,6 +68,33 @@ +keys: ?DeviceOlmOutboundKeys, }; +export type DeviceOlmInboundKeys = { + +identityKeysBlob: IdentityKeysBlob, + +signedPrekeys: SignedPrekeys, + +payloadSignature: string, +}; +export const deviceOlmInboundKeysValidator: TInterface = + tShape({ + identityKeysBlob: identityKeysBlobValidator, + signedPrekeys: signedPrekeysValidator, + payloadSignature: t.String, + }); + +export type UserDevicesOlmInboundKeys = { + +keys: { + +[deviceID: string]: ?DeviceOlmInboundKeys, + }, + +username?: ?string, + +walletAddress?: ?string, +}; + +export const userDeviceOlmInboundKeysValidator: TInterface = + tShape({ + keys: t.dict(t.String, t.maybe(deviceOlmInboundKeysValidator)), + username: t.maybe(t.String), + walletAddress: t.maybe(t.String), + }); + export interface IdentityServiceClient { +deleteUser: () => Promise; +getKeyserverKeys: string => Promise; @@ -85,20 +128,6 @@ +commServicesAccessToken: string, }; -// This type should not be altered without also updating -// InboundKeyInfoResponse in native/native_rust_library/src/lib.rs -export type InboundKeyInfoResponse = { - +payload: string, - +payloadSignature: string, - +socialProof?: ?string, - +contentPrekey: string, - +contentPrekeySignature: string, - +notifPrekey: string, - +notifPrekeySignature: string, - +username?: ?string, - +walletAddress?: ?string, -}; - export type IdentityAuthResult = { +userID: string, +accessToken: string, diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -10,7 +10,7 @@ import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js'; import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js'; import type { ClientDBUserStoreOperation } from 'lib/ops/user-store-ops'; -import type { OLMOneTimeKeys } from 'lib/types/crypto-types'; +import type { OneTimeKeysResult, SignedPrekeys } from 'lib/types/crypto-types'; import type { ClientDBDraftStoreOperation } from 'lib/types/draft-types.js'; import type { ClientDBMessageInfo } from 'lib/types/message-types.js'; import type { ClientDBStore } from 'lib/types/store-ops-types'; @@ -29,24 +29,12 @@ +signature: string, }; -type SignedPrekeys = { - +contentPrekey: string, - +contentPrekeySignature: string, - +notifPrekey: string, - +notifPrekeySignature: string, -}; - type CommServicesAuthMetadata = { +userID?: ?string, +deviceID?: ?string, +accessToken?: ?string, }; -type OneTimeKeysResult = { - contentOneTimeKeys: OLMOneTimeKeys, - notificationsOneTimeKeys: OLMOneTimeKeys, -}; - interface Spec extends TurboModule { +getDraft: (key: string) => Promise; +updateDraft: (key: string, text: string) => Promise;