mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-25 17:25:18 +02:00
This allows the file to be checked by tsc, which would have caught some of the missing type aliases sooner (now added to Native.ts.in). Strictly speaking the behavior is slightly different: we have returned to exporting many items individually instead of collecting them on a single object. Co-authored-by: Alex Bakon <akonradi@signal.org>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
//
|
|
// Copyright 2023 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import ByteArray from '../internal/ByteArray.js';
|
|
import * as Native from '../../Native.js';
|
|
|
|
import CallLinkPublicParams from './CallLinkPublicParams.js';
|
|
import UuidCiphertext from '../groups/UuidCiphertext.js';
|
|
import { Aci } from '../../Address.js';
|
|
|
|
export default class CallLinkSecretParams extends ByteArray {
|
|
private readonly __type?: never;
|
|
|
|
static deriveFromRootKey(callLinkRootKey: Uint8Array): CallLinkSecretParams {
|
|
return new CallLinkSecretParams(
|
|
Native.CallLinkSecretParams_DeriveFromRootKey(callLinkRootKey)
|
|
);
|
|
}
|
|
|
|
constructor(contents: Uint8Array) {
|
|
super(contents, Native.CallLinkSecretParams_CheckValidContents);
|
|
}
|
|
|
|
getPublicParams(): CallLinkPublicParams {
|
|
return new CallLinkPublicParams(
|
|
Native.CallLinkSecretParams_GetPublicParams(this.contents)
|
|
);
|
|
}
|
|
|
|
decryptUserId(userId: UuidCiphertext): Aci {
|
|
return Aci.parseFromServiceIdFixedWidthBinary(
|
|
Native.CallLinkSecretParams_DecryptUserId(this.contents, userId.contents)
|
|
);
|
|
}
|
|
|
|
encryptUserId(userId: Aci): UuidCiphertext {
|
|
return new UuidCiphertext(
|
|
Native.CallLinkSecretParams_EncryptUserId(
|
|
this.contents,
|
|
userId.getServiceIdFixedWidthBinary()
|
|
)
|
|
);
|
|
}
|
|
}
|