mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
This is very similar to the AuthCredential used by the group server, but using CallLinkParams to encrypt the user ID rather than GroupParams (and using GenericServerParams to issue the credential rather than the group server's ServerParams).
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
//
|
|
// Copyright 2023 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import ByteArray from '../internal/ByteArray';
|
|
import * as Native from '../../../Native';
|
|
|
|
import CallLinkPublicParams from './CallLinkPublicParams';
|
|
import GenericServerSecretParams from '../GenericServerSecretParams';
|
|
import UuidCiphertext from '../groups/UuidCiphertext';
|
|
|
|
export default class CallLinkAuthCredentialPresentation extends ByteArray {
|
|
private readonly __type?: never;
|
|
|
|
constructor(contents: Buffer) {
|
|
super(
|
|
contents,
|
|
Native.CallLinkAuthCredentialPresentation_CheckValidContents
|
|
);
|
|
}
|
|
|
|
verify(
|
|
serverParams: GenericServerSecretParams,
|
|
callLinkParams: CallLinkPublicParams,
|
|
now: Date = new Date()
|
|
): void {
|
|
Native.CallLinkAuthCredentialPresentation_Verify(
|
|
this.contents,
|
|
Math.floor(now.getTime() / 1000),
|
|
serverParams.contents,
|
|
callLinkParams.contents
|
|
);
|
|
}
|
|
|
|
getUserId(): UuidCiphertext {
|
|
return new UuidCiphertext(
|
|
Native.CallLinkAuthCredentialPresentation_GetUserId(this.contents)
|
|
);
|
|
}
|
|
}
|