mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-02 20:42:24 +02:00
Like ProfileKeyCredential, but with an expiration timestamp embedded in it. This has its own credential type and response type, but uses the same request type as a "classic" ProfileKeyCredential, and generates presentations usable with AnyProfileKeyCredential- Presentation, so that existing server code accepting presentations will automatically do the right thing. Adoption for servers: - Update secret params - When presentations are saved in group state, use ProfileKeyCredentialPresentation.getStructurallyValidV1PresentationBytes() to maintain backwards compatibility with existing clients. - Add an endpoint to issue ExpiringProfileKeyCredentials - (future) Remove the endpoint that issues regular ProfileKeyCredentials Adoption for clients, after the server has updated: - Update public params - Start fetching and using ExpiringProfileKeyCredentials instead of regular ProfileKeyCredentials (the old endpoint will eventually go away) - Node: To bring types into harmony, a receipt's expiration time has been changed to a `number` instead of a `bigint`
25 lines
702 B
Swift
25 lines
702 B
Swift
//
|
|
// Copyright 2022 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
import SignalFfi
|
|
|
|
public class ExpiringProfileKeyCredential: ByteArray {
|
|
public required init(contents: [UInt8]) throws {
|
|
try super.init(contents, checkValid: signal_expiring_profile_key_credential_check_valid_contents)
|
|
}
|
|
|
|
public var expirationTime: Date {
|
|
let timestampInSeconds = failOnError {
|
|
try self.withUnsafePointerToSerialized { contents in
|
|
try invokeFnReturningInteger {
|
|
signal_expiring_profile_key_credential_get_expiration_time($0, contents)
|
|
}
|
|
}
|
|
}
|
|
return Date(timeIntervalSince1970: TimeInterval(timestampInSeconds))
|
|
}
|
|
}
|