Skip to content

Commit

Permalink
Remove MLS from ts packages (#2301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergekh2 authored Feb 8, 2025
1 parent 58e2b11 commit 9daa613
Show file tree
Hide file tree
Showing 43 changed files with 16 additions and 3,463 deletions.
1 change: 0 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@river-build/dlog": "workspace:^",
"@river-build/encryption": "workspace:^",
"@river-build/generated": "workspace:^",
"@river-build/mls-rs-wasm": "^0.0.16",
"@river-build/proto": "workspace:^",
"@river-build/web3": "workspace:^",
"browser-or-node": "^3.0.0",
Expand Down
59 changes: 2 additions & 57 deletions packages/sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
UserBio,
Tags,
BlockchainTransaction,
MemberPayload_Mls,
MiniblockHeader,
GetStreamResponse,
CreateStreamResponse,
Expand Down Expand Up @@ -139,7 +138,6 @@ import {
make_UserPayload_BlockchainTransaction,
ContractReceipt,
make_MemberPayload_EncryptionAlgorithm,
make_MemberPayload_Mls,
} from './types'

import debug from 'debug'
Expand All @@ -161,8 +159,6 @@ import { SignerContext } from './signerContext'
import { decryptAESGCM, deriveKeyAndIV, encryptAESGCM, uint8ArrayToBase64 } from './crypto_utils'
import { makeTags, makeTipTags } from './tags'
import { TipEventObject } from '@river-build/generated/dev/typings/ITipping'
import { extractMlsExternalGroup, ExtractMlsExternalGroupResult } from './mls/utils/mlsutils'
import { MlsAdapter, MLS_ALGORITHM } from './mls'

export type ClientEvents = StreamEvents & DecryptionEvents

Expand Down Expand Up @@ -211,7 +207,6 @@ export class Client
private entitlementsDelegate: EntitlementsDelegate
private decryptionExtensions?: BaseDecryptionExtensions
private syncedStreamsExtensions?: SyncedStreamsExtension
private mlsAdapter?: MlsAdapter
private persistenceStore: IPersistenceStore
private validatedEvents: Record<string, { isValid: boolean; reason?: string }> = {}
private defaultGroupEncryptionAlgorithm: GroupEncryptionAlgorithmId
Expand Down Expand Up @@ -274,7 +269,6 @@ export class Client
highPriorityStreamIds,
{
startSyncStreams: async () => {
this.mlsAdapter?.start()
this.streams.startSyncStreams()
this.decryptionExtensions?.start()
},
Expand Down Expand Up @@ -389,7 +383,6 @@ export class Client
encryptionDeviceInit?: EncryptionDeviceInitOpts
}): Promise<{
initCryptoTime: number
//initMlsTime: number
initUserStreamTime: number
initUserInboxStreamTime: number
initUserMetadataStreamTime: number
Expand All @@ -405,11 +398,9 @@ export class Client
this.logCall('initializeUser', this.userId)
assert(this.userStreamId === undefined, 'already initialized')
const initCrypto = await getTime(() => this.initCrypto(opts?.encryptionDeviceInit))
//const initMls = await getTime(() => this.initMls())

check(isDefined(this.decryptionExtensions), 'decryptionExtensions must be defined')
check(isDefined(this.syncedStreamsExtensions), 'syncedStreamsExtensions must be defined')
//check(isDefined(this.mlsAdapter), 'mlsAdapter must be defined')

const [
initUserStream,
Expand All @@ -435,7 +426,6 @@ export class Client

return {
initCryptoTime: initCrypto.time,
//initMlsTime: initMls.time,
initUserStreamTime: initUserStream.time,
initUserInboxStreamTime: initUserInboxStream.time,
initUserMetadataStreamTime: initUserMetadataStream.time,
Expand Down Expand Up @@ -978,13 +968,13 @@ export class Client
check(isDefined(stream), 'stream not found')
check(
stream.view.membershipContent.encryptionAlgorithm != encryptionAlgorithm,
`mlsEnabled is already set to ${encryptionAlgorithm}`,
`encryptionAlgorithm is already set to ${encryptionAlgorithm}`,
)
return this.makeEventAndAddToStream(
streamId,
make_MemberPayload_EncryptionAlgorithm(encryptionAlgorithm),
{
method: 'setMlsEnabled',
method: 'setStreamEncryptionAlgorithm',
},
)
}
Expand Down Expand Up @@ -1620,9 +1610,6 @@ export class Client
let message: EncryptedData
const encryptionAlgorithm = stream.view.membershipContent.encryptionAlgorithm
switch (encryptionAlgorithm) {
case MLS_ALGORITHM:
message = await this.encryptGroupEventEpochSecret(payload, streamId)
break
case GroupEncryptionAlgorithmId.HybridGroupEncryption:
message = await this.encryptGroupEvent(
payload,
Expand Down Expand Up @@ -2470,18 +2457,6 @@ export class Client
)
}

/// Initialise MLS but do not start it
private async initMls(): Promise<void> {
this.logCall('initMls')
if (this.mlsAdapter) {
this.logCall('Attempt to re-init mls adapter, ignoring')
return
}

this.mlsAdapter = new MlsAdapter(this)
await this.mlsAdapter.initialize()
}

/**
* Resets crypto backend and creates a new encryption account, uploading device keys to UserDeviceKey stream.
*/
Expand Down Expand Up @@ -2711,36 +2686,6 @@ export class Client
public async debugDropStream(syncId: string, streamId: string): Promise<void> {
await this.rpcClient.info({ debug: ['drop_stream', syncId, streamId] })
}

public async _debugSendMls(
streamId: string | Uint8Array,
payload: PlainMessage<MemberPayload_Mls>,
) {
return this.makeEventAndAddToStream(streamId, make_MemberPayload_Mls(payload), {
method: 'mls',
})
}

public async getMlsExternalGroupInfo(
streamId: string,
): Promise<ExtractMlsExternalGroupResult | undefined> {
let streamView = this.stream(streamId)?.view
if (!streamView || !streamView.isInitialized) {
streamView = await this.getStream(streamId)
}
check(isDefined(streamView), `stream not found: ${streamId}`)
return extractMlsExternalGroup(streamView)
}

private async encryptGroupEventEpochSecret(
payload: Message,
streamId: string,
): Promise<EncryptedData> {
if (this.mlsAdapter === undefined) {
throw new Error('mls adapter not initialized')
}
return this.mlsAdapter.encryptGroupEventEpochSecret(streamId, payload)
}
}

function ensureNoHexPrefix(value: string): string {
Expand Down
64 changes: 0 additions & 64 deletions packages/sdk/src/mls/adapter.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/sdk/src/mls/constants.ts

This file was deleted.

45 changes: 0 additions & 45 deletions packages/sdk/src/mls/coordinator/awaiter.ts

This file was deleted.

Loading

0 comments on commit 9daa613

Please sign in to comment.