diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings index 0aef1a22c2a71e203c2683d76b8133c30084231a..15fe03a547f2c9d8b8c19fc7b3e8f43681a1a6e4 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings index 0aef1a22c2a71e203c2683d76b8133c30084231a..15fe03a547f2c9d8b8c19fc7b3e8f43681a1a6e4 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Bindings index 0aef1a22c2a71e203c2683d76b8133c30084231a..15fe03a547f2c9d8b8c19fc7b3e8f43681a1a6e4 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/Current/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Bindings b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Bindings index 64b1c12c34d809479f884add1a1fefb7da025ee9..9ee144b911c2fd99b30fee3e8903698938973dc7 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings index 64b1c12c34d809479f884add1a1fefb7da025ee9..9ee144b911c2fd99b30fee3e8903698938973dc7 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Bindings b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Bindings index 64b1c12c34d809479f884add1a1fefb7da025ee9..9ee144b911c2fd99b30fee3e8903698938973dc7 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Headers/Bindings.objc.h index 3e41e9aabe048ffb1f5d9a836c8c26624847469b..a87e7b1adf40a466e486637f98f905fb706e6485 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/Current/Headers/Bindings.objc.h @@ -27,6 +27,10 @@ @class BindingsFilePartTracker; @class BindingsFileSend; @class BindingsFileTransfer; +@class BindingsGroup; +@class BindingsGroupChat; +@class BindingsGroupReport; +@class BindingsGroupSendReport; @class BindingsIdList; @class BindingsMessage; @class BindingsNodeRegistrationReport; @@ -49,6 +53,10 @@ @class BindingsFileTransferReceiveProgressCallback; @protocol BindingsFileTransferSentProgressCallback; @class BindingsFileTransferSentProgressCallback; +@protocol BindingsGroupChatProcessor; +@class BindingsGroupChatProcessor; +@protocol BindingsGroupRequest; +@class BindingsGroupRequest; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -118,6 +126,15 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +@protocol BindingsGroupChatProcessor <NSObject> +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +@protocol BindingsGroupRequest <NSObject> +- (void)callback:(BindingsGroup* _Nullable)g; +@end + @protocol BindingsListener <NSObject> /** * Hear is called to receive a message in the UI. @@ -1033,6 +1050,175 @@ Returns: - (NSData* _Nullable)send:(NSData* _Nullable)payload recipientID:(NSData* _Nullable)recipientID retry:(float)retry callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; @end +/** + * Group structure contains the identifying and membership information of a +group chat. + */ +@interface BindingsGroup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * GetCreatedMS returns the time the group was created in milliseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedMS; +/** + * GetCreatedNano returns the time the group was created in nanoseconds. This is +also the time the group requests were sent. + */ +- (int64_t)getCreatedNano; +/** + * GetID return the 33-byte unique group ID. This represents the id.ID object + */ +- (NSData* _Nullable)getID; +/** + * GetInitMessage returns initial message sent with the group request. + */ +- (NSData* _Nullable)getInitMessage; +/** + * GetMembership retrieves a list of group members. The list is in order; +the first contact is the leader/creator of the group. +All subsequent members are ordered by their ID. + +Returns: + - []byte - a JSON marshalled version of the member list. + */ +- (NSData* _Nullable)getMembership:(NSError* _Nullable* _Nullable)error; +/** + * GetName returns the name set by the user for the group. + */ +- (NSData* _Nullable)getName; +/** + * GetTrackedID returns the tracked ID of the Group object. This is used by the backend tracker. + */ +- (long)getTrackedID; +/** + * Serialize serializes the Group. + */ +- (NSData* _Nullable)serialize; +@end + +/** + * GroupChat is a binding-layer group chat manager. + */ +@interface BindingsGroupChat : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +- (nullable instancetype)init:(long)e2eID requestFunc:(id<BindingsGroupRequest> _Nullable)requestFunc processor:(id<BindingsGroupChatProcessor> _Nullable)processor; +/** + * GetGroup returns the group with the group ID. If no group exists, then the +error "failed to find group" is returned. + +Parameters: + - groupId - The byte data representing a group ID (a byte marshalled id.ID). + This can be pulled from a marshalled GroupReport. +Returns: + - Group - The bindings-layer representation of a group. + */ +- (BindingsGroup* _Nullable)getGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * GetGroups returns an IdList containing a list of group IDs that the user is a member of. + +Returns: + - []byte - a JSON marshalled IdList representing all group ID's. + */ +- (NSData* _Nullable)getGroups:(NSError* _Nullable* _Nullable)error; +/** + * JoinGroup allows a user to join a group when a request is received. +If an error is returned, handle it properly first; you may then retry later +with the same trackedGroupId. + +Parameters: + - trackedGroupId - the ID to retrieve the Group object within the backend's + tracking system. This is received by GroupRequest.Callback. + */ +- (BOOL)joinGroup:(long)trackedGroupId error:(NSError* _Nullable* _Nullable)error; +/** + * LeaveGroup deletes a group so a user no longer has access. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + */ +- (BOOL)leaveGroup:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +// skipped method GroupChat.MakeGroup with unsupported parameter or return types + +/** + * NumGroups returns the number of groups the user is a part of. + */ +- (long)numGroups; +/** + * ResendRequest resends a group request to all members in the group. + +Parameters: + - groupId - a byte representation of a group's ID. + This can be found in the report returned by GroupChat.MakeGroup. + +Returns: + - []byte - a JSON-marshalled GroupReport. + */ +- (NSData* _Nullable)resendRequest:(NSData* _Nullable)groupId error:(NSError* _Nullable* _Nullable)error; +/** + * Send is the bindings-level function for sending to a group. + +Parameters: + - groupId - the byte data representing a group ID. + This can be pulled from a marshalled GroupReport. + - message - the message that the user wishes to send to the group. + - tag - the tag associated with the message. This tag may be empty. + +Returns: + - []byte - a JSON marshalled GroupSendReport. + */ +- (NSData* _Nullable)send:(NSData* _Nullable)groupId message:(NSData* _Nullable)message tag:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; +@end + +/** + * GroupReport is returned when creating a new group and contains the ID of +the group, a list of rounds that the group requests were sent on, and the +status of the send operation. + */ +@interface BindingsGroupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +// skipped field GroupReport.Rounds with unsupported type: []int + +@property (nonatomic) long status; +@end + +/** + * GroupSendReport is returned when sending a group message. It contains the +round ID sent on and the timestamp of the send operation. + */ +@interface BindingsGroupSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field GroupSendReport.RoundID with unsupported type: uint64 + +@property (nonatomic) int64_t timestamp; +@property (nonatomic) NSData* _Nullable messageID; +@end + /** * IdList is a wrapper for a list of marshalled id.ID objects. */ @@ -1656,6 +1842,16 @@ Returns: */ FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSString* _Nullable backupPassphrase, NSData* _Nullable sessionPassword, NSData* _Nullable backupFileContents, NSError* _Nullable* _Nullable error); +/** + * NewGroupChat creates a bindings-layer group chat manager. + +Parameters: + - e2eID - e2e object ID in the tracker. + - requestFunc - a callback to handle group chat requests. + - processor - the group chat message processor. + */ +FOUNDATION_EXPORT BindingsGroupChat* _Nullable BindingsNewGroupChat(long e2eID, id<BindingsGroupRequest> _Nullable requestFunc, id<BindingsGroupChatProcessor> _Nullable processor, NSError* _Nullable* _Nullable error); + /** * NewUdManagerFromBackup builds a new user discover manager from a backup. It will construct a manager that is already registered and restore already @@ -1809,6 +2005,10 @@ FOUNDATION_EXPORT BOOL BindingsUpdateCommonErrors(NSString* _Nullable jsonFile, @class BindingsFileTransferSentProgressCallback; +@class BindingsGroupChatProcessor; + +@class BindingsGroupRequest; + @class BindingsListener; @class BindingsLogWriter; @@ -1912,6 +2112,32 @@ Parameters: - (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; @end +/** + * GroupChatProcessor manages the handling of received group chat messages. + */ +@interface BindingsGroupChatProcessor : NSObject <goSeqRefInterface, BindingsGroupChatProcessor> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)process:(NSData* _Nullable)decryptedMessage msg:(NSData* _Nullable)msg receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId err:(NSError* _Nullable)err; +- (NSString* _Nonnull)string; +@end + +/** + * GroupRequest is a bindings-layer interface that handles a group reception. + +Parameters: + - trackedGroupId - a bindings layer Group object. + */ +@interface BindingsGroupRequest : NSObject <goSeqRefInterface, BindingsGroupRequest> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(BindingsGroup* _Nullable)g; +@end + /** * Listener provides a callback to hear a message. diff --git a/Sources/ElixxirDAppsSDK/Callbacks/GroupChatProcessor.swift b/Sources/ElixxirDAppsSDK/Callbacks/GroupChatProcessor.swift new file mode 100644 index 0000000000000000000000000000000000000000..b5edc9cbcc8361f12021d62980615054386c0ece --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/GroupChatProcessor.swift @@ -0,0 +1,93 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatProcessor { + public struct Callback: Equatable { + public init( + decryptedMessage: Result<Data, NSError>, + msg: Data, + receptionId: Data, + ephemeralId: Int64, + roundId: Int64 + ) { + self.decryptedMessage = decryptedMessage + self.msg = msg + self.receptionId = receptionId + self.ephemeralId = ephemeralId + self.roundId = roundId + } + + public var decryptedMessage: Result<Data, NSError> + public var msg: Data + public var receptionId: Data + public var ephemeralId: Int64 + public var roundId: Int64 + } + + public init( + name: String = "GroupChatProcessor", + handle: @escaping (Callback) -> Void + ) { + self.name = name + self.handle = handle + } + + public var name: String + public var handle: (Callback) -> Void +} + +extension GroupChatProcessor { + public static let unimplemented = GroupChatProcessor( + name: "GroupChatProcessor.unimplemented", + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension GroupChatProcessor { + func makeBindingsGroupChatProcessor() -> BindingsGroupChatProcessorProtocol { + class CallbackObject: NSObject, BindingsGroupChatProcessorProtocol { + init(_ callback: GroupChatProcessor) { + self.callback = callback + } + + let callback: GroupChatProcessor + + func process( + _ decryptedMessage: Data?, + msg: Data?, + receptionId: Data?, + ephemeralId: Int64, + roundId: Int64, + err: Error? + ) { + guard let msg = msg else { + fatalError("BindingsGroupChatProcessor received `nil` msg") + } + guard let receptionId = receptionId else { + fatalError("BindingsGroupChatProcessor received `nil` receptionId") + } + let decryptedMessageResult: Result<Data, NSError> + if let err = err { + decryptedMessageResult = .failure(err as NSError) + } else if let decryptedMessage = decryptedMessage { + decryptedMessageResult = .success(decryptedMessage) + } else { + fatalError("BindingsGroupChatProcessor received `nil` decryptedMessage and `nil` error") + } + callback.handle(.init( + decryptedMessage: decryptedMessageResult, + msg: msg, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) + } + + func string() -> String { + callback.name + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/GroupRequest.swift b/Sources/ElixxirDAppsSDK/Callbacks/GroupRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..a0591f36d8b59c58e00b092973d2a0b1a32bc2e1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/GroupRequest.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupRequest { + public init(handle: @escaping (Group) -> Void) { + self.handle = handle + } + + public var handle: (Group) -> Void +} + +extension GroupRequest { + public static let unimplemented = GroupRequest( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension GroupRequest { + func makeBindingsGroupRequest() -> BindingsGroupRequestProtocol { + class CallbackObject: NSObject, BindingsGroupRequestProtocol { + init(_ callback: GroupRequest) { + self.callback = callback + } + + let callback: GroupRequest + + func callback(_ g: BindingsGroup?) { + guard let bindingsGroup = g else { + fatalError("BindingsGroupRequest.handle received `nil` group") + } + callback.handle(.live(bindingsGroup)) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Functors/NewGroupChat.swift b/Sources/ElixxirDAppsSDK/Functors/NewGroupChat.swift new file mode 100644 index 0000000000000000000000000000000000000000..c5ed45596809b0e9e1e588376b364ed2a17a2d07 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/NewGroupChat.swift @@ -0,0 +1,39 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewGroupChat { + public var run: (Int, GroupRequest, GroupChatProcessor) throws -> GroupChat + + public func callAsFunction( + e2eId: Int, + groupRequest: GroupRequest, + groupChatProcessor: GroupChatProcessor + ) throws -> GroupChat { + try run(e2eId, groupRequest, groupChatProcessor) + } +} + +extension NewGroupChat { + public static let live = NewGroupChat { e2eId, groupRequest, groupChatProcessor in + var error: NSError? + let bindingsGroupChat = BindingsNewGroupChat( + e2eId, + groupRequest.makeBindingsGroupRequest(), + groupChatProcessor.makeBindingsGroupChatProcessor(), + &error + ) + if let error = error { + throw error + } + guard let bindingsGroupChat = bindingsGroupChat else { + fatalError("BindingsNewGroupChat returned `nil` without providing error") + } + return .live(bindingsGroupChat) + } +} + +extension NewGroupChat { + public static let unimplemented = NewGroupChat( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedMS.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedMS.swift new file mode 100644 index 0000000000000000000000000000000000000000..41960aba88bd4bf265529b05d9f0789b8263c37a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedMS.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetCreatedMS { + public var run: () -> Int64 + + public func callAsFunction() -> Int64 { + run() + } +} + +extension GroupGetCreatedMS { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetCreatedMS { + GroupGetCreatedMS(run: bindingsGroup.getCreatedMS) + } +} + +extension GroupGetCreatedMS { + public static let unimplemented = GroupGetCreatedMS( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedNano.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedNano.swift new file mode 100644 index 0000000000000000000000000000000000000000..982c0cc349ad07007821b8b6a49bbaca9f3fdc97 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetCreatedNano.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetCreatedNano { + public var run: () -> Int64 + + public func callAsFunction() -> Int64 { + run() + } +} + +extension GroupGetCreatedNano { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetCreatedNano { + GroupGetCreatedNano(run: bindingsGroup.getCreatedNano) + } +} + +extension GroupGetCreatedNano { + public static let unimplemented = GroupGetCreatedNano( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetId.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetId.swift new file mode 100644 index 0000000000000000000000000000000000000000..85f7509b85e4386de3f45a5a37a6de186a7baa0c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetId.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetId { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GroupGetId { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetId { + GroupGetId { + guard let data = bindingsGroup.getID() else { + fatalError("BindingsGroup.getID returned `nil`") + } + return data + } + } +} + +extension GroupGetId { + public static let unimplemented = GroupGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetInitMessage.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetInitMessage.swift new file mode 100644 index 0000000000000000000000000000000000000000..b3ac47d8795313e71afbb8949997831d802a3c04 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetInitMessage.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetInitMessage { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GroupGetInitMessage { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetInitMessage { + GroupGetInitMessage { + guard let data = bindingsGroup.getInitMessage() else { + fatalError("BindingsGroup.getInitMessage returned `nil`") + } + return data + } + } +} + +extension GroupGetInitMessage { + public static let unimplemented = GroupGetInitMessage( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetMembership.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetMembership.swift new file mode 100644 index 0000000000000000000000000000000000000000..1d78a2486781187817b022a96741b12c8217cbf6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetMembership.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetMembership { + public var run: () throws -> Data + + public func callAsFunction() throws -> Data { + try run() + } +} + +extension GroupGetMembership { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetMembership { + GroupGetMembership { + try bindingsGroup.getMembership() + } + } +} + +extension GroupGetMembership { + public static let unimplemented = GroupGetMembership( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetName.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetName.swift new file mode 100644 index 0000000000000000000000000000000000000000..f355a1646954a30ff124cb92ef0275fbc36278f5 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetName.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetName { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GroupGetName { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetName { + GroupGetName { + guard let data = bindingsGroup.getName() else { + fatalError("BindingsGroup.getName returned `nil`") + } + return data + } + } +} + +extension GroupGetName { + public static let unimplemented = GroupGetName( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetTrackedId.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetTrackedId.swift new file mode 100644 index 0000000000000000000000000000000000000000..4ec389e0395a9926b9efcca73dfc32e2a50ea5be --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupGetTrackedId.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupGetTrackedId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension GroupGetTrackedId { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupGetTrackedId { + GroupGetTrackedId(run: bindingsGroup.getTrackedID) + } +} + +extension GroupGetTrackedId { + public static let unimplemented = GroupGetTrackedId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Group/Functors/GroupSerialize.swift b/Sources/ElixxirDAppsSDK/Group/Functors/GroupSerialize.swift new file mode 100644 index 0000000000000000000000000000000000000000..aa6cea1e777b727fad0e0db1fd7c8283c3afb5bc --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Functors/GroupSerialize.swift @@ -0,0 +1,28 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupSerialize { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GroupSerialize { + public static func live(_ bindingsGroup: BindingsGroup) -> GroupSerialize { + GroupSerialize { + guard let data = bindingsGroup.serialize() else { + fatalError("BindingsGroup.serialize returned `nil`") + } + return data + } + } +} + +extension GroupSerialize { + public static let unimplemented = GroupSerialize( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/Group/Group.swift b/Sources/ElixxirDAppsSDK/Group/Group.swift new file mode 100644 index 0000000000000000000000000000000000000000..25723dbab131acc9a361ad47cbb944a1a131e12d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Group/Group.swift @@ -0,0 +1,40 @@ +import Bindings + +public struct Group { + public var getCreatedMS: GroupGetCreatedMS + public var getCreatedNano: GroupGetCreatedNano + public var getId: GroupGetId + public var getInitMessage: GroupGetInitMessage + public var getMembership: GroupGetMembership + public var getName: GroupGetName + public var getTrackedID: GroupGetTrackedId + public var serialize: GroupSerialize +} + +extension Group { + public static func live(_ bindingsGroup: BindingsGroup) -> Group { + Group( + getCreatedMS: .live(bindingsGroup), + getCreatedNano: .live(bindingsGroup), + getId: .live(bindingsGroup), + getInitMessage: .live(bindingsGroup), + getMembership: .live(bindingsGroup), + getName: .live(bindingsGroup), + getTrackedID: .live(bindingsGroup), + serialize: .live(bindingsGroup) + ) + } +} + +extension Group { + public static let unimplemented = Group( + getCreatedMS: .unimplemented, + getCreatedNano: .unimplemented, + getId: .unimplemented, + getInitMessage: .unimplemented, + getMembership: .unimplemented, + getName: .unimplemented, + getTrackedID: .unimplemented, + serialize: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroup.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroup.swift new file mode 100644 index 0000000000000000000000000000000000000000..e4d5a5eedaa70e823c6cbd4cfbb67bb99f093620 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroup.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatGetGroup { + public var run: (Data) throws -> Group + + public func callAsFunction(groupId: Data) throws -> Group { + try run(groupId) + } +} + +extension GroupChatGetGroup { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatGetGroup { + GroupChatGetGroup { groupId in + .live(try bindingsGroupChat.getGroup(groupId)) + } + } +} + +extension GroupChatGetGroup { + public static let unimplemented = GroupChatGetGroup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroups.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroups.swift new file mode 100644 index 0000000000000000000000000000000000000000..02d29af296ffe837618888b7dfeedc11066999af --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatGetGroups.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatGetGroups { + public var run: () throws -> [Data] + + public func callAsFunction() throws -> [Data] { + try run() + } +} + +extension GroupChatGetGroups { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatGetGroups { + GroupChatGetGroups { + let listData = try bindingsGroupChat.getGroups() + return try JSONDecoder().decode([Data].self, from: listData) + } + } +} + +extension GroupChatGetGroups { + public static let unimplemented = GroupChatGetGroups( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatJoinGroup.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatJoinGroup.swift new file mode 100644 index 0000000000000000000000000000000000000000..a69160396532f608e4014fb89a9930da755b597f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatJoinGroup.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatJoinGroup { + public var run: (Int) throws -> Void + + public func callAsFunction(trackedGroupId: Int) throws { + try run(trackedGroupId) + } +} + +extension GroupChatJoinGroup { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatJoinGroup { + GroupChatJoinGroup(run: bindingsGroupChat.joinGroup) + } +} + +extension GroupChatJoinGroup { + public static let unimplemented = GroupChatJoinGroup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatLeaveGroup.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatLeaveGroup.swift new file mode 100644 index 0000000000000000000000000000000000000000..e13626065df4dcd7fa8788bd336fac71b6fb9b10 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatLeaveGroup.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatLeaveGroup { + public var run: (Data) throws -> Void + + public func callAsFunction(groupId: Data) throws { + try run(groupId) + } +} + +extension GroupChatLeaveGroup { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatLeaveGroup { + GroupChatLeaveGroup(run: bindingsGroupChat.leaveGroup) + } +} + +extension GroupChatLeaveGroup { + public static let unimplemented = GroupChatLeaveGroup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatNumGroups.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatNumGroups.swift new file mode 100644 index 0000000000000000000000000000000000000000..f0c4d071384df5638e936bbf635e1f12c893cbc2 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatNumGroups.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatNumGroups { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension GroupChatNumGroups { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatNumGroups { + GroupChatNumGroups(run: bindingsGroupChat.numGroups) + } +} + +extension GroupChatNumGroups { + public static let unimplemented = GroupChatNumGroups( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatResendRequest.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatResendRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..817ea59e4ccb2a0e0cd68270dbe3d64714887947 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatResendRequest.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatResendRequest { + public var run: (Data) throws -> GroupReport + + public func callAsFunction(groupId: Data) throws -> GroupReport { + try run(groupId) + } +} + +extension GroupChatResendRequest { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatResendRequest { + GroupChatResendRequest { groupId in + let reportData = try bindingsGroupChat.resendRequest(groupId) + return try GroupReport.decode(reportData) + } + } +} + +extension GroupChatResendRequest { + public static let unimplemented = GroupChatResendRequest( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatSend.swift b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatSend.swift new file mode 100644 index 0000000000000000000000000000000000000000..6e2f79526b88b27dc85f40bef8b61daefaa30be2 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/Functors/GroupChatSend.swift @@ -0,0 +1,29 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GroupChatSend { + public var run: (Data, Data, String?) throws -> GroupSendReport + + public func callAsFunction( + groupId: Data, + message: Data, + tag: String? = nil + ) throws -> GroupSendReport { + try run(groupId, message, tag) + } +} + +extension GroupChatSend { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChatSend { + GroupChatSend { groupId, message, tag in + let reportData = try bindingsGroupChat.send(groupId, message: message, tag: tag) + return try GroupSendReport.decode(reportData) + } + } +} + +extension GroupChatSend { + public static let unimplemented = GroupChatSend( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GroupChat/GroupChat.swift b/Sources/ElixxirDAppsSDK/GroupChat/GroupChat.swift new file mode 100644 index 0000000000000000000000000000000000000000..10f24edf28af41e468c5e0573a9cb12c01ac960e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/GroupChat/GroupChat.swift @@ -0,0 +1,37 @@ +import Bindings + +public struct GroupChat { + public var getGroup: GroupChatGetGroup + public var getGroups: GroupChatGetGroups + public var joinGroup: GroupChatJoinGroup + public var leaveGroup: GroupChatLeaveGroup + public var numGroups: GroupChatNumGroups + public var resendRequest: GroupChatResendRequest + public var send: GroupChatSend +} + +extension GroupChat { + public static func live(_ bindingsGroupChat: BindingsGroupChat) -> GroupChat { + GroupChat( + getGroup: .live(bindingsGroupChat), + getGroups: .live(bindingsGroupChat), + joinGroup: .live(bindingsGroupChat), + leaveGroup: .live(bindingsGroupChat), + numGroups: .live(bindingsGroupChat), + resendRequest: .live(bindingsGroupChat), + send: .live(bindingsGroupChat) + ) + } +} + +extension GroupChat { + public static let unimplemented = GroupChat( + getGroup: .unimplemented, + getGroups: .unimplemented, + joinGroup: .unimplemented, + leaveGroup: .unimplemented, + numGroups: .unimplemented, + resendRequest: .unimplemented, + send: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Models/GroupReport.swift b/Sources/ElixxirDAppsSDK/Models/GroupReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..0407507dfe034255822b07f78eaf9310dff3975b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/GroupReport.swift @@ -0,0 +1,33 @@ +import Foundation + +public struct GroupReport: Equatable { + public init( + id: Data, + rounds: [Int], + status: Int + ) { + self.id = id + self.rounds = rounds + self.status = status + } + + public var id: Data + public var rounds: [Int] + public var status: Int +} + +extension GroupReport: Codable { + enum CodingKeys: String, CodingKey { + case id = "Id" + case rounds = "Rounds" + case status = "Status" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/GroupSendReport.swift b/Sources/ElixxirDAppsSDK/Models/GroupSendReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..c7b3b01d5da48cc518773572c95bdd76213544ab --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/GroupSendReport.swift @@ -0,0 +1,33 @@ +import Foundation + +public struct GroupSendReport: Equatable { + public init( + roundId: UInt64, + timestamp: Int64, + messageId: Data + ) { + self.roundId = roundId + self.timestamp = timestamp + self.messageId = messageId + } + + public var roundId: UInt64 + public var timestamp: Int64 + public var messageId: Data +} + +extension GroupSendReport: Codable { + enum CodingKeys: String, CodingKey { + case roundId = "RoundID" + case timestamp = "Timestamp" + case messageId = "MessageID" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/GroupReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/GroupReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..d89542e7fc7ed3e8b00d8f3c4a740b37d815aed0 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/GroupReportTests.swift @@ -0,0 +1,31 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class GroupReportTests: XCTestCase { + func testCoding() throws { + let idB64 = "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=" + let rounds: [Int] = [1, 5, 9] + let status: Int = 123 + let jsonString = """ + { + "Id": "\(idB64)", + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "Status": \(status) + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try GroupReport.decode(jsonData) + + XCTAssertNoDifference(model, GroupReport( + id: Data(base64Encoded: idB64)!, + rounds: rounds, + status: status + )) + + let encodedModel = try model.encode() + let decodedModel = try GroupReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/GroupSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/GroupSendReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..8d99647c9432d5ff88ddc57738ebab00d48db9d3 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/GroupSendReportTests.swift @@ -0,0 +1,31 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class GroupSendReportTests: XCTestCase { + func testCoding() throws { + let roundId: UInt64 = 123 + let timestamp: Int64 = 321 + let messageIdB64 = "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=" + let jsonString = """ + { + "RoundID": \(roundId), + "Timestamp": \(timestamp), + "MessageID": "\(messageIdB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try GroupSendReport.decode(jsonData) + + XCTAssertNoDifference(model, GroupSendReport( + roundId: roundId, + timestamp: timestamp, + messageId: Data(base64Encoded: messageIdB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try GroupSendReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +}