mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
swift-format is owned by the Swift project and is generally less opinionated than swiftformat (but better at formatting to a limited line length).
65 lines
2.4 KiB
Swift
65 lines
2.4 KiB
Swift
//
|
|
// Copyright 2023 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
import SignalFfi
|
|
|
|
public class CreateCallLinkCredential: ByteArray, @unchecked Sendable {
|
|
public required init(contents: Data) throws {
|
|
try super.init(contents, checkValid: signal_create_call_link_credential_check_valid_contents)
|
|
}
|
|
|
|
public func present<RoomId: ContiguousBytes>(
|
|
roomId: RoomId,
|
|
userId: Aci,
|
|
serverParams: GenericServerPublicParams,
|
|
callLinkParams: CallLinkSecretParams
|
|
) -> CreateCallLinkCredentialPresentation {
|
|
return failOnError {
|
|
self.present(
|
|
roomId: roomId,
|
|
userId: userId,
|
|
serverParams: serverParams,
|
|
callLinkParams: callLinkParams,
|
|
randomness: try .generate()
|
|
)
|
|
}
|
|
}
|
|
|
|
public func present<RoomId: ContiguousBytes>(
|
|
roomId: RoomId,
|
|
userId: Aci,
|
|
serverParams: GenericServerPublicParams,
|
|
callLinkParams: CallLinkSecretParams,
|
|
randomness: Randomness
|
|
) -> CreateCallLinkCredentialPresentation {
|
|
return failOnError {
|
|
try withUnsafeBorrowedBuffer { contents in
|
|
try roomId.withUnsafeBorrowedBuffer { roomId in
|
|
try userId.withPointerToFixedWidthBinary { userId in
|
|
try serverParams.withUnsafeBorrowedBuffer { serverParams in
|
|
try callLinkParams.withUnsafeBorrowedBuffer { callLinkParams in
|
|
try randomness.withUnsafePointerToBytes { randomness in
|
|
try invokeFnReturningVariableLengthSerialized {
|
|
signal_create_call_link_credential_present_deterministic(
|
|
$0,
|
|
contents,
|
|
roomId,
|
|
userId,
|
|
serverParams,
|
|
callLinkParams,
|
|
randomness
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|