RingRTC: Conversions from Buffer->Uint8Array
This commit is contained in:
parent
56e40928e4
commit
e6a57f69d8
7 changed files with 40 additions and 38 deletions
|
@ -13769,7 +13769,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
|
|||
|
||||
```
|
||||
|
||||
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.54.1, protobuf 2.54.1, ringrtc 2.54.1, regex-aot 0.1.0, partial-default-derive 0.1.0
|
||||
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.55.0, protobuf 2.55.0, ringrtc 2.55.0, regex-aot 0.1.0, partial-default-derive 0.1.0
|
||||
|
||||
```
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
"@react-types/shared": "3.27.0",
|
||||
"@signalapp/libsignal-client": "0.76.4",
|
||||
"@signalapp/quill-cjs": "2.1.2",
|
||||
"@signalapp/ringrtc": "2.54.1",
|
||||
"@signalapp/ringrtc": "2.55.0",
|
||||
"@signalapp/sqlcipher": "2.1.0",
|
||||
"@signalapp/windows-ucv": "1.0.1",
|
||||
"@tanstack/react-virtual": "3.11.2",
|
||||
|
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
@ -135,8 +135,8 @@ importers:
|
|||
specifier: 2.1.2
|
||||
version: 2.1.2
|
||||
'@signalapp/ringrtc':
|
||||
specifier: 2.54.1
|
||||
version: 2.54.1
|
||||
specifier: 2.55.0
|
||||
version: 2.55.0
|
||||
'@signalapp/sqlcipher':
|
||||
specifier: 2.1.0
|
||||
version: 2.1.0
|
||||
|
@ -2780,8 +2780,8 @@ packages:
|
|||
resolution: {integrity: sha512-y2sgqdivlrG41J4Zvt/82xtH/PZjDlgItqlD2g/Cv3ZbjlR6cGhTNXbfNygCJB8nXj+C7I28pjt1Zm3k0pv2mg==}
|
||||
engines: {npm: '>=8.2.3'}
|
||||
|
||||
'@signalapp/ringrtc@2.54.1':
|
||||
resolution: {integrity: sha512-BcV4ewf3QJl3QAltWS+nImZx4o4k3cTEL1RFnSY8vO1lg9Zc4XkaDJVjbSEWakQR8NorrFIy/nNEf+RKb8kr+g==}
|
||||
'@signalapp/ringrtc@2.55.0':
|
||||
resolution: {integrity: sha512-dXmRc4WucEe3bnEDvSUf2MGrNNS3WkSUbRkP3xYchWKb5g9Afc8ax8ORPGVqD8cp9FHqAydW0OZDyzdnSb9p3A==}
|
||||
|
||||
'@signalapp/sqlcipher@2.1.0':
|
||||
resolution: {integrity: sha512-SRHiTOBcC25KXM7aZMyDiY2MP5uwsZM1NOIlUZlH0gtR4kTPiLEJqyhomA8II6lhl9BTGc9R2M/GLelQrQhvhw==}
|
||||
|
@ -12498,7 +12498,7 @@ snapshots:
|
|||
lodash: 4.17.21
|
||||
quill-delta: 5.1.0
|
||||
|
||||
'@signalapp/ringrtc@2.54.1':
|
||||
'@signalapp/ringrtc@2.55.0':
|
||||
dependencies:
|
||||
https-proxy-agent: 7.0.6
|
||||
tar: 6.2.1
|
||||
|
|
|
@ -743,7 +743,7 @@ export class CallingClass {
|
|||
|
||||
const rootKey = CallLinkRootKey.generate();
|
||||
const roomId = rootKey.deriveRoomId();
|
||||
const roomIdHex = roomId.toString('hex');
|
||||
const roomIdHex = Bytes.toHex(roomId);
|
||||
const logId = `createCallLink(${roomIdHex})`;
|
||||
|
||||
log.info(`${logId}: Creating call link`);
|
||||
|
@ -784,10 +784,10 @@ export class CallingClass {
|
|||
|
||||
const result = await RingRTC.createCallLink(
|
||||
sfuUrl,
|
||||
Buffer.from(credentialPresentation),
|
||||
credentialPresentation,
|
||||
rootKey,
|
||||
adminKey,
|
||||
Buffer.from(serializedPublicParams),
|
||||
serializedPublicParams,
|
||||
CallLinkRestrictions.AdminApproval
|
||||
);
|
||||
|
||||
|
@ -803,7 +803,7 @@ export class CallingClass {
|
|||
const callLink: CallLinkType = {
|
||||
roomId: roomIdHex,
|
||||
rootKey: rootKey.toString(),
|
||||
adminKey: adminKey.toString('base64'),
|
||||
adminKey: Bytes.toBase64(adminKey),
|
||||
storageNeedsSync: true,
|
||||
...state,
|
||||
};
|
||||
|
@ -831,7 +831,7 @@ export class CallingClass {
|
|||
|
||||
const result = await RingRTC.deleteCallLink(
|
||||
sfuUrl,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined,
|
||||
callLinkAdminKey
|
||||
|
@ -868,7 +868,7 @@ export class CallingClass {
|
|||
await getCallLinkAuthCredentialPresentation(callLinkRootKey);
|
||||
const result = await RingRTC.updateCallLinkName(
|
||||
sfuUrl,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined,
|
||||
callLinkAdminKey,
|
||||
|
@ -914,7 +914,7 @@ export class CallingClass {
|
|||
|
||||
const result = await RingRTC.updateCallLinkRestrictions(
|
||||
sfuUrl,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined,
|
||||
callLinkAdminKey,
|
||||
|
@ -949,7 +949,7 @@ export class CallingClass {
|
|||
|
||||
const result = await RingRTC.readCallLink(
|
||||
this._sfuUrl,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined
|
||||
);
|
||||
|
@ -972,7 +972,7 @@ export class CallingClass {
|
|||
preferLocalVideo = true,
|
||||
}: Readonly<{
|
||||
callLinkRootKey: CallLinkRootKey;
|
||||
adminPasskey: Buffer | undefined;
|
||||
adminPasskey: Uint8Array | undefined;
|
||||
hasLocalAudio: boolean;
|
||||
preferLocalVideo?: boolean;
|
||||
}>): Promise<
|
||||
|
@ -1016,7 +1016,7 @@ export class CallingClass {
|
|||
authCredentialPresentation,
|
||||
callLinkRootKey,
|
||||
adminPasskey,
|
||||
endorsementsPublicKey: Buffer.from(endorsementsPublicKey),
|
||||
endorsementsPublicKey,
|
||||
});
|
||||
|
||||
groupCall.setOutgoingAudioMuted(!hasLocalAudio);
|
||||
|
@ -1250,7 +1250,7 @@ export class CallingClass {
|
|||
|
||||
const result = await RingRTC.peekCallLinkCall(
|
||||
this._sfuUrl,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined
|
||||
);
|
||||
|
@ -1300,14 +1300,14 @@ export class CallingClass {
|
|||
const logId = getLogId({ source: 'connectGroupCall', conversationId });
|
||||
log.info(logId);
|
||||
|
||||
const groupIdBuffer = Buffer.from(Bytes.fromBase64(groupId));
|
||||
const groupIdBuffer = Bytes.fromBase64(groupId);
|
||||
|
||||
let isRequestingMembershipProof = false;
|
||||
|
||||
const outerGroupCall = RingRTC.getGroupCall(
|
||||
groupIdBuffer,
|
||||
this._sfuUrl,
|
||||
Buffer.alloc(0),
|
||||
new Uint8Array(),
|
||||
AUDIO_LEVEL_INTERVAL_MS,
|
||||
{
|
||||
...this.#getGroupCallObserver(conversationId, CallMode.Group),
|
||||
|
@ -1361,8 +1361,8 @@ export class CallingClass {
|
|||
roomId: string;
|
||||
authCredentialPresentation: CallLinkAuthCredentialPresentation;
|
||||
callLinkRootKey: CallLinkRootKey;
|
||||
adminPasskey: Buffer | undefined;
|
||||
endorsementsPublicKey: Buffer;
|
||||
adminPasskey: Uint8Array | undefined;
|
||||
endorsementsPublicKey: Uint8Array;
|
||||
}): GroupCall {
|
||||
const existing = this.#getGroupCall(roomId);
|
||||
if (existing) {
|
||||
|
@ -1387,11 +1387,11 @@ export class CallingClass {
|
|||
const outerGroupCall = RingRTC.getCallLinkCall(
|
||||
this._sfuUrl,
|
||||
endorsementsPublicKey,
|
||||
Buffer.from(authCredentialPresentation.serialize()),
|
||||
authCredentialPresentation.serialize(),
|
||||
callLinkRootKey,
|
||||
undefined,
|
||||
adminPasskey,
|
||||
Buffer.alloc(0),
|
||||
new Uint8Array(),
|
||||
AUDIO_LEVEL_INTERVAL_MS,
|
||||
this.#getGroupCallObserver(roomId, CallMode.Adhoc)
|
||||
);
|
||||
|
@ -1821,7 +1821,7 @@ export class CallingClass {
|
|||
authCredentialPresentation,
|
||||
callLinkRootKey,
|
||||
adminPasskey,
|
||||
endorsementsPublicKey: Buffer.from(endorsementsPublicKey),
|
||||
endorsementsPublicKey,
|
||||
});
|
||||
|
||||
// Set the camera disposition as we transition from the lobby to the call link call.
|
||||
|
@ -2230,7 +2230,7 @@ export class CallingClass {
|
|||
);
|
||||
return;
|
||||
}
|
||||
const groupIdBuffer = Buffer.from(Bytes.fromBase64(groupId));
|
||||
const groupIdBuffer = Bytes.fromBase64(groupId);
|
||||
|
||||
RingRTC.cancelGroupRing(
|
||||
groupIdBuffer,
|
||||
|
@ -2930,8 +2930,8 @@ export class CallingClass {
|
|||
ageSec: messageAgeSec,
|
||||
receivedAtCounter: envelope.receivedAtCounter,
|
||||
receivedAtDate: envelope.receivedAtDate,
|
||||
senderIdentityKey: Buffer.from(senderIdentityKey),
|
||||
receiverIdentityKey: Buffer.from(receiverIdentityKey),
|
||||
senderIdentityKey,
|
||||
receiverIdentityKey,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2999,12 +2999,12 @@ export class CallingClass {
|
|||
|
||||
// Used to send a variety of group call messages, including the initial call message
|
||||
async #handleSendCallMessageToGroup(
|
||||
groupIdBytes: Buffer,
|
||||
groupIdBytes: Uint8Array,
|
||||
data: Buffer,
|
||||
urgency: CallMessageUrgency,
|
||||
overrideRecipients: Array<Buffer> = []
|
||||
): Promise<boolean> {
|
||||
const groupId = groupIdBytes.toString('base64');
|
||||
const groupId = Bytes.toBase64(groupIdBytes);
|
||||
const conversation = window.ConversationController.get(groupId);
|
||||
if (!conversation) {
|
||||
log.error('handleSendCallMessageToGroup(): could not find conversation');
|
||||
|
@ -3070,14 +3070,14 @@ export class CallingClass {
|
|||
}
|
||||
|
||||
async #handleGroupCallRingUpdate(
|
||||
groupIdBytes: Buffer,
|
||||
groupIdBytes: Uint8Array,
|
||||
ringId: bigint,
|
||||
ringerBytes: Buffer,
|
||||
update: RingUpdate
|
||||
): Promise<void> {
|
||||
log.info(`handleGroupCallRingUpdate(): got ring update ${update}`);
|
||||
|
||||
const groupId = groupIdBytes.toString('base64');
|
||||
const groupId = Bytes.toBase64(groupIdBytes);
|
||||
|
||||
const ringerUuid = bytesToUuid(ringerBytes);
|
||||
if (!ringerUuid) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { CallLinkRootKey } from '@signalapp/ringrtc';
|
||||
import * as Bytes from '../../Bytes';
|
||||
import type {
|
||||
CallLinkRecord,
|
||||
CallLinkStateType,
|
||||
|
@ -221,9 +222,9 @@ export function updateCallLinkAdminKeyByRoomId(
|
|||
}
|
||||
|
||||
function assertRoomIdMatchesRootKey(roomId: string, rootKey: string): void {
|
||||
const derivedRoomId = CallLinkRootKey.parse(rootKey)
|
||||
.deriveRoomId()
|
||||
.toString('hex');
|
||||
const derivedRoomId = Bytes.toHex(
|
||||
CallLinkRootKey.parse(rootKey).deriveRoomId()
|
||||
);
|
||||
strictAssert(
|
||||
roomId === derivedRoomId,
|
||||
'passed roomId must match roomId derived from root key'
|
||||
|
|
|
@ -69,8 +69,8 @@ export function getPlaceholderCallLinkConversation(
|
|||
};
|
||||
}
|
||||
|
||||
export function toAdminKeyBytes(adminKey: string): Buffer {
|
||||
return Buffer.from(adminKey, 'base64');
|
||||
export function toAdminKeyBytes(adminKey: string): Uint8Array {
|
||||
return Bytes.fromBase64(adminKey);
|
||||
}
|
||||
|
||||
export function fromAdminKeyBytes(adminKey: Uint8Array): string {
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
toAdminKeyBytes,
|
||||
} from './callLinks';
|
||||
import { parseStrict } from './schemas';
|
||||
import * as Bytes from '../Bytes';
|
||||
|
||||
/**
|
||||
* RingRTC conversions
|
||||
|
@ -64,7 +65,7 @@ export function callLinkRestrictionsToRingRTC(
|
|||
}
|
||||
|
||||
export function getRoomIdFromRootKey(rootKey: CallLinkRootKey): string {
|
||||
return rootKey.deriveRoomId().toString('hex');
|
||||
return Bytes.toHex(rootKey.deriveRoomId());
|
||||
}
|
||||
|
||||
export function getRoomIdFromRootKeyString(rootKeyString: string): string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue