diff --git a/ElixxirDAppsSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElixxirDAppsSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved index 0ee0d575b6265a1319b61f4e9167c7a059296261..c7c4ea5527425921cedb3ac85bdb93b2e3bf4aeb 100644 --- a/ElixxirDAppsSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElixxirDAppsSDK.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "c4f78db9b90ca57b7b6abc2223e235242739ea3c", - "version" : "0.4.0" + "revision" : "21ec1d717c07cea5a026979cb0471dd95c7087e7", + "version" : "0.5.0" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "50a70a9d3583fe228ce672e8923010c8df2deddd", - "version" : "0.2.1" + "revision" : "ef8e14e7ce1c0c304c644c6ba365d06c468ded6b", + "version" : "0.3.3" } } ], diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Bindings index 5e98165734e7459fa58db4fc4c12194fc68bd6bd..528df5fe985f3cf811249d0fe523f999a90b7f5a 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif 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 5e98165734e7459fa58db4fc4c12194fc68bd6bd..528df5fe985f3cf811249d0fe523f999a90b7f5a 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif 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 5e98165734e7459fa58db4fc4c12194fc68bd6bd..528df5fe985f3cf811249d0fe523f999a90b7f5a 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif 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 146965a8b7ce44426ff1522b757705707d755540..f7ce222ffba175522c761fca3b7a412511ac4ed9 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif 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 146965a8b7ce44426ff1522b757705707d755540..f7ce222ffba175522c761fca3b7a412511ac4ed9 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif 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 146965a8b7ce44426ff1522b757705707d755540..f7ce222ffba175522c761fca3b7a412511ac4ed9 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 4e88771249b34b440abf4a8b282fcfc75ff1c7f9..31a22fa5f38ab6e18e6f5e71a5417163f2bb746f 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 @@ -12,20 +12,42 @@ @class BindingsAuthenticatedConnection; +@class BindingsBackup; +@class BindingsBackupReport; +@class BindingsBroadcastMessage; +@class BindingsBroadcastReport; +@class BindingsChannel; +@class BindingsChannelDef; @class BindingsCmix; @class BindingsConnection; @class BindingsE2ESendReport; @class BindingsE2e; +@class BindingsEventReport; @class BindingsFact; +@class BindingsFilePartTracker; +@class BindingsFileSend; +@class BindingsFileTransfer; @class BindingsIdList; @class BindingsMessage; +@class BindingsProgress; +@class BindingsReceivedFile; @class BindingsReceptionIdentity; @class BindingsRestlikeMessage; @class BindingsRoundsList; +@class BindingsSingleUseCallbackReport; +@class BindingsSingleUseResponseReport; +@class BindingsSingleUseSendReport; +@class BindingsUserDiscovery; @protocol BindingsAuthCallbacks; @class BindingsAuthCallbacks; +@protocol BindingsBroadcastListener; +@class BindingsBroadcastListener; @protocol BindingsClientError; @class BindingsClientError; +@protocol BindingsFileTransferReceiveProgressCallback; +@class BindingsFileTransferReceiveProgressCallback; +@protocol BindingsFileTransferSentProgressCallback; +@class BindingsFileTransferSentProgressCallback; @protocol BindingsListener; @class BindingsListener; @protocol BindingsLogWriter; @@ -36,6 +58,22 @@ @class BindingsNetworkHealthCallback; @protocol BindingsProcessor; @class BindingsProcessor; +@protocol BindingsReceiveFileCallback; +@class BindingsReceiveFileCallback; +@protocol BindingsReporterFunc; +@class BindingsReporterFunc; +@protocol BindingsRestlikeCallback; +@class BindingsRestlikeCallback; +@protocol BindingsSingleUseCallback; +@class BindingsSingleUseCallback; +@protocol BindingsSingleUseResponse; +@class BindingsSingleUseResponse; +@protocol BindingsStopper; +@class BindingsStopper; +@protocol BindingsUdNetworkStatus; +@class BindingsUdNetworkStatus; +@protocol BindingsUpdateBackupFunc; +@class BindingsUpdateBackupFunc; @protocol BindingsAuthCallbacks <NSObject> - (void)confirm:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @@ -43,18 +81,48 @@ - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +@protocol BindingsBroadcastListener <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @protocol BindingsClientError <NSObject> - (void)report:(NSString* _Nullable)source message:(NSString* _Nullable)message trace:(NSString* _Nullable)trace; @end +@protocol BindingsFileTransferReceiveProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +@protocol BindingsFileTransferSentProgressCallback <NSObject> +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + @protocol BindingsListener <NSObject> /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -76,6 +144,49 @@ Accepts a marshalled Message object - (NSString* _Nonnull)string; @end +@protocol BindingsReceiveFileCallback <NSObject> +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsReporterFunc <NSObject> +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +@protocol BindingsRestlikeCallback <NSObject> +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +@protocol BindingsSingleUseCallback <NSObject> +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsSingleUseResponse <NSObject> +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +@protocol BindingsStopper <NSObject> +- (void)stop; +@end + +@protocol BindingsUdNetworkStatus <NSObject> +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +@protocol BindingsUpdateBackupFunc <NSObject> +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + @interface BindingsAuthenticatedConnection : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; @@ -88,13 +199,171 @@ Accepts a marshalled Message object - (long)getId; - (NSData* _Nullable)getPartner; - (BOOL)isAuthenticated; -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * Cmix BindingsClient wraps the xxdk.Cmix, implementing additional functions -to support the gomobile Cmix interface + * Backup is a bindings-level struct encapsulating the backup.Backup +client object. + */ +@interface BindingsBackup : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * AddJson stores the argument within the Backup structure. + +Params + - json - JSON string + */ +- (void)addJson:(NSString* _Nullable)json; +/** + * IsBackupRunning returns true if the backup has been initialized and is +running. Returns false if it has been stopped. + */ +- (BOOL)isBackupRunning; +/** + * StopBackup stops the backup processes and deletes the user's password from +storage. To enable backups again, call InitializeBackup. + */ +- (BOOL)stopBackup:(NSError* _Nullable* _Nullable)error; +@end + +/** + * BackupReport is the bindings' representation of the return values of +NewCmixFromBackup. + +Example BackupReport: +{"BackupIdListJson":"WyJPRHRRTTA4ZERpV3lXaE0wWUhjanRHWnZQcHRSa1JOZ1pHR2FkTG10dE9BRCJd","BackupParams":""} + */ +@interface BindingsBackupReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * The JSON encoded list of E2E partner IDs + */ +@property (nonatomic) NSData* _Nullable backupIdListJson; +/** + * The backup parameters found within the backup file + */ +@property (nonatomic) NSData* _Nullable backupParams; +@end + +/** + * BroadcastMessage is the bindings representation of a broadcast message. + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61], + "Payload":"SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + } + */ +@interface BindingsBroadcastMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field BroadcastMessage.BroadcastReport with unsupported type: gitlab.com/elixxir/client/bindings.BroadcastReport + +@property (nonatomic) NSData* _Nullable payload; +@end + +/** + * BroadcastReport is the bindings representation of the info on how a broadcast message was sent + +Example JSON: + {"RoundID":42, + "EphID":[0,0,0,0,0,0,24,61] + } + */ +@interface BindingsBroadcastReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long roundID; +// skipped field BroadcastReport.EphID with unsupported type: gitlab.com/xx_network/primitives/id/ephemeral.Id + +@end + +/** + * Channel is a bindings-level struct encapsulating the broadcast.Channel client object. + */ +@interface BindingsChannel : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * Broadcast sends a given payload over the broadcast channel using symmetric broadcast. + */ +- (NSData* _Nullable)broadcast:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; +/** + * BroadcastAsymmetric sends a given payload over the broadcast channel using asymmetric broadcast. +This mode of encryption requires a private key. + */ +- (NSData* _Nullable)broadcastAsymmetric:(NSData* _Nullable)payload pk:(NSData* _Nullable)pk error:(NSError* _Nullable* _Nullable)error; +/** + * Get returns the result of calling json.Marshal on a ChannelDef based on the underlying crypto broadcast.Channel. + */ +- (NSData* _Nullable)get:(NSError* _Nullable* _Nullable)error; +/** + * Listen registers a BroadcastListener for a given method. +This allows users to handle incoming broadcast messages. + +Params: + - l - BroadcastListener object + - method - int corresponding to broadcast.Method constant, 0 for symmetric or 1 for asymmetric + */ +- (BOOL)listen:(id<BindingsBroadcastListener> _Nullable)l method:(long)method error:(NSError* _Nullable* _Nullable)error; +/** + * MaxAsymmetricPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxAsymmetricPayloadSize; +/** + * MaxPayloadSize returns the maximum possible payload size which can be broadcast. + */ +- (long)maxPayloadSize; +/** + * Stop stops the channel from listening for more messages. + */ +- (void)stop; +@end + +/** + * ChannelDef is the bindings representation of an elixxir/crypto broadcast.Channel object. + +Example JSON: + {"Name": "My broadcast channel", + "Description":"A broadcast channel for me to test things", + "Salt":"gpUqW7N22sffMXsvPLE7BA==", + "PubKey":"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + } + */ +@interface BindingsChannelDef : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull description; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable pubKey; +@end + +/** + * Cmix wraps the xxdk.Cmix struct, implementing additional functions to support +the bindings Cmix interface. */ @interface BindingsCmix : NSObject <goSeqRefInterface> { } @@ -103,100 +372,122 @@ to support the gomobile Cmix interface - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Connect performs auth key negotiation with the given recipient, -and returns a Connection object for the newly-created partner.Manager + * AddHealthCallback adds a callback that gets called whenever the network +health changes. Returns a registration ID that can be used to unregister. + */ +- (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * Connect performs auth key negotiation with the given recipient and returns a +Connection object for the newly created partner.Manager. + This function is to be used sender-side and will block until the partner.Manager is confirmed. -recipientContact - marshalled contact.Contact object -myIdentity - marshalled ReceptionIdentity object + +Parameters: + - e2eId - ID of the E2E object in the e2e tracker + - recipientContact - marshalled contact.Contact object + - myIdentity - marshalled ReceptionIdentity object + */ +- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact e2eParamsJSON:(NSData* _Nullable)e2eParamsJSON error:(NSError* _Nullable* _Nullable)error; +/** + * GetID returns the ID for this Cmix in the cmixTracker. */ -- (BindingsConnection* _Nullable)connect:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; -- (BindingsAuthenticatedConnection* _Nullable)connectWithAuthentication:(long)e2eId recipientContact:(NSData* _Nullable)recipientContact error:(NSError* _Nullable* _Nullable)error; - (long)getID; /** - * HasRunningProcessies checks if any background threads are running. -returns true if none are running. This is meant to be -used when NetworkFollowerStatus() returns Stopping. -Due to the handling of comms on iOS, where the OS can -block indefiently, it may not enter the stopped -state apropreatly. This can be used instead. + * HasRunningProcessies checks if any background threads are running and returns +true if one or more are. + +This is meant to be used when NetworkFollowerStatus returns xxdk.Stopping. +Due to the handling of comms on iOS, where the OS can block indefinitely, it +may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; /** - * IsNetworkHealthy returns true if the network is read to be in a healthy state where -messages can be sent + * IsHealthy returns true if the network is read to be in a healthy state where +messages can be sent. + */ +- (BOOL)isHealthy; +/** + * MakeLegacyReceptionIdentity generates the legacy identity for receiving +messages. */ -- (BOOL)isNetworkHealthy; +- (NSData* _Nullable)makeLegacyReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * MakeIdentity generates a new cryptographic identity for receiving messages + * MakeReceptionIdentity generates a new cryptographic identity for receiving +messages. */ -- (NSData* _Nullable)makeIdentity:(NSError* _Nullable* _Nullable)error; +- (NSData* _Nullable)makeReceptionIdentity:(NSError* _Nullable* _Nullable)error; /** - * Gets the state of the network follower. Returns: -Stopped - 0 -Starting - 1000 -Running - 2000 -Stopping - 3000 + * NetworkFollowerStatus gets the state of the network follower. It returns a +status with the following values: + Stopped - 0 + Running - 2000 + Stopping - 3000 */ - (long)networkFollowerStatus; /** * RegisterClientErrorCallback registers the callback to handle errors from the -long running threads controlled by StartNetworkFollower and StopNetworkFollower +long-running threads controlled by StartNetworkFollower and +StopNetworkFollower. */ - (void)registerClientErrorCallback:(id<BindingsClientError> _Nullable)clientError; /** - * RegisterNetworkHealthCB registers the network health callback to be called -any time the network health changes. Returns a unique ID that can be used to -unregister the network health callback. + * RemoveHealthCallback removes a health callback using its registration ID. */ -- (int64_t)registerNetworkHealthCB:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +- (void)removeHealthCallback:(int64_t)funcID; /** - * StartNetworkFollower kicks off the tracking of the network. It starts -long running network client threads and returns an object for checking -state and stopping those threads. -Call this when returning from sleep and close when going back to -sleep. + * StartNetworkFollower kicks off the tracking of the network. It starts long- +running network threads and returns an object for checking state and +stopping those threads. + +Call this when returning from sleep and close when going back to sleep. + These threads may become a significant drain on battery when offline, ensure -they are stopped if there is no internet access +they are stopped if there is no internet access. + Threads Started: - Network Follower (/network/follow.go) - tracks the network events and hands them off to workers for handling + tracks the network events and hands them off to workers for handling. - Historical Round Retrieval (/network/rounds/historical.go) - Retrieves data about rounds which are too old to be stored by the client + retrieves data about rounds that are too old to be stored by the client. - Message Retrieval Worker Group (/network/rounds/retrieve.go) - Requests all messages in a given round from the gateway of the last nodes + requests all messages in a given round from the gateway of the last + nodes. - Message Handling Worker Group (/network/message/handle.go) - Decrypts and partitions messages when signals via the Switchboard - - health Tracker (/network/health) - Via the network instance tracks the state of the network + decrypts and partitions messages when signals via the Switchboard. + - Health Tracker (/network/health), + via the network instance, tracks the state of the network. - Garbled Messages (/network/message/garbled.go) - Can be signaled to check all recent messages which could be be decoded - Uses a message store on disk for persistence + can be signaled to check all recent messages that could be decoded. It + uses a message store on disk for persistence. - Critical Messages (/network/message/critical.go) - Ensures all protocol layer mandatory messages are sent - Uses a message store on disk for persistence + ensures all protocol layer mandatory messages are sent. It uses a + message store on disk for persistence. - KeyExchange Trigger (/keyExchange/trigger.go) - Responds to sent rekeys and executes them + responds to sent rekeys and executes them. - KeyExchange Confirm (/keyExchange/confirm.go) - Responds to confirmations of successful rekey operations + responds to confirmations of successful rekey operations. + - Auth Callback (/auth/callback.go) + handles both auth confirm and requests. */ - (BOOL)startNetworkFollower:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * StopNetworkFollower stops the network follower if it is running. -It returns errors if the Follower is in the wrong status to stop or if it -fails to stop it. -if the network follower is running and this fails, the client object will + * StopNetworkFollower stops the network follower if it is running. It returns +an error if the follower is in the wrong state to stop or if it fails to stop +it. + +if the network follower is running and this fails, the Cmix object will most likely be in an unrecoverable state and need to be trashed. */ - (BOOL)stopNetworkFollower:(NSError* _Nullable* _Nullable)error; -- (void)unregisterNetworkHealthCB:(int64_t)funcID; /** * WaitForMessageDelivery allows the caller to get notified if the rounds a message was sent in successfully completed. Under the hood, this uses an API -which uses the internal round data, network historical round lookup, and +that uses the internal round data, network historical round lookup, and waiting on network events to determine what has (or will) occur. -The callbacks will return at timeoutMS if no state update occurs +The callbacks will return at timeoutMS if no state update occurs. This function takes the marshaled send report to ensure a memory leak does not occur as a result of both sides of the bindings holding a reference to @@ -204,14 +495,15 @@ the same pointer. */ - (BOOL)waitForMessageDelivery:(NSData* _Nullable)roundList mdc:(id<BindingsMessageDeliveryCallback> _Nullable)mdc timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** - * WaitForNewtwork will block until either the network is healthy or the -passed timeout. It will return true if the network is healthy + * WaitForNetwork will block until either the network is healthy or the passed +timeout is reached. It will return true if the network is healthy. */ - (BOOL)waitForNetwork:(long)timeoutMS; @end /** - * Connection is the bindings representation of a connect.Connection object that can be tracked by id + * Connection is the bindings' representation of a connect.Connection object +that can be tracked by ID. */ @interface BindingsConnection : NSObject <goSeqRefInterface> { } @@ -220,36 +512,37 @@ passed timeout. It will return true if the network is healthy - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; /** - * Close deletes this Connection's partner.Manager and releases resources + * Close deletes this Connection's partner.Manager and releases resources. */ - (BOOL)close:(NSError* _Nullable* _Nullable)error; /** - * GetId returns the Connection.id + * GetId returns the Connection ID. */ - (long)getId; /** - * GetPartner returns the partner.Manager for this Connection + * GetPartner returns the partner.Manager for this Connection. */ - (NSData* _Nullable)getPartner; /** - * RegisterListener is used for E2E reception -and allows for reading data sent from the partner.Manager -Returns marshalled ListenerID + * RegisterListener is used for E2E reception and allows for reading data sent +from the partner.Manager. */ -- (void)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener; +- (BOOL)registerListener:(long)messageType newListener:(id<BindingsListener> _Nullable)newListener error:(NSError* _Nullable* _Nullable)error; /** - * SendE2E is a wrapper for sending specifically to the Connection's partner.Manager -Returns marshalled E2ESendReport + * SendE2E is a wrapper for sending specifically to the Connection's +partner.Manager. Returns a marshalled E2ESendReport. */ - (NSData* _Nullable)sendE2E:(long)mt payload:(NSData* _Nullable)payload error:(NSError* _Nullable* _Nullable)error; @end /** - * E2ESendReport is the bindings representation of the return values of SendE2E + * E2ESendReport is the bindings' representation of the return values of +SendE2E. + Example E2ESendReport: -{"Rounds":[1,5,9], - "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp":1653582683183384000} + {"Rounds":[1,5,9], + "MessageID":"51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", + "Timestamp":1653582683183384000} */ @interface BindingsE2ESendReport : NSObject <goSeqRefInterface> { } @@ -265,8 +558,8 @@ Example E2ESendReport: @end /** - * E2e BindingsClient wraps the xxdk.E2e, implementing additional functions -to support the gomobile E2e interface + * E2e wraps the xxdk.E2e, implementing additional functions +to support the bindings E2e interface. */ @interface BindingsE2e : NSObject <goSeqRefInterface> { } @@ -283,15 +576,14 @@ Parameters: */ - (BOOL)addPartnerCallback:(NSData* _Nullable)partnerID cb:(id<BindingsAuthCallbacks> _Nullable)cb error:(NSError* _Nullable* _Nullable)error; /** - * AddService adds a service for all partners of the given -tag, which will call back on the given processor. These can -be sent to using the tag fields in the Params Object -Passing nil for the processor allows you to create a -service which is never called but will be visible by -notifications. Processes added this way are generally not -end-to-end encrypted messages themselves, but other -protocols which piggyback on e2e relationships to start -communication + * AddService adds a service for all partners of the given tag, which will call +back on the given processor. These can be sent to using the tag fields in the +Params object. + +Passing nil for the processor allows you to create a service that is never +called but will be visible by notifications. Processes added this way are +generally not end-to-end encrypted messages themselves, but other protocols +that piggyback on e2e relationships to start communication. */ - (BOOL)addService:(NSString* _Nullable)tag processor:(id<BindingsProcessor> _Nullable)processor error:(NSError* _Nullable* _Nullable)error; /** @@ -303,24 +595,28 @@ replay them on the callbacks. * Confirm sends a confirmation for a received request. It can only be called once. This both sends keying material to the other party and creates a channel in the e2e handler, after which e2e messages can be sent to the -partner using e2e.Handler.SendE2E. +partner using E2e.SendE2E. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. -A confirm cannot be sent for a contact who has not sent a request or who is -already a partner. This can only be called once for a specific contact. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. -If the confirm must be resent, use ReplayConfirm. + +A confirmation cannot be sent for a contact who has not sent a request or who +is already a partner. This can only be called once for a specific contact. +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + +If the confirmation must be resent, use ReplayConfirm. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)confirm:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * DeleteAllRequests clears all requests from client's auth storage. + * DeleteAllRequests clears all requests from auth storage. */ - (BOOL)deleteAllRequests:(NSError* _Nullable* _Nullable)error; /** @@ -332,7 +628,8 @@ Parameters: */ - (BOOL)deletePartnerCallback:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteReceiveRequests clears all received requests from client's auth storage. + * DeleteReceiveRequests clears all received requests from auth +storage. */ - (BOOL)deleteReceiveRequests:(NSError* _Nullable* _Nullable)error; /** @@ -343,144 +640,162 @@ Parameters: */ - (BOOL)deleteRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * DeleteSentRequests clears all sent requests from client's auth storage. + * DeleteSentRequests clears all sent requests from auth storage. */ - (BOOL)deleteSentRequests:(NSError* _Nullable* _Nullable)error; /** - * FirstPartitionSize returns the max partition payload size for the -first payload + * FirstPartitionSize returns the max partition payload size for the first +payload. */ - (long)firstPartitionSize; /** - * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user has -an E2E relationship with. + * GetAllPartnerIDs returns a marshalled list of all partner IDs that the user +has an E2E relationship with. + Returns: - []byte - the marshalled bytes of the IdList object. */ - (NSData* _Nullable)getAllPartnerIDs:(NSError* _Nullable* _Nullable)error; /** - * GetContact returns a marshalled contact.Contact object for the E2e ReceptionIdentity + * GetContact returns a marshalled contact.Contact object for the E2e +ReceptionIdentity. */ - (NSData* _Nullable)getContact; /** - * GetHistoricalDHPrivkey returns the user's marshalled Historical DH Private Key + * GetHistoricalDHPrivkey returns the user's marshalled historical DH private +key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPrivkey:(NSError* _Nullable* _Nullable)error; /** - * GetHistoricalDHPubkey returns the user's marshalled Historical DH -Public Key + * GetHistoricalDHPubkey returns the user's marshalled historical DH public key. + Returns: - []byte - the marshalled bytes of the cyclic.Int object. */ - (NSData* _Nullable)getHistoricalDHPubkey:(NSError* _Nullable* _Nullable)error; /** - * GetID returns the e2eTracker ID for the E2e object + * GetID returns the e2eTracker ID for the E2e object. */ - (long)getID; /** - * GetReceivedRequest returns a contact if there's a received request for it. + * GetReceivedRequest returns a contact if there is a received request for it. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - []byte - the marshalled bytes of the contact.Contact object. */ - (NSData* _Nullable)getReceivedRequest:(NSData* _Nullable)partnerID error:(NSError* _Nullable* _Nullable)error; /** - * GetReceptionID returns the marshalled default IDs + * GetReceptionID returns the marshalled default IDs. + Returns: - []byte - the marshalled bytes of the id.ID object. */ - (NSData* _Nullable)getReceptionID; /** * HasAuthenticatedChannel returns true if an authenticated channel with the -partner exists, otherwise returns false +partner exists, otherwise returns false. + Parameters: - partnerId - the marshalled bytes of the id.ID object. */ - (BOOL)hasAuthenticatedChannel:(NSData* _Nullable)partnerId ret0_:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * PartitionSize returns the partition payload size for the given -payload index. The first payload is index 0. + * PartitionSize returns the partition payload size for the given payload index. +The first payload is index 0. */ - (long)partitionSize:(long)payloadIndex; /** - * PayloadSize Returns the max payload size for a partitionable E2E -message + * PayloadSize returns the max payload size for a partitionable E2E message. */ - (long)payloadSize; /** - * RemoveService removes all services for the given tag + * RemoveService removes all services for the given tag. */ - (BOOL)removeService:(NSString* _Nullable)tag error:(NSError* _Nullable* _Nullable)error; /** - * ReplayConfirm resends a confirm to the partner. It will fail to send if the -send relationship with the partner has already ratcheted. -The confirm sends as a critical message; if the round it sends on fails, it -will be auto resend by the cMix client. + * ReplayConfirm resends a confirmation to the partner. It will fail to send if +the send relationship with the partner has already ratcheted. + +The confirmation sends as a critical message; if the round it sends on fails, +it will be auto resent by the cMix client. + This will not be useful if either side has ratcheted. Parameters: - partnerID - the marshalled bytes of the id.ID object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)replayConfirm:(NSData* _Nullable)partnerID ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * Request sends a contact request from the user identity in the imported e2e -structure to the passed contact, as well as the passed facts (will error if -they are too long). -The other party must accept the request by calling Confirm in order to be -able to send messages using e2e.Handler.SendE2E. When the other party does -so, the "confirm" callback will get called. + * Request sends a contact request from the user identity in the imported E2e +structure to the passed contact, as well as the passed facts (it will error +if they are too long). + +The other party must accept the request by calling Confirm to be able to send +messages using E2e.SendE2E. When the other party does so, the "confirm" +callback will get called. + The round the request is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. -The request sends as a critical message, if the round send on fails, it will -be auto resent by the cMix client. + +The request sends as a critical message, if the round it sends on fails, it +will be auto resent by the cMix client. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. - myFacts - stringified list of fact.FactList. + Returns: - int64 - ID of the round (convert to uint64) */ -- (BOOL)request:(NSData* _Nullable)partnerContact myFactsString:(NSString* _Nullable)myFactsString ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; +- (BOOL)request:(NSData* _Nullable)partnerContact factsListJson:(NSData* _Nullable)factsListJson ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** * Reset sends a contact reset request from the user identity in the imported e2e structure to the passed contact, as well as the passed facts (it will error if they are too long). + This deletes all traces of the relationship with the partner from e2e and create a new relationship from scratch. + The round the reset is initially sent on will be returned, but the request will be listed as a critical message, so the underlying cMix client will auto resend it in the event of failure. + A request cannot be sent for a contact who has already received a request or who is already a partner. Parameters: - partnerContact - the marshalled bytes of the contact.Contact object. + Returns: - int64 - ID of the round (convert to uint64) */ - (BOOL)reset:(NSData* _Nullable)partnerContact ret0_:(int64_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error; /** - * SecondPartitionSize returns the max partition payload size for all -payloads after the first payload + * SecondPartitionSize returns the max partition payload size for all payloads +after the first payload. */ - (long)secondPartitionSize; /** - * SendE2E send a message containing the payload to the -recipient of the passed message type, per the given -parameters - encrypted with end-to-end encryption. -Default parameters can be retrieved through + * SendE2E send a message containing the payload to the recipient of the passed +message type, per the given parameters--encrypted with end-to-end encryption. + Parameters: - recipientId - the marshalled bytes of the id.ID object. - e2eParams - the marshalled bytes of the e2e.Params object. + Returns: - []byte - the marshalled bytes of the E2ESendReport object. */ @@ -497,234 +812,763 @@ Parameters: @end /** - * Fact is an internal fact type for use in the bindings layer -example marshalled Fact: -{"Fact":"Zezima","Type":0} + * EventReport is a public struct which represents the contents of an event +report. + +Example JSON: + { + "Priority":1, + "Category":"Test Events", + "EventType":"Ping", + "Details":"This is an example of an event report" + } */ -@interface BindingsFact : NSObject <goSeqRefInterface> { +@interface BindingsEventReport : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) NSString* _Nonnull fact; -@property (nonatomic) long type; +@property (nonatomic) long priority; +@property (nonatomic) NSString* _Nonnull category; +@property (nonatomic) NSString* _Nonnull eventType; +@property (nonatomic) NSString* _Nonnull details; @end /** - * IdList is a wrapper for a list of marshalled id.ID objects + * Fact is an internal fact type for use in the bindings layer. + +JSON example: + { + "Fact": "Zezima", + "Type": 0 + } */ -@interface BindingsIdList : NSObject <goSeqRefInterface> { +@interface BindingsFact : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field IdList.Ids with unsupported type: [][]byte - +@property (nonatomic) NSString* _Nonnull fact; +@property (nonatomic) long type; @end /** - * Message is the bindings representation of a receive.Message -Example Message format: -{"MessageType":1, - "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID":17,"Timestamp":1653580439357351000, - "Encrypted":false, - "RoundId":19} + * FilePartTracker contains the fileTransfer.FilePartTracker. */ -@interface BindingsMessage : NSObject <goSeqRefInterface> { +@interface BindingsFilePartTracker : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -@property (nonatomic) long messageType; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable payload; -@property (nonatomic) NSData* _Nullable sender; -@property (nonatomic) NSData* _Nullable recipientID; -@property (nonatomic) int64_t ephemeralID; -@property (nonatomic) int64_t timestamp; -@property (nonatomic) BOOL encrypted; -@property (nonatomic) long roundId; -@end - /** - * ReceptionIdentity struct -Example marshalled ReceptionIdentity: -{"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) - // RSA Private key (PEM format) - "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - // Salt for identity (base64) - "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - // DH Private key - "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" -} + * GetNumParts returns the total number of file parts in the transfer. */ -@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { -} -@property(strong, readonly) _Nonnull id _ref; +- (long)getNumParts; +/** + * GetPartStatus returns the status of the file part with the given part number. -- (nonnull instancetype)initWithRef:(_Nonnull id)ref; -- (nonnull instancetype)init; -@property (nonatomic) NSData* _Nullable id_; -@property (nonatomic) NSData* _Nullable rsaPrivatePem; -@property (nonatomic) NSData* _Nullable salt; -@property (nonatomic) NSData* _Nullable dhKeyPrivate; +The possible values for the status are: + - 0 < Part does not exist + - 0 = unsent + - 1 = arrived (sender has sent a part, and it has arrived) + - 2 = received (receiver has received a part) + */ +- (long)getPartStatus:(long)partNum; @end /** - * RestlikeMessage is the bindings representation of a restlike.Message -Example marshalled RestlikeMessage: -{"Version":1, -"Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", -"Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", -"Method":2, -"URI":"xx://CmixRestlike/rest", -"Error":""} + * FileSend is a public struct that contains the file contents and its name, +type, and preview. + { + "Name":"testfile.txt", + "Type":"text file", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Contents":"VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + } */ -@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +@interface BindingsFileSend : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RestlikeMessage.Version with unsupported type: uint32 - -@property (nonatomic) NSData* _Nullable headers; -@property (nonatomic) NSData* _Nullable content; -@property (nonatomic) long method; -@property (nonatomic) NSString* _Nonnull uri; -@property (nonatomic) NSString* _Nonnull error; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSData* _Nullable contents; @end /** - * Example marshalled roundList object: -[1001,1003,1006] + * FileTransfer object is a bindings-layer struct which wraps a +fileTransfer.FileTransfer interface. */ -@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +@interface BindingsFileTransfer : NSObject <goSeqRefInterface> { } @property(strong, readonly) _Nonnull id _ref; - (nonnull instancetype)initWithRef:(_Nonnull id)ref; - (nonnull instancetype)init; -// skipped field RoundsList.Rounds with unsupported type: []int +/** + * CloseSend deletes a file from the internal storage once a transfer has +completed or reached the retry limit. Returns an error if the transfer has +not run out of retries. -- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; -@end +This function should be called once a transfer completes or errors out (as +reported by the progress callback). -/** - * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. -The NDF is processed into a protobuf containing a signature which -is verified using the cert string passed in. The NDF is returned as marshaled -byte data which may be used to start a client. +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); - +- (BOOL)closeSend:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * EnableGrpcLogs sets GRPC trace logging + * MaxFileNameLen returns the max number of bytes allowed for a file name. */ -FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); - +- (long)maxFileNameLen; /** - * GenerateSecret creates a secret password using a system-based -pseudorandom number generator. It takes 1 parameter, `numBytes`, -which should be set to 32, but can be set higher in certain cases. + * MaxFileSize returns the max number of bytes allowed for a file. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); - +- (long)maxFileSize; /** - * GetDependencies returns the api DEPENDENCIES + * MaxFileTypeLen returns the max number of bytes allowed for a file type. */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); - +- (long)maxFileTypeLen; /** - * GetFactsFromContact accepts a marshalled contact.Contact object, returning its marshalled list of Fact objects + * MaxPreviewSize returns the max number of bytes allowed for a file preview. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (long)maxPreviewSize; /** - * GetGitVersion rturns the api GITVERSION - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + * Receive returns the full file on the completion of the transfer. It deletes +internal references to the data and unregisters any attached progress +callbacks. Returns an error if the transfer is not complete, the full file +cannot be verified, or if the transfer cannot be found. -/** - * GetIDFromContact accepts a marshalled contact.Contact object & returns a marshalled id.ID object - */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); +Receive can only be called once the progress callback returns that the +file transfer is complete. -/** - * GetPubkeyFromContact accepts a marshalled contact.Contact object & returns a json marshalled large.Int DhPubKey +Parameters: + - tidBytes - file transfer ID */ -FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); - +- (NSData* _Nullable)receive:(NSData* _Nullable)tidBytes error:(NSError* _Nullable* _Nullable)error; /** - * GetVersion returns the api SEMVER - */ -FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + * RegisterReceivedProgressCallback allows for the registration of a callback to +track the progress of an individual received file transfer. -/** - * sets level of logging. All logs the set level and above will be displayed -options are: - TRACE - 0 - DEBUG - 1 - INFO - 2 - WARN - 3 - ERROR - 4 - CRITICAL - 5 - FATAL - 6 -The default state without updates is: INFO - */ -FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); +This should be done when a new transfer is received on the ReceiveCallback. -/** - * Login will load an existing client from the storageDir -using the password. This will fail if the client doesn't exist or -the password is incorrect. -The password is passed as a byte array so that it can be cleared from -memory and stored as securely as possible using the memguard library. -Login does not block on network connection, and instead loads and -starts subprocesses to perform network operations. -TODO: add in custom parameters instead of the default +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering */ -FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLogin(NSString* _Nullable storageDir, NSData* _Nullable password, NSError* _Nullable* _Nullable error); - +- (BOOL)registerReceivedProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferReceiveProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2e creates and returns a new E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used - */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2e(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); + * RegisterSentProgressCallback allows for the registration of a callback to +track the progress of an individual sent file transfer. + +SentProgressCallback is auto registered on Send; this function should be +called when resuming clients or registering extra callbacks. +Parameters: + - tidBytes - file transfer ID + - callback - callback that reports file reception progress + - period - duration to wait between progress callbacks triggering + */ +- (BOOL)registerSentProgressCallback:(NSData* _Nullable)tidBytes callback:(id<BindingsFileTransferSentProgressCallback> _Nullable)callback period:(NSString* _Nullable)period error:(NSError* _Nullable* _Nullable)error; /** - * LoginE2eEphemeral creates and returns a new ephemeral E2e object and adds it to the e2eTrackerSingleton -identity should be created via MakeIdentity() and passed in here -If callbacks is left nil, a default auth.Callbacks will be used + * Send is the bindings-level function for sending a file. + +Parameters: + - payload - JSON marshalled FileSend + - recipientID - marshalled recipient id.ID + - paramsJSON - JSON marshalled e2e.Params + - retry - number of retries allowed + - callback - callback that reports file sending progress + - period - duration to wait between progress callbacks triggering + +Returns: + - []byte - unique file transfer ID */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSError* _Nullable* _Nullable error); +- (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 /** - * LoginE2eLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -Uses the pre-generated transmission ID used by xxdk.Cmix -If callbacks is left nil, a default auth.Callbacks will be used -This function is designed to maintain backwards compatibility with previous xx messenger designs -and should not be used for other purposes + * IdList is a wrapper for a list of marshalled id.ID objects. */ -FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginE2eLegacy(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSError* _Nullable* _Nullable error); +@interface BindingsIdList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field IdList.Ids with unsupported type: [][]byte + +@end + +/** + * Message is the bindings' representation of a receive.Message. + +JSON example: + { + "MessageType":1, + "ID":"EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", + "Payload":"7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", + "Sender":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RecipientID":"amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphemeralID":17,"Timestamp":1653580439357351000, + "Encrypted":false, + "RoundId":19 + } + */ +@interface BindingsMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) long messageType; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable sender; +@property (nonatomic) NSData* _Nullable recipientID; +@property (nonatomic) int64_t ephemeralID; +@property (nonatomic) int64_t timestamp; +@property (nonatomic) BOOL encrypted; +@property (nonatomic) long roundId; +@end + +/** + * Progress is a public struct that represents the progress of an in-progress +file transfer. + +Example JSON: + { + "Completed":false, + "Transmitted":128, + "Total":2048, + "Err":null + } + */ +@interface BindingsProgress : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL completed; +@property (nonatomic) long transmitted; +@property (nonatomic) long total; +@property (nonatomic) NSError* _Nullable err; +@end + +/** + * ReceivedFile is a public struct that contains the metadata of a new file +transfer. + +Example JSON: + { + "TransferID":"B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=", + "SenderID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "Preview":"aXQncyBtZSBhIHByZXZpZXc=", + "Name":"testfile.txt", + "Type":"text file", + "Size":2048 + } + */ +@interface BindingsReceivedFile : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable transferID; +@property (nonatomic) NSData* _Nullable senderID; +@property (nonatomic) NSData* _Nullable preview; +@property (nonatomic) NSString* _Nonnull name; +@property (nonatomic) NSString* _Nonnull type; +@property (nonatomic) long size; +@end + +/** + * ReceptionIdentity struct. + +JSON example: + { + "ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", + "Salt":"4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", + "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + } + */ +@interface BindingsReceptionIdentity : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) NSData* _Nullable id_; +@property (nonatomic) NSData* _Nullable rsaPrivatePem; +@property (nonatomic) NSData* _Nullable salt; +@property (nonatomic) NSData* _Nullable dhKeyPrivate; +@end + +/** + * RestlikeMessage is the bindings' representation of a restlike.Message + +JSON example: + { + "Version":1, + "Headers":"Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", + "Content":"VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", + "Method":2, + "URI":"xx://CmixRestlike/rest", + "Error":"" + } + */ +@interface BindingsRestlikeMessage : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RestlikeMessage.Version with unsupported type: uint32 + +@property (nonatomic) NSData* _Nullable headers; +@property (nonatomic) NSData* _Nullable content; +@property (nonatomic) long method; +@property (nonatomic) NSString* _Nonnull uri; +@property (nonatomic) NSString* _Nonnull error; +@end + +/** + * RoundsList contains a list of round IDs. + +Example marshalled roundList object: + [1001,1003,1006] + */ +@interface BindingsRoundsList : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field RoundsList.Rounds with unsupported type: []int + +/** + * Marshal JSON marshals the RoundsList. + */ +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseCallbackReport is the bindings-layer struct used to represent +single -use messages received by a callback passed into single.Listen. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "Partner":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseCallbackReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseCallbackReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +// skipped field SingleUseCallbackReport.Partner with unsupported type: *gitlab.com/xx_network/primitives/id.ID + +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSData* _Nullable receptionID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseResponseReport is the bindings-layer struct used to represent +information passed to the single.Response callback interface in response to +single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "Payload":"rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==", + "ReceptionID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"}, + "Err":null + } + */ +@interface BindingsSingleUseResponseReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseResponseReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable payload; +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +@property (nonatomic) NSError* _Nullable err; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * SingleUseSendReport is the bindings-layer struct used to represent +information returned by single.TransmitRequest. + +JSON example: + { + "Rounds":[1,5,9], + "EphID":{"EphId":[0,0,0,0,0,0,3,89], + "Source":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"} + } + */ +@interface BindingsSingleUseSendReport : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +// skipped field SingleUseSendReport.RoundsList with unsupported type: gitlab.com/elixxir/client/bindings.RoundsList + +@property (nonatomic) NSData* _Nullable receptionID; +@property (nonatomic) int64_t ephID; +- (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; +@end + +/** + * UserDiscovery is a bindings-layer struct that wraps an ud.Manager interface. + */ +@interface BindingsUserDiscovery : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +/** + * ConfirmFact confirms a fact first registered via AddFact. The confirmation ID +comes from AddFact while the code will come over the associated +communications system. + */ +- (BOOL)confirmFact:(NSString* _Nullable)confirmationID code:(NSString* _Nullable)code error:(NSError* _Nullable* _Nullable)error; +/** + * GetContact returns the marshalled bytes of the contact.Contact for UD as +retrieved from the NDF. + */ +- (NSData* _Nullable)getContact:(NSError* _Nullable* _Nullable)error; +/** + * GetFacts returns a JSON marshalled list of fact.Fact objects that exist +within the Store's registeredFacts map. + */ +- (NSData* _Nullable)getFacts; +/** + * GetID returns the udTracker ID for the UserDiscovery object. + */ +- (long)getID; +/** + * PermanentDeleteAccount removes the username associated with this user from +the UD service. This will only take a username type fact, and the fact must +be associated with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)permanentDeleteAccount:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * RemoveFact removes a previously confirmed fact. This will fail if the fact +passed in is not UD service does not associate this fact with this user. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (BOOL)removeFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SendRegisterFact adds a fact for the user to user discovery. Will only +succeed if the user is already registered and the system does not have the +fact currently registered for any user. + +This does not complete the fact registration process, it returns a +confirmation ID instead. Over the communications system the fact is +associated with, a code will be sent. This confirmation ID needs to be called +along with the code to finalize the fact. + +Parameters: + - factJson - a JSON marshalled fact.Fact + */ +- (NSString* _Nonnull)sendRegisterFact:(NSData* _Nullable)factJson error:(NSError* _Nullable* _Nullable)error; +/** + * SetAlternativeUserDiscovery sets the alternativeUd object within manager. +Once set, any user discovery operation will go through the alternative +user discovery service. + +To undo this operation, use UnsetAlternativeUserDiscovery. + */ +- (BOOL)setAlternativeUserDiscovery:(NSData* _Nullable)altCert altAddress:(NSData* _Nullable)altAddress contactFile:(NSData* _Nullable)contactFile error:(NSError* _Nullable* _Nullable)error; +/** + * UnsetAlternativeUserDiscovery clears out the information from the Manager +object. + */ +- (BOOL)unsetAlternativeUserDiscovery:(NSError* _Nullable* _Nullable)error; +@end + +/** + * AsyncRequestRestLike sends an asynchronous restlike request to a given +contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + - cb - RestlikeCallback callback + +Returns an error, and the RestlikeCallback will be called with the results +of JSON marshalling the response when received. + */ +FOUNDATION_EXPORT BOOL BindingsAsyncRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, id<BindingsRestlikeCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL. +The NDF is processed into a protobuf containing a signature that is verified +using the cert string passed in. The NDF is returned as marshaled byte data +that may be used to start a client. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsDownloadAndVerifySignedNdfWithUrl(NSString* _Nullable url, NSString* _Nullable cert, NSError* _Nullable* _Nullable error); + +/** + * EnableGrpcLogs sets GRPC trace logging. + */ +FOUNDATION_EXPORT void BindingsEnableGrpcLogs(id<BindingsLogWriter> _Nullable writer); + +/** + * GenerateSecret creates a secret password using a system-based pseudorandom +number generator. + +Parameters: + - numBytes - The size of secret. It should be set to 32, but can be set + higher in certain cases. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGenerateSecret(long numBytes); + +/** + * GetDefaultCMixParams returns a JSON serialized object with all of the cMix +parameters and their default values. Call this function and modify the JSON +to change cMix settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultCMixParams(void); + +/** + * GetDefaultE2EParams returns a JSON serialized object with all of the E2E +parameters and their default values. Call this function and modify the JSON +to change E2E settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2EParams(void); + +/** + * GetDefaultE2eFileTransferParams returns a JSON serialized object with all the +e2e file transfer parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultE2eFileTransferParams(void); + +/** + * GetDefaultFileTransferParams returns a JSON serialized object with all the +file transfer parameters and their default values. Call this function and +modify the JSON to change file transfer settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultFileTransferParams(void); + +/** + * GetDefaultSingleUseParams returns a JSON serialized object with all the +single-use parameters and their default values. Call this function and modify +the JSON to change single use settings. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetDefaultSingleUseParams(void); + +/** + * GetDependencies returns the xxdk.DEPENDENCIES. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetDependencies(void); + +/** + * GetFactsFromContact accepts a marshalled contact.Contact object and returns +its marshalled list of Fact objects. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetFactsFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetGitVersion returns the xxdk.GITVERSION. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetGitVersion(void); + +/** + * GetIDFromContact accepts a marshalled contact.Contact object and returns a +marshalled id.ID object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetIDFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); /** - * NewKeystore creates client storage, generates keys, connects, and registers + * GetPubkeyFromContact accepts a marshalled contact.Contact object and returns +a JSON marshalled large.Int DH public key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsGetPubkeyFromContact(NSData* _Nullable marshaled, NSError* _Nullable* _Nullable error); + +/** + * GetVersion returns the xxdk.SEMVER. + */ +FOUNDATION_EXPORT NSString* _Nonnull BindingsGetVersion(void); + +/** + * InitFileTransfer creates a bindings-level file transfer manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - paramsJSON - JSON marshalled fileTransfer.Params + */ +FOUNDATION_EXPORT BindingsFileTransfer* _Nullable BindingsInitFileTransfer(long e2eID, id<BindingsReceiveFileCallback> _Nullable receiveFileCallback, NSData* _Nullable e2eFileTransferParamsJson, NSData* _Nullable fileTransferParamsJson, NSError* _Nullable* _Nullable error); + +/** + * InitializeBackup creates a bindings-layer Backup object. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - password - password used in LoadCmix. + - cb - the callback to be called when a backup is triggered. + */ +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsInitializeBackup(long e2eID, long udID, NSString* _Nullable password, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * Listen starts a single-use listener on a given tag using the passed in e2e object +and SingleUseCallback func. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - tag - identifies the single-use message + - cb - the callback that will be called when a response is received + +Returns: + - Stopper - an interface containing a function used to stop the listener + */ +FOUNDATION_EXPORT id<BindingsStopper> _Nullable BindingsListen(long e2eID, NSString* _Nullable tag, id<BindingsSingleUseCallback> _Nullable cb, NSError* _Nullable* _Nullable error); + +/** + * LoadCmix will load an existing user storage from the storageDir using the password. +This will fail if the user storage does not exist or the password is incorrect. + +The password is passed as a byte array so that it can be cleared from memory +and stored as securely as possible using the MemGuard library. + +LoadCmix does not block on network connection and instead loads and starts +subprocesses to perform network operations. + */ +FOUNDATION_EXPORT BindingsCmix* _Nullable BindingsLoadCmix(NSString* _Nullable storageDir, NSData* _Nullable password, NSData* _Nullable cmixParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoadOrNewUserDiscovery creates a bindings-level user discovery manager. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsLoadOrNewUserDiscovery(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSString* _Nullable username, NSData* _Nullable registrationValidationSignature, NSError* _Nullable* _Nullable error); + +/** + * LoadReceptionIdentity loads the given identity in Cmix storage with the given +key. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsLoadReceptionIdentity(NSString* _Nullable key, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * LogLevel sets level of logging. All logs at the set level and below will be +displayed (e.g., when log level is ERROR, only ERROR, CRITICAL, and FATAL +messages will be printed). + +Log level options: + TRACE - 0 + DEBUG - 1 + INFO - 2 + WARN - 3 + ERROR - 4 + CRITICAL - 5 + FATAL - 6 + +The default log level without updates is INFO. + */ +FOUNDATION_EXPORT BOOL BindingsLogLevel(long level, NSError* _Nullable* _Nullable error); + +/** + * Login creates and returns a new E2e object and adds it to the +e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a +default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLogin(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * LoginEphemeral creates and returns a new ephemeral E2e object and adds it to +the e2eTrackerSingleton. identity should be created via +Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in +here. If callbacks is left nil, a default auth.Callbacks will be used. + */ +FOUNDATION_EXPORT BindingsE2e* _Nullable BindingsLoginEphemeral(long cmixId, id<BindingsAuthCallbacks> _Nullable callbacks, NSData* _Nullable identity, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * NewBroadcastChannel creates a bindings-layer broadcast channel & starts listening for new messages + +Params + - cmixId - internal ID of cmix + - channelDefinition - JSON marshalled ChannelDef object + */ +FOUNDATION_EXPORT BindingsChannel* _Nullable BindingsNewBroadcastChannel(long cmixId, NSData* _Nullable channelDefinition, NSError* _Nullable* _Nullable error); + +/** + * NewCmix creates user storage, generates keys, connects, and registers with the network. Note that this does not register a username/identity, but merely creates a new cryptographic identity for adding such information at a later date. Users of this function should delete the storage directory on error. */ -FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable regCode, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BOOL BindingsNewCmix(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable password, NSString* _Nullable registrationCode, NSError* _Nullable* _Nullable error); + +/** + * NewCmixFromBackup initializes a new e2e storage from an encrypted +backup. Users of this function should delete the storage directory on error. +Users of this function should call LoadCmix as normal once this call succeeds. + +Params + - ndfJSON - JSON of the NDF. + - storageDir - directory for the storage files. + - sessionPassword - password to decrypt the data in the storageDir. + - backupPassphrase - backup passphrase provided by the user. Used to decrypt backup. + - backupFileContents - the file contents of the backup. + +Returns: + - []byte - the JSON marshalled bytes of the BackupReport object. + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsNewCmixFromBackup(NSString* _Nullable ndfJSON, NSString* _Nullable storageDir, NSData* _Nullable sessionPassword, NSData* _Nullable backupPassphrase, NSData* _Nullable backupFileContents, 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 +registered facts into store. + +Parameters: + - e2eID - e2e object ID in the tracker + - follower - network follower func wrapped in UdNetworkStatus + - emailFactJson - a JSON marshalled email fact.Fact + - phoneFactJson - a JSON marshalled phone fact.Fact + */ +FOUNDATION_EXPORT BindingsUserDiscovery* _Nullable BindingsNewUdManagerFromBackup(long e2eID, id<BindingsUdNetworkStatus> _Nullable follower, NSData* _Nullable emailFactJson, NSData* _Nullable phoneFactJson, NSError* _Nullable* _Nullable error); /** * RegisterLogWriter registers a callback on which logs are written. @@ -732,30 +1576,106 @@ FOUNDATION_EXPORT BOOL BindingsNewKeystore(NSString* _Nullable network, NSString FOUNDATION_EXPORT void BindingsRegisterLogWriter(id<BindingsLogWriter> _Nullable writer); /** - * RestlikeRequest performs a normal restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * RequestRestLike sends a restlike request to a given contact. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - request - JSON marshalled RestlikeMessage + - paramsJSON - JSON marshalled single.RequestParams + +Returns: + - []byte - JSON marshalled restlike.Message + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRequestRestLike(long e2eID, NSData* _Nullable recipient, NSData* _Nullable request, NSData* _Nullable paramsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequest performs a normal restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - connectionID - ID of the connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long cmixId, long connectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); + +/** + * RestlikeRequestAuth performs an authenticated restlike request. + +Parameters: + - cmixId - ID of the cMix object in the tracker + - authConnectionID - ID of the authenticated connection in the tracker + - request - JSON marshalled RestlikeMessage + - e2eParamsJSON - JSON marshalled xxdk.E2EParams + +Returns: + - []byte - JSON marshalled RestlikeMessage */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequest(long clientID, long connectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long cmixId, long authConnectionID, NSData* _Nullable request, NSData* _Nullable e2eParamsJSON, NSError* _Nullable* _Nullable error); /** - * RestlikeRequestAuth performs an authenticated restlike request -request - marshalled RestlikeMessage -Returns marshalled result RestlikeMessage + * ResumeBackup resumes the backup processes with a new callback. +Call this function only when resuming a backup that has already been +initialized or to replace the callback. +To start the backup for the first time or to use a new password, use +InitializeBackup. + +Params + - e2eID - ID of the E2e object in the e2e tracker. + - udID - ID of the UserDiscovery object in the ud tracker. + - cb - the callback to be called when a backup is triggered. + This will replace any callback that has been passed into InitializeBackup. */ -FOUNDATION_EXPORT NSData* _Nullable BindingsRestlikeRequestAuth(long clientID, long authConnectionID, NSData* _Nullable request, NSError* _Nullable* _Nullable error); +FOUNDATION_EXPORT BindingsBackup* _Nullable BindingsResumeBackup(long e2eID, long udID, id<BindingsUpdateBackupFunc> _Nullable cb, NSError* _Nullable* _Nullable error); /** * SetFactsOnContact replaces the facts on the contact with the passed in facts -pass in empty facts in order to clear the facts -Accepts a marshalled contact.Contact object & a marshalled list of Fact objects +pass in empty facts in order to clear the facts. + +Parameters: + - marshaled - JSON marshalled contact.Contact object + - facts - JSON marshalled Fact object. */ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable marshaled, NSData* _Nullable facts, NSError* _Nullable* _Nullable error); +/** + * StoreReceptionIdentity stores the given identity in Cmix storage with the +given key. This is the ideal way to securely store identities, as the caller +of this function is only required to store the given key separately rather +than the keying material. + */ +FOUNDATION_EXPORT BOOL BindingsStoreReceptionIdentity(NSString* _Nullable key, NSData* _Nullable identity, long cmixId, NSError* _Nullable* _Nullable error); + +/** + * TransmitSingleUse transmits payload to recipient via single-use. + +Parameters: + - e2eID - ID of the e2e object in the tracker + - recipient - marshalled contact.Contact object + - tag - identifies the single-use message + - payload - message contents + - paramsJSON - JSON marshalled single.RequestParams + - responseCB - the callback that will be called when a response is received + +Returns: + - []byte - JSON marshalled SingleUseSendReport + */ +FOUNDATION_EXPORT NSData* _Nullable BindingsTransmitSingleUse(long e2eID, NSData* _Nullable recipient, NSString* _Nullable tag, NSData* _Nullable payload, NSData* _Nullable paramsJSON, id<BindingsSingleUseResponse> _Nullable responseCB, NSError* _Nullable* _Nullable error); + @class BindingsAuthCallbacks; +@class BindingsBroadcastListener; + @class BindingsClientError; +@class BindingsFileTransferReceiveProgressCallback; + +@class BindingsFileTransferSentProgressCallback; + @class BindingsListener; @class BindingsLogWriter; @@ -766,6 +1686,22 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @class BindingsProcessor; +@class BindingsReceiveFileCallback; + +@class BindingsReporterFunc; + +@class BindingsRestlikeCallback; + +@class BindingsSingleUseCallback; + +@class BindingsSingleUseResponse; + +@class BindingsStopper; + +@class BindingsUdNetworkStatus; + +@class BindingsUpdateBackupFunc; + /** * AuthCallbacks is the bindings-specific interface for auth.Callbacks methods. */ @@ -779,6 +1715,18 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable - (void)reset:(NSData* _Nullable)contact receptionId:(NSData* _Nullable)receptionId ephemeralId:(int64_t)ephemeralId roundId:(int64_t)roundId; @end +/** + * BroadcastListener is the public function type bindings can use to listen for broadcast messages. +It accepts the result of calling json.Marshal on a BroadcastMessage object. + */ +@interface BindingsBroadcastListener : NSObject <goSeqRefInterface, BindingsBroadcastListener> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + @interface BindingsClientError : NSObject <goSeqRefInterface, BindingsClientError> { } @property(strong, readonly) _Nonnull id _ref; @@ -788,10 +1736,50 @@ FOUNDATION_EXPORT NSData* _Nullable BindingsSetFactsOnContact(NSData* _Nullable @end /** - * Listener provides a callback to hear a message -An object implementing this interface can be called back when the client -gets a message of the type that the registerer specified at registration -time. + * FileTransferReceiveProgressCallback is a bindings-layer interface that is +called with the progress of a received file. + */ +@interface BindingsFileTransferReceiveProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferReceiveProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * FileTransferSentProgressCallback is a bindings-layer interface that contains +a callback that is called when the sent progress updates. + */ +@interface BindingsFileTransferSentProgressCallback : NSObject <goSeqRefInterface, BindingsFileTransferSentProgressCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a file part is sent or an error occurs. + +Parameters: + - payload - the JSON marshalled bytes of a Progress object. + - t - tracker that allows the lookup of the status of any file part + - err - any errors that occurred during sending + */ +- (void)callback:(NSData* _Nullable)payload t:(BindingsFilePartTracker* _Nullable)t err:(NSError* _Nullable)err; +@end + +/** + * Listener provides a callback to hear a message. + +An object implementing this interface can be called back when the client gets +a message of the type that the registerer specified at registration time. */ @interface BindingsListener : NSObject <goSeqRefInterface, BindingsListener> { } @@ -799,12 +1787,14 @@ time. - (nonnull instancetype)initWithRef:(_Nonnull id)ref; /** - * Hear is called to receive a message in the UI -Accepts a marshalled Message object + * Hear is called to receive a message in the UI. + +Parameters: + - item - JSON marshalled Message object */ - (void)hear:(NSData* _Nullable)item; /** - * Name returns a name, used for debugging + * Name returns a name; used for debugging. */ - (NSString* _Nonnull)name; @end @@ -820,8 +1810,11 @@ Accepts a marshalled Message object /** * MessageDeliveryCallback gets called on the determination if all events related to a message send were successful. + If delivered == true, timedOut == false && roundResults != nil + If delivered == false, roundResults == nil + If timedOut == true, delivered == false && roundResults == nil */ @interface BindingsMessageDeliveryCallback : NSObject <goSeqRefInterface, BindingsMessageDeliveryCallback> { @@ -833,8 +1826,8 @@ If timedOut == true, delivered == false && roundResults == nil @end /** - * A callback when which is used to receive notification if network health -changes + * NetworkHealthCallback contains a callback that is used to receive +notification if network health changes. */ @interface BindingsNetworkHealthCallback : NSObject <goSeqRefInterface, BindingsNetworkHealthCallback> { } @@ -856,4 +1849,122 @@ changes - (NSString* _Nonnull)string; @end +/** + * ReceiveFileCallback is a bindings-layer interface that contains a callback +that is called when a file is received. + */ +@interface BindingsReceiveFileCallback : NSObject <goSeqRefInterface, BindingsReceiveFileCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * Callback is called when a new file transfer is received. + +Parameters: + - payload - the JSON marshalled bytes of a ReceivedFile object. + - err - any errors that occurred during reception + */ +- (void)callback:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * ReporterFunc is a bindings-layer interface that receives info from the Event +Manager. + +Parameters: + - payload - JSON marshalled EventReport object + */ +@interface BindingsReporterFunc : NSObject <goSeqRefInterface, BindingsReporterFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)report:(NSData* _Nullable)payload err:(NSError* _Nullable)err; +@end + +/** + * RestlikeCallback is the public function type bindings can use to make an +asynchronous restlike request. + +Parameters: + - []byte - JSON marshalled restlike.Message + - error - an error (the results of calling json.Marshal on the message) + */ +@interface BindingsRestlikeCallback : NSObject <goSeqRefInterface, BindingsRestlikeCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)p0 p1:(NSError* _Nullable)p1; +@end + +/** + * SingleUseCallback func is passed into Listen and called when messages are +received. + +Parameters: + - callbackReport - JSON marshalled SingleUseCallbackReport + */ +@interface BindingsSingleUseCallback : NSObject <goSeqRefInterface, BindingsSingleUseCallback> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)callbackReport err:(NSError* _Nullable)err; +@end + +/** + * SingleUseResponse is the public facing callback function passed by bindings +clients into TransmitSingleUse. + +Parameters: + - callbackReport - JSON marshalled SingleUseResponseReport + */ +@interface BindingsSingleUseResponse : NSObject <goSeqRefInterface, BindingsSingleUseResponse> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)callback:(NSData* _Nullable)responseReport err:(NSError* _Nullable)err; +@end + +/** + * Stopper is a public interface returned by Listen, allowing users to stop the registered listener. + */ +@interface BindingsStopper : NSObject <goSeqRefInterface, BindingsStopper> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)stop; +@end + +/** + * UdNetworkStatus contains the UdNetworkStatus, which is a bindings-level +interface for ud.udNetworkStatus. + */ +@interface BindingsUdNetworkStatus : NSObject <goSeqRefInterface, BindingsUdNetworkStatus> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +/** + * UdNetworkStatus returns: +- int - a xxdk.Status int + */ +- (long)udNetworkStatus; +@end + +/** + * UpdateBackupFunc contains a function callback that returns new backups. + */ +@interface BindingsUpdateBackupFunc : NSObject <goSeqRefInterface, BindingsUpdateBackupFunc> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (void)updateBackup:(NSData* _Nullable)encryptedBackup; +@end + #endif diff --git a/Package.swift b/Package.swift index 5f0bf3edb9c89e60b400bac60b999d01736bd514..63e76076b0f3dad3d5e0d351660f48b63b4be6db 100644 --- a/Package.swift +++ b/Package.swift @@ -29,21 +29,33 @@ let package = Package( dependencies: [ .package( url: "https://github.com/pointfreeco/swift-custom-dump.git", - .upToNextMajor(from: "0.4.0") + .upToNextMajor(from: "0.5.0") + ), + .package( + url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", + .upToNextMajor(from: "0.3.3") ), ], targets: [ .target( name: "ElixxirDAppsSDK", dependencies: [ - .target(name: "Bindings"), + .target( + name: "Bindings" + ), + .product( + name: "XCTestDynamicOverlay", + package: "xctest-dynamic-overlay" + ), ], swiftSettings: swiftSettings ), .testTarget( name: "ElixxirDAppsSDKTests", dependencies: [ - .target(name: "ElixxirDAppsSDK"), + .target( + name: "ElixxirDAppsSDK" + ), .product( name: "CustomDump", package: "swift-custom-dump" diff --git a/Sources/ElixxirDAppsSDK/Backup/Backup.swift b/Sources/ElixxirDAppsSDK/Backup/Backup.swift new file mode 100644 index 0000000000000000000000000000000000000000..7c8abc19758748a34e21b2163db6b9a53f9d4055 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Backup/Backup.swift @@ -0,0 +1,25 @@ +import Bindings + +public struct Backup { + public var isRunning: BackupIsRunning + public var addJSON: BackupAddJSON + public var stop: BackupStop +} + +extension Backup { + public static func live(_ bindingsBackup: BindingsBackup) -> Backup { + Backup( + isRunning: .live(bindingsBackup), + addJSON: .live(bindingsBackup), + stop: .live(bindingsBackup) + ) + } +} + +extension Backup { + public static let unimplemented = Backup( + isRunning: .unimplemented, + addJSON: .unimplemented, + stop: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Backup/Functors/BackupAddJson.swift b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupAddJson.swift new file mode 100644 index 0000000000000000000000000000000000000000..6c16884fdeca03546fefa6c5ce298bb18d3486f0 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupAddJson.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct BackupAddJSON { + public var run: (String) -> Void + + public func callAsFunction(_ jsonString: String) { + run(jsonString) + } +} + +extension BackupAddJSON { + public static func live(_ bindingsBackup: BindingsBackup) -> BackupAddJSON { + BackupAddJSON(run: bindingsBackup.addJson) + } +} + +extension BackupAddJSON { + public static let unimplemented = BackupAddJSON( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Backup/Functors/BackupIsRunning.swift b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupIsRunning.swift new file mode 100644 index 0000000000000000000000000000000000000000..ceee54543c848993c3fb265f2d6699b544c0098f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupIsRunning.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct BackupIsRunning { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension BackupIsRunning { + public static func live(_ bindingsBackup: BindingsBackup) -> BackupIsRunning { + BackupIsRunning(run: bindingsBackup.isBackupRunning) + } +} + +extension BackupIsRunning { + public static let unimplemented = BackupIsRunning( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Backup/Functors/BackupStop.swift b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupStop.swift new file mode 100644 index 0000000000000000000000000000000000000000..b2df31eff1a1e3944ee04fce381d064f61d0c587 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Backup/Functors/BackupStop.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct BackupStop { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension BackupStop { + public static func live(_ bindingsBackup: BindingsBackup) -> BackupStop { + BackupStop(run: bindingsBackup.stop) + } +} + +extension BackupStop { + public static let unimplemented = BackupStop( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/AuthCallbacks.swift b/Sources/ElixxirDAppsSDK/Callbacks/AuthCallbacks.swift new file mode 100644 index 0000000000000000000000000000000000000000..c6d2b867fe7964e44f17d16aee4e7ac8a0964467 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/AuthCallbacks.swift @@ -0,0 +1,81 @@ +import Bindings +import XCTestDynamicOverlay + +public struct AuthCallbacks { + public enum Callback: Equatable { + case confirm(contact: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) + case request(contact: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) + case reset(contact: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) + } + + public init(handle: @escaping (Callback) -> Void) { + self.handle = handle + } + + public var handle: (Callback) -> Void +} + +extension AuthCallbacks { + public static let unimplemented = AuthCallbacks( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension AuthCallbacks { + func makeBindingsAuthCallbacks() -> BindingsAuthCallbacksProtocol { + class CallbackObject: NSObject, BindingsAuthCallbacksProtocol { + init(_ callback: AuthCallbacks) { + self.callback = callback + } + + let callback: AuthCallbacks + + func confirm(_ contact: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) { + guard let contact = contact else { + fatalError("BindingsAuthCallbacks.confirm received `nil` contact") + } + guard let receptionId = receptionId else { + fatalError("BindingsAuthCallbacks.confirm received `nil` receptionId") + } + callback.handle(.confirm( + contact: contact, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) + } + + func request(_ contact: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) { + guard let contact = contact else { + fatalError("BindingsAuthCallbacks.request received `nil` contact") + } + guard let receptionId = receptionId else { + fatalError("BindingsAuthCallbacks.request received `nil` receptionId") + } + callback.handle(.request( + contact: contact, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) + } + + func reset(_ contact: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) { + guard let contact = contact else { + fatalError("BindingsAuthCallbacks.reset received `nil` contact") + } + guard let receptionId = receptionId else { + fatalError("BindingsAuthCallbacks.reset received `nil` receptionId") + } + callback.handle(.reset( + contact: contact, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/BroadcastListener.swift b/Sources/ElixxirDAppsSDK/Callbacks/BroadcastListener.swift new file mode 100644 index 0000000000000000000000000000000000000000..2b610491b1264ca5785222436458bffe8efe9c4a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/BroadcastListener.swift @@ -0,0 +1,44 @@ +import Bindings +import XCTestDynamicOverlay + +public struct BroadcastListener { + public init(handle: @escaping (Result<BroadcastMessage, NSError>) -> Void) { + self.handle = handle + } + + public var handle: (Result<BroadcastMessage, NSError>) -> Void +} + +extension BroadcastListener { + public static let unimplemented = BroadcastListener( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension BroadcastListener { + func makeBindingsBroadcastListener() -> BindingsBroadcastListenerProtocol { + class CallbackObject: NSObject, BindingsBroadcastListenerProtocol { + init(_ callback: BroadcastListener) { + self.callback = callback + } + + let callback: BroadcastListener + + func callback(_ p0: Data?, p1: Error?) { + if let error = p1 { + callback.handle(.failure(error as NSError)) + } else if let data = p0 { + do { + callback.handle(.success(try BroadcastMessage.decode(data))) + } catch { + callback.handle(.failure(error as NSError)) + } + } else { + fatalError("BindingsBroadcastListener received `nil` data and `nil` error") + } + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/ClientErrorCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/ClientErrorCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..6c48939d3a56170f61bbb79ffb10a805aa919536 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/ClientErrorCallback.swift @@ -0,0 +1,47 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ClientErrorCallback { + public init(handle: @escaping (ClientError) -> Void) { + self.handle = handle + } + + public var handle: (ClientError) -> Void +} + +extension ClientErrorCallback { + public static let unimplemented = ClientErrorCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension ClientErrorCallback { + func makeBindingsClientError() -> BindingsClientErrorProtocol { + class CallbackObject: NSObject, BindingsClientErrorProtocol { + init(_ callback: ClientErrorCallback) { + self.callback = callback + } + + let callback: ClientErrorCallback + + func report(_ source: String?, message: String?, trace: String?) { + guard let source = source else { + fatalError("BindingsClientError.report received `nil` source") + } + guard let message = message else { + fatalError("BindingsClientError.report received `nil` message") + } + guard let trace = trace else { + fatalError("BindingsClientError.report received `nil` trace") + } + callback.handle(ClientError( + source: source, + message: message, + trace: trace + )) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..faf5a70081d9c96f4e05ba4bfc19598e1fd635b6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift @@ -0,0 +1,69 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferProgressCallback { + public struct Callback { + public var progress: Progress + public var partTracker: FilePartTracker + } + + public init(handle: @escaping (Result<Callback, NSError>) -> Void) { + self.handle = handle + } + + public var handle: (Result<Callback, NSError>) -> Void +} + +extension FileTransferProgressCallback { + public static let unimplemented = FileTransferProgressCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension FileTransferProgressCallback { + func makeBindingsFileTransferReceiveProgressCallback() -> BindingsFileTransferReceiveProgressCallbackProtocol { + makeBindingsFileTransferProgressCallback(debugName: "BindingsFileTransferReceiveProgressCallback") + } + + func makeBindingsFileTransferSentProgressCallback() -> BindingsFileTransferSentProgressCallbackProtocol { + makeBindingsFileTransferProgressCallback(debugName: "BindingsFileTransferSentProgressCallback") + } + + private func makeBindingsFileTransferProgressCallback(debugName: String) + -> BindingsFileTransferReceiveProgressCallbackProtocol & BindingsFileTransferSentProgressCallbackProtocol { + class CallbackObject: NSObject, + BindingsFileTransferReceiveProgressCallbackProtocol, + BindingsFileTransferSentProgressCallbackProtocol { + init(_ callback: FileTransferProgressCallback, _ debugName: String) { + self.callback = callback + self.debugName = debugName + } + + let callback: FileTransferProgressCallback + let debugName: String + + func callback(_ payload: Data?, t: BindingsFilePartTracker?, err: Error?) { + if let error = err { + callback.handle(.failure(error as NSError)) + return + } + guard let payload = payload else { + fatalError("\(debugName) received `nil` payload without providing error") + } + guard let tracker = t else { + fatalError("\(debugName) received `nil` tracker without providing error") + } + do { + callback.handle(.success(.init( + progress: try Progress.decode(payload), + partTracker: .live(tracker) + ))) + } catch { + callback.handle(.failure(error as NSError)) + } + } + } + + return CallbackObject(self, debugName) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/HealthCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/HealthCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..7ba94384242f80ada886ded142bdd69eab09601c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/HealthCallback.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct HealthCallback { + public init(handle: @escaping (Bool) -> Void) { + self.handle = handle + } + + public var handle: (Bool) -> Void +} + +extension HealthCallback { + public static let unimplemented = HealthCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension HealthCallback { + func makeBindingsHealthCallback() -> BindingsNetworkHealthCallbackProtocol { + class CallbackObject: NSObject, BindingsNetworkHealthCallbackProtocol { + init(_ callback: HealthCallback) { + self.callback = callback + } + + let callback: HealthCallback + + func callback(_ p0: Bool) { + callback.handle(p0) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/Listener.swift b/Sources/ElixxirDAppsSDK/Callbacks/Listener.swift new file mode 100644 index 0000000000000000000000000000000000000000..359270b3ea277d8a9e89326334ccc6c4ff8fe7b8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/Listener.swift @@ -0,0 +1,51 @@ +import Bindings +import XCTestDynamicOverlay + +public struct Listener { + public init( + name: String = "Listener", + handle: @escaping (Message) -> Void + ) { + self.name = name + self.handle = handle + } + + public var name: String + public var handle: (Message) -> Void +} + +extension Listener { + public static let unimplemented = Listener( + name: "unimplemented", + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension Listener { + func makeBindingsListener() -> BindingsListenerProtocol { + class CallbackObject: NSObject, BindingsListenerProtocol { + init(_ callback: Listener) { + self.callback = callback + } + + let callback: Listener + + func hear(_ item: Data?) { + guard let item = item else { + fatalError("BindingsListener.hear received `nil`") + } + do { + callback.handle(try Message.decode(item)) + } catch { + fatalError("BindingsListener.hear message decoding failed with error: \(error)") + } + } + + func name() -> String { + callback.name + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/LogWriter.swift b/Sources/ElixxirDAppsSDK/Callbacks/LogWriter.swift new file mode 100644 index 0000000000000000000000000000000000000000..0a04e549c33e2984637995b2c00789798e8badd4 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/LogWriter.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LogWriter { + public init(handle: @escaping (String) -> Void) { + self.handle = handle + } + + public var handle: (String) -> Void +} + +extension LogWriter { + public static let unimplemented = LogWriter( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension LogWriter { + func makeBindingsLogWriter() -> BindingsLogWriterProtocol { + class CallbackObject: NSObject, BindingsLogWriterProtocol { + init(_ callback: LogWriter) { + self.callback = callback + } + + let callback: LogWriter + + func log(_ p0: String?) { + guard let p0 = p0 else { + fatalError("BindingsLogWriter.log received `nil`") + } + callback.handle(p0) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/MessageDeliveryCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/MessageDeliveryCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..429a5bfe3b6fd8c63c6c7f5731448ee75c9e1d69 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/MessageDeliveryCallback.swift @@ -0,0 +1,58 @@ +import Bindings +import XCTestDynamicOverlay + +public struct MessageDeliveryCallback { + public enum Result: Equatable { + case delivered(roundResults: [Int]) + case notDelivered(timedOut: Bool) + } + + public init(handle: @escaping (Result) -> Void) { + self.handle = handle + } + + public var handle: (Result) -> Void +} + +extension MessageDeliveryCallback { + public static let unimplemented = MessageDeliveryCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension MessageDeliveryCallback { + func makeBindingsMessageDeliveryCallback() -> BindingsMessageDeliveryCallbackProtocol { + class CallbackObject: NSObject, BindingsMessageDeliveryCallbackProtocol { + init(_ callback: MessageDeliveryCallback) { + self.callback = callback + } + + let callback: MessageDeliveryCallback + + func eventCallback(_ delivered: Bool, timedOut: Bool, roundResults: Data?) { + if delivered, + !timedOut, + let roundResultsData = roundResults, + let roundResults = try? JSONDecoder().decode([Int].self, from: roundResultsData) + { + callback.handle(.delivered(roundResults: roundResults)) + return + } + + if !delivered { + callback.handle(.notDelivered(timedOut: timedOut)) + return + } + + fatalError(""" + BindingsMessageDeliveryCallback received invalid parameters: + - delivered → \(delivered) + - timedOut → \(timedOut) + - roundResults → \(roundResults.map { String(data: $0, encoding: .utf8) ?? "" } ?? "") + """) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/Processor.swift b/Sources/ElixxirDAppsSDK/Callbacks/Processor.swift new file mode 100644 index 0000000000000000000000000000000000000000..4a9297c453c09ef5ed32d1ac20ba3da9cd3e7376 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/Processor.swift @@ -0,0 +1,66 @@ +import Bindings +import XCTestDynamicOverlay + +public struct Processor { + public struct Callback: Equatable { + public init(message: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) { + self.message = message + self.receptionId = receptionId + self.ephemeralId = ephemeralId + self.roundId = roundId + } + + public var message: Data + public var receptionId: Data + public var ephemeralId: Int64 + public var roundId: Int64 + } + + public init(serviceTag: String, process: @escaping (Callback) -> Void) { + self.serviceTag = serviceTag + self.process = process + } + + public var serviceTag: String + public var process: (Callback) -> Void +} + +extension Processor { + public static let unimplemented = Processor( + serviceTag: "unimplemented", + process: XCTUnimplemented("\(Self.self).process") + ) +} + +extension Processor { + func makeBindingsProcessor() -> BindingsProcessorProtocol { + class CallbackObject: NSObject, BindingsProcessorProtocol { + init(_ callback: Processor) { + self.callback = callback + } + + let callback: Processor + + func process(_ message: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) { + guard let message = message else { + fatalError("BindingsProcessor.process received `nil` message") + } + guard let receptionId = receptionId else { + fatalError("BindingsProcessor.process received `nil` receptionId") + } + callback.process(Callback( + message: message, + receptionId: receptionId, + ephemeralId: ephemeralId, + roundId: roundId + )) + } + + func string() -> String { + callback.serviceTag + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/ReceiveFileCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/ReceiveFileCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..4bfe288b708cb9bea99a7ce02004fb1ad58bddff --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/ReceiveFileCallback.swift @@ -0,0 +1,40 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ReceiveFileCallback { + public var handle: (Result<ReceivedFile, NSError>) -> Void +} + +extension ReceiveFileCallback { + public static let unimplemented = ReceiveFileCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension ReceiveFileCallback { + func makeBindingsReceiveFileCallback() -> BindingsReceiveFileCallbackProtocol { + class CallbackObject: NSObject, BindingsReceiveFileCallbackProtocol { + init(_ callback: ReceiveFileCallback) { + self.callback = callback + } + + let callback: ReceiveFileCallback + + func callback(_ payload: Data?, err: Error?) { + if let error = err { + callback.handle(.failure(error as NSError)) + } else if let data = payload { + do { + callback.handle(.success(try ReceivedFile.decode(data))) + } catch { + callback.handle(.failure(error as NSError)) + } + } else { + fatalError("BindingsReceiveFileCallback received `nil` payload and `nil` error") + } + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/RestlikeCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/RestlikeCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..835df93323bf20d181419862e91f99d6ffe8670f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/RestlikeCallback.swift @@ -0,0 +1,44 @@ +import Bindings +import XCTestDynamicOverlay + +public struct RestlikeCallback { + public init(handle: @escaping (Result<RestlikeMessage, NSError>) -> Void) { + self.handle = handle + } + + public var handle: (Result<RestlikeMessage, NSError>) -> Void +} + +extension RestlikeCallback { + public static let unimplemented = RestlikeCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension RestlikeCallback { + func makeBindingsRestlikeCallback() -> BindingsRestlikeCallbackProtocol { + class CallbackObject: NSObject, BindingsRestlikeCallbackProtocol { + init(_ callback: RestlikeCallback) { + self.callback = callback + } + + let callback: RestlikeCallback + + func callback(_ p0: Data?, p1: Error?) { + if let error = p1 { + callback.handle(.failure(error as NSError)) + } else if let messageData = p0 { + do { + callback.handle(.success(try RestlikeMessage.decode(messageData))) + } catch { + callback.handle(.failure(error as NSError)) + } + } else { + fatalError("BindingsRestlikeCallback received `nil` message and `nil` error") + } + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/SingleUseCallback.swift b/Sources/ElixxirDAppsSDK/Callbacks/SingleUseCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..99a4cf1f95be9328f7325aecaf852eb785cab414 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/SingleUseCallback.swift @@ -0,0 +1,44 @@ +import Bindings +import XCTestDynamicOverlay + +public struct SingleUseCallback { + public init(handle: @escaping (Result<SingleUseCallbackReport, NSError>) -> Void) { + self.handle = handle + } + + public var handle: (Result<SingleUseCallbackReport, NSError>) -> Void +} + +extension SingleUseCallback { + public static let unimplemented = SingleUseCallback( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension SingleUseCallback { + func makeBindingsSingleUseCallback() -> BindingsSingleUseCallbackProtocol { + class CallbackObject: NSObject, BindingsSingleUseCallbackProtocol { + init(_ callback: SingleUseCallback) { + self.callback = callback + } + + let callback: SingleUseCallback + + func callback(_ callbackReport: Data?, err: Error?) { + if let error = err { + callback.handle(.failure(error as NSError)) + } else if let callbackReport = callbackReport { + do { + callback.handle(.success(try SingleUseCallbackReport.decode(callbackReport))) + } catch { + callback.handle(.failure(error as NSError)) + } + } else { + fatalError("BindingsSingleUseCallback received `nil` callbackReport and `nil` error") + } + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/SingleUseResponse.swift b/Sources/ElixxirDAppsSDK/Callbacks/SingleUseResponse.swift new file mode 100644 index 0000000000000000000000000000000000000000..98db7efd45a724b6e74e42ef689fa43e5e4f975b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/SingleUseResponse.swift @@ -0,0 +1,44 @@ +import Bindings +import XCTestDynamicOverlay + +public struct SingleUseResponse { + public init(handle: @escaping (Result<SingleUseResponseReport, NSError>) -> Void) { + self.handle = handle + } + + public var handle: (Result<SingleUseResponseReport, NSError>) -> Void +} + +extension SingleUseResponse { + public static let unimplemented = SingleUseResponse( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension SingleUseResponse { + func makeBindingsSingleUseResponse() -> BindingsSingleUseResponseProtocol { + class CallbackObject: NSObject, BindingsSingleUseResponseProtocol { + init(_ callback: SingleUseResponse) { + self.callback = callback + } + + let callback: SingleUseResponse + + func callback(_ responseReport: Data?, err: Error?) { + if let error = err { + callback.handle(.failure(error as NSError)) + } else if let reportData = responseReport { + do { + callback.handle(.success(try SingleUseResponseReport.decode(reportData))) + } catch { + callback.handle(.failure(error as NSError)) + } + } else { + fatalError("BindingsSingleUseResponse received `nil` responseReport and `nil` err") + } + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/UdNetworkStatus.swift b/Sources/ElixxirDAppsSDK/Callbacks/UdNetworkStatus.swift new file mode 100644 index 0000000000000000000000000000000000000000..70975b7d68ac2a82801bd6365445e7bb476c9940 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/UdNetworkStatus.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UdNetworkStatus { + public init(handle: @escaping () -> Int) { + self.handle = handle + } + + public var handle: () -> Int +} + +extension UdNetworkStatus { + public static let unimplemented = UdNetworkStatus( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension UdNetworkStatus { + func makeBindingsUdNetworkStatus() -> BindingsUdNetworkStatusProtocol { + class CallbackObject: NSObject, BindingsUdNetworkStatusProtocol { + init(_ callback: UdNetworkStatus) { + self.callback = callback + } + + let callback: UdNetworkStatus + + func udNetworkStatus() -> Int { + callback.handle() + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Callbacks/UpdateBackupFunc.swift b/Sources/ElixxirDAppsSDK/Callbacks/UpdateBackupFunc.swift new file mode 100644 index 0000000000000000000000000000000000000000..5748695fa73fbc3ebf33df56eb761d47e80073f6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Callbacks/UpdateBackupFunc.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UpdateBackupFunc { + public init(handle: @escaping (Data) -> Void) { + self.handle = handle + } + + public var handle: (Data) -> Void +} + +extension UpdateBackupFunc { + public static let unimplemented = UpdateBackupFunc( + handle: XCTUnimplemented("\(Self.self)") + ) +} + +extension UpdateBackupFunc { + func makeBindingsUpdateBackupFunc() -> BindingsUpdateBackupFuncProtocol { + class CallbackObject: NSObject, BindingsUpdateBackupFuncProtocol { + init(_ callback: UpdateBackupFunc) { + self.callback = callback + } + + let callback: UpdateBackupFunc + + func updateBackup(_ encryptedBackup: Data?) { + guard let encryptedBackup = encryptedBackup else { + fatalError("BindingsUpdateBackupFunc received `nil` encryptedBackup") + } + callback.handle(encryptedBackup) + } + } + + return CallbackObject(self) + } +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Channel.swift b/Sources/ElixxirDAppsSDK/Channel/Channel.swift new file mode 100644 index 0000000000000000000000000000000000000000..532a04edc33bc471bac5a7697aa021b2f6725eb1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Channel.swift @@ -0,0 +1,37 @@ +import Bindings + +public struct Channel { + public var broadcast: ChannelBroadcast + public var broadcastAsymmetric: ChannelBroadcastAsymmetric + public var get: ChannelGet + public var listen: ChannelListen + public var maxAsymmetricPayloadSize: ChannelMaxAsymmetricPayloadSize + public var maxPayloadSize: ChannelMaxPayloadSize + public var stop: ChannelStop +} + +extension Channel { + public static func live(_ bindingsChannel: BindingsChannel) -> Channel { + Channel( + broadcast: .live(bindingsChannel), + broadcastAsymmetric: .live(bindingsChannel), + get: .live(bindingsChannel), + listen: .live(bindingsChannel), + maxAsymmetricPayloadSize: .live(bindingsChannel), + maxPayloadSize: .live(bindingsChannel), + stop: .live(bindingsChannel) + ) + } +} + +extension Channel { + public static let unimplemented = Channel( + broadcast: .unimplemented, + broadcastAsymmetric: .unimplemented, + get: .unimplemented, + listen: .unimplemented, + maxAsymmetricPayloadSize: .unimplemented, + maxPayloadSize: .unimplemented, + stop: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcast.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcast.swift new file mode 100644 index 0000000000000000000000000000000000000000..ee9a3adf8b5f4cf6e745a9f103715663165279bd --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcast.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelBroadcast { + public var run: (Data) throws -> Data + + public func callAsFunction(_ payload: Data) throws -> Data { + try run(payload) + } +} + +extension ChannelBroadcast { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelBroadcast { + ChannelBroadcast(run: bindingsChannel.broadcast) + } +} + +extension ChannelBroadcast { + public static let unimplemented = ChannelBroadcast( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcastAsymmetric.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcastAsymmetric.swift new file mode 100644 index 0000000000000000000000000000000000000000..9d92e00297cc99ce2b0b195180994cb0aa8666d0 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelBroadcastAsymmetric.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelBroadcastAsymmetric { + public var run: (Data, Data) throws -> Data + + public func callAsFunction( + payload: Data, + privateKey: Data + ) throws -> Data { + try run(payload, privateKey) + } +} + +extension ChannelBroadcastAsymmetric { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelBroadcastAsymmetric { + ChannelBroadcastAsymmetric(run: bindingsChannel.broadcastAsymmetric(_:pk:)) + } +} + +extension ChannelBroadcastAsymmetric { + public static let unimplemented = ChannelBroadcastAsymmetric( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelGet.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelGet.swift new file mode 100644 index 0000000000000000000000000000000000000000..7c27a3dca1b537f9a6bc0ef322d89b65c46ad412 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelGet.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelGet { + public var run: () throws -> ChannelDef + + public func callAsFunction() throws -> ChannelDef { + try run() + } +} + +extension ChannelGet { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelGet { + ChannelGet { + try ChannelDef.decode(bindingsChannel.get()) + } + } +} + +extension ChannelGet { + public static let unimplemented = ChannelGet( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelListen.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelListen.swift new file mode 100644 index 0000000000000000000000000000000000000000..65fc1089f9076c57ab2fae004ce0fdab79cd80d8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelListen.swift @@ -0,0 +1,30 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelListen { + public var run: (Int, BroadcastListener) throws -> Void + + public func callAsFunction( + method: Int, + callback: BroadcastListener + ) throws { + try run(method, callback) + } +} + +extension ChannelListen { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelListen { + ChannelListen { method, callback in + try bindingsChannel.listen( + callback.makeBindingsBroadcastListener(), + method: method + ) + } + } +} + +extension ChannelListen { + public static let unimplemented = ChannelListen( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxAsymmetricPayloadSize.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxAsymmetricPayloadSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..6b315b0f695f241d56b044822764b1266f5fd90d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxAsymmetricPayloadSize.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelMaxAsymmetricPayloadSize { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension ChannelMaxAsymmetricPayloadSize { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelMaxAsymmetricPayloadSize { + ChannelMaxAsymmetricPayloadSize(run: bindingsChannel.maxAsymmetricPayloadSize) + } +} + +extension ChannelMaxAsymmetricPayloadSize { + public static let unimplemented = ChannelMaxAsymmetricPayloadSize( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxPayloadSize.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxPayloadSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..b6ef89f873eb4d7667487e2242151b3f3cdf1b21 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelMaxPayloadSize.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelMaxPayloadSize { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension ChannelMaxPayloadSize { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelMaxPayloadSize { + ChannelMaxPayloadSize(run: bindingsChannel.maxPayloadSize) + } +} + +extension ChannelMaxPayloadSize { + public static let unimplemented = ChannelMaxPayloadSize( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelStop.swift b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelStop.swift new file mode 100644 index 0000000000000000000000000000000000000000..faddcb18be457355ec685e30fb3cb5ac937c1bed --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Channel/Functors/ChannelStop.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ChannelStop { + public var run: () -> Void + + public func callAsFunction() { + run() + } +} + +extension ChannelStop { + public static func live(_ bindingsChannel: BindingsChannel) -> ChannelStop { + ChannelStop(run: bindingsChannel.stop) + } +} + +extension ChannelStop { + public static let unimplemented = ChannelStop( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Client.swift b/Sources/ElixxirDAppsSDK/Client.swift deleted file mode 100644 index 650e6dc0c806e4abef292e405509cb02522dafef..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Client.swift +++ /dev/null @@ -1,48 +0,0 @@ -import Bindings - -public struct Client { - public var getId: ClientIdProvider - public var hasRunningProcesses: ClientProcessStatusProvider - public var networkFollower: NetworkFollower - public var waitForNetwork: NetworkWaiter - public var isNetworkHealthy: NetworkHealthProvider - public var monitorNetworkHealth: NetworkHealthListener - public var listenErrors: ClientErrorListener - public var makeIdentity: IdentityMaker - public var connect: ConnectionMaker - public var waitForDelivery: MessageDeliveryWaiter -} - -extension Client { - public static func live(bindingsClient: BindingsCmix) -> Client { - Client( - getId: .live(bindingsClient: bindingsClient), - hasRunningProcesses: .live(bindingsClient: bindingsClient), - networkFollower: .live(bindingsClient: bindingsClient), - waitForNetwork: .live(bindingsClient: bindingsClient), - isNetworkHealthy: .live(bindingsClient: bindingsClient), - monitorNetworkHealth: .live(bindingsClient: bindingsClient), - listenErrors: .live(bindingsClient: bindingsClient), - makeIdentity: .live(bindingsClient: bindingsClient), - connect: .live(bindingsClient: bindingsClient), - waitForDelivery: .live(bindingsClient: bindingsClient) - ) - } -} - -#if DEBUG -extension Client { - public static let failing = Client( - getId: .failing, - hasRunningProcesses: .failing, - networkFollower: .failing, - waitForNetwork: .failing, - isNetworkHealthy: .failing, - monitorNetworkHealth: .failing, - listenErrors: .failing, - makeIdentity: .failing, - connect: .failing, - waitForDelivery: .failing - ) -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientCreator.swift b/Sources/ElixxirDAppsSDK/ClientCreator.swift deleted file mode 100644 index 6021adc126b597b92de7068d8d5fd447cec36313..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientCreator.swift +++ /dev/null @@ -1,37 +0,0 @@ -import Bindings - -public struct ClientCreator { - public var create: (URL, Data, Data, String?) throws -> Void - - public func callAsFunction( - directoryURL: URL, - ndf: Data, - password: Data, - regCode: String? = nil - ) throws { - try create(directoryURL, ndf, password, regCode) - } -} - -extension ClientCreator { - public static let live = ClientCreator { directoryURL, ndf, password, regCode in - var error: NSError? - let network = String(data: ndf, encoding: .utf8)! - let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error) - if let error = error { - throw error - } - if !created { - fatalError("BindingsNewClient returned `false` without providing error") - } - } -} - -#if DEBUG -extension ClientCreator { - public static let failing = ClientCreator { _, _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientE2E.swift b/Sources/ElixxirDAppsSDK/ClientE2E.swift deleted file mode 100644 index b16c68a6f39f8d6bebab0c1003a50d582e1d0ba7..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientE2E.swift +++ /dev/null @@ -1,24 +0,0 @@ -import Bindings - -public struct ClientE2E { - public var getId: ClientE2EIdProvider - public var getContactFromIdentity: ContactFromIdentityProvider -} - -extension ClientE2E { - public static func live(bindingsClientE2E: BindingsE2e) -> ClientE2E { - ClientE2E( - getId: .live(bindingsClientE2E: bindingsClientE2E), - getContactFromIdentity: .live(bindingsClientE2E: bindingsClientE2E) - ) - } -} - -#if DEBUG -extension ClientE2E { - public static let failing = ClientE2E( - getId: .failing, - getContactFromIdentity: .failing - ) -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientE2EIdProvider.swift b/Sources/ElixxirDAppsSDK/ClientE2EIdProvider.swift deleted file mode 100644 index 4eadb5966c558281beb2e625422e79c9cd348600..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientE2EIdProvider.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Bindings - -public struct ClientE2EIdProvider { - public var get: () -> Int - - public func callAsFunction() -> Int { - get() - } -} - -extension ClientE2EIdProvider { - public static func live(bindingsClientE2E: BindingsE2e) -> ClientE2EIdProvider { - ClientE2EIdProvider(get: bindingsClientE2E.getID) - } -} - -#if DEBUG -extension ClientE2EIdProvider { - public static let failing = ClientE2EIdProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift b/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift deleted file mode 100644 index 6af64a4e46f19ae1b6d7f5c13348a99d1cf1672f..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift +++ /dev/null @@ -1,36 +0,0 @@ -import Bindings - -public struct ClientE2ELogin { - public var login: (Client) throws -> ClientE2E - - public func callAsFunction(with client: Client) throws -> ClientE2E { - try login(client) - } -} - -extension ClientE2ELogin { - public static let live = ClientE2ELogin { client in - var error: NSError? - let cMixId = client.getId() - let myIdentity = try client.makeIdentity() - let encoder = JSONEncoder() - let myIdentityData = try encoder.encode(myIdentity) - let bindingsClientE2E = BindingsLoginE2e(cMixId, nil, myIdentityData, &error) - if let error = error { - throw error - } - guard let bindingsClientE2E = bindingsClientE2E else { - fatalError("BindingsLoginE2E returned `nil` without providing error") - } - return ClientE2E.live(bindingsClientE2E: bindingsClientE2E) - } -} - -#if DEBUG -extension ClientE2ELogin { - public static let failing = ClientE2ELogin { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientErrorListener.swift b/Sources/ElixxirDAppsSDK/ClientErrorListener.swift deleted file mode 100644 index 7babe34e57c1ad2e9ae0ff33a760f55fda419dc9..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientErrorListener.swift +++ /dev/null @@ -1,48 +0,0 @@ -import Bindings - -public struct ClientErrorListener { - public var listen: (@escaping (ClientError) -> Void) -> Void - - public func callAsFunction(callback: @escaping (ClientError) -> Void) { - listen(callback) - } -} - -extension ClientErrorListener { - public static func live(bindingsClient: BindingsCmix) -> ClientErrorListener { - ClientErrorListener { callback in - let listener = Listener(onReport: callback) - bindingsClient.registerClientErrorCallback(listener) - } - } -} - -private final class Listener: NSObject, BindingsClientErrorProtocol { - init(onReport: @escaping (ClientError) -> Void) { - self.onReport = onReport - super.init() - } - - let onReport: (ClientError) -> Void - - func report(_ source: String?, message: String?, trace: String?) { - guard let source = source else { - fatalError("BindingsClientError.source is `nil`") - } - guard let message = message else { - fatalError("BindingsClientError.message is `nil`") - } - guard let trace = trace else { - fatalError("BindingsClientError.trace is `nil`") - } - onReport(ClientError(source: source, message: message, trace: trace)) - } -} - -#if DEBUG -extension ClientErrorListener { - public static let failing = ClientErrorListener { _ in - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientIdProvider.swift b/Sources/ElixxirDAppsSDK/ClientIdProvider.swift deleted file mode 100644 index acdfadbae87b69cb9c0f1ee1f6cd5601edfb8ec5..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientIdProvider.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Bindings - -public struct ClientIdProvider { - public var get: () -> Int - - public func callAsFunction() -> Int { - get() - } -} - -extension ClientIdProvider { - public static func live(bindingsClient: BindingsCmix) -> ClientIdProvider { - ClientIdProvider(get: bindingsClient.getID) - } -} - -#if DEBUG -extension ClientIdProvider { - public static let failing = ClientIdProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientLoader.swift b/Sources/ElixxirDAppsSDK/ClientLoader.swift deleted file mode 100644 index 7c1ca48a5972eb644509ac569b167eeb31a64172..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientLoader.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Bindings - -public struct ClientLoader { - public var load: (URL, Data) throws -> Client - - public func callAsFunction(directoryURL: URL, password: Data) throws -> Client { - try load(directoryURL, password) - } -} - -extension ClientLoader { - public static let live = ClientLoader { directoryURL, password in - var error: NSError? - let bindingsClient = BindingsLogin(directoryURL.path, password, &error) - if let error = error { - throw error - } - guard let bindingsClient = bindingsClient else { - fatalError("BindingsLogin returned `nil` without providing error") - } - return Client.live(bindingsClient: bindingsClient) - } -} - -#if DEBUG -extension ClientLoader { - public static let failing = ClientLoader { _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientProcessStatusProvider.swift b/Sources/ElixxirDAppsSDK/ClientProcessStatusProvider.swift deleted file mode 100644 index 4da5756277a848f8ca5131fed039ef1ff4ef7abe..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientProcessStatusProvider.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Bindings - -public struct ClientProcessStatusProvider { - public var get: () -> Bool - - public func callAsFunction() -> Bool { - get() - } -} - -extension ClientProcessStatusProvider { - public static func live(bindingsClient: BindingsCmix) -> ClientProcessStatusProvider { - ClientProcessStatusProvider(get: bindingsClient.hasRunningProcessies) - } -} - -#if DEBUG -extension ClientProcessStatusProvider { - public static let failing = ClientProcessStatusProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ClientStorage.swift b/Sources/ElixxirDAppsSDK/ClientStorage.swift deleted file mode 100644 index 7c18828b69e30f48fd14c69ec16913d2785bc784..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ClientStorage.swift +++ /dev/null @@ -1,69 +0,0 @@ -import Bindings - -public struct ClientStorage { - public var hasStoredClient: () -> Bool - public var createClient: () throws -> Client - public var loadClient: () throws -> Client - public var removeClient: () throws -> Void -} - -extension ClientStorage { - public static let defaultDirectoryURL = FileManager.default - .urls(for: .applicationSupportDirectory, in: .userDomainMask) - .first! - .appendingPathComponent("xx.network.client") - - public static func live( - environment: Environment = .mainnet, - directoryURL: URL = defaultDirectoryURL, - fileManager: FileManager = .default, - generatePassword: PasswordGenerator = .live, - passwordStorage: PasswordStorage, - downloadNDF: NDFDownloader = .live, - createClient: ClientCreator = .live, - loadClient: ClientLoader = .live - ) -> ClientStorage { - ClientStorage( - hasStoredClient: { - let contents = try? fileManager.contentsOfDirectory(atPath: directoryURL.path) - return contents.map { $0.isEmpty == false } ?? false - }, - createClient: { - let ndf = try downloadNDF(environment) - let password = generatePassword() - try passwordStorage.save(password) - try? fileManager.removeItem(at: directoryURL) - try? fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true) - try createClient(directoryURL: directoryURL, ndf: ndf, password: password) - return try loadClient(directoryURL: directoryURL, password: password) - }, - loadClient: { - let password = try passwordStorage.load() - return try loadClient(directoryURL: directoryURL, password: password) - }, - removeClient: { - try fileManager.removeItem(at: directoryURL) - } - ) - } -} - -#if DEBUG -extension ClientStorage { - public static let failing = ClientStorage( - hasStoredClient: { false }, - createClient: { - struct NotImplemented: Error {} - throw NotImplemented() - }, - loadClient: { - struct NotImplemented: Error {} - throw NotImplemented() - }, - removeClient: { - struct NotImplemented: Error {} - throw NotImplemented() - } - ) -} -#endif diff --git a/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift b/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift new file mode 100644 index 0000000000000000000000000000000000000000..a8d867715a687b9d1c7c62700549461fb6b610be --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift @@ -0,0 +1,55 @@ +import Bindings + +public struct Cmix { + public var getId: CmixGetId + public var makeReceptionIdentity: CmixMakeReceptionIdentity + public var makeLegacyReceptionIdentity: CmixMakeLegacyReceptionIdentity + public var isHealthy: CmixIsHealthy + public var hasRunningProcesses: CmixHasRunningProcesses + public var networkFollowerStatus: CmixNetworkFollowerStatus + public var startNetworkFollower: CmixStartNetworkFollower + public var stopNetworkFollower: CmixStopNetworkFollower + public var waitForNetwork: CmixWaitForNetwork + public var registerClientErrorCallback: CmixRegisterClientErrorCallback + public var addHealthCallback: CmixAddHealthCallback + public var waitForMessageDelivery: CmixWaitForMessageDelivery + public var connect: CmixConnect +} + +extension Cmix { + public static func live(_ bindingsCmix: BindingsCmix) -> Cmix { + Cmix( + getId: .live(bindingsCmix), + makeReceptionIdentity: .live(bindingsCmix), + makeLegacyReceptionIdentity: .live(bindingsCmix), + isHealthy: .live(bindingsCmix), + hasRunningProcesses: .live(bindingsCmix), + networkFollowerStatus: .live(bindingsCmix), + startNetworkFollower: .live(bindingsCmix), + stopNetworkFollower: .live(bindingsCmix), + waitForNetwork: .live(bindingsCmix), + registerClientErrorCallback: .live(bindingsCmix), + addHealthCallback: .live(bindingsCmix), + waitForMessageDelivery: .live(bindingsCmix), + connect: .live(bindingsCmix) + ) + } +} + +extension Cmix { + public static let unimplemented = Cmix( + getId: .unimplemented, + makeReceptionIdentity: .unimplemented, + makeLegacyReceptionIdentity: .unimplemented, + isHealthy: .unimplemented, + hasRunningProcesses: .unimplemented, + networkFollowerStatus: .unimplemented, + startNetworkFollower: .unimplemented, + stopNetworkFollower: .unimplemented, + waitForNetwork: .unimplemented, + registerClientErrorCallback: .unimplemented, + addHealthCallback: .unimplemented, + waitForMessageDelivery: .unimplemented, + connect: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..1326c85700ced8ae5b34b48bf87e17c7d91f67c9 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift @@ -0,0 +1,29 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixAddHealthCallback { + public var run: (HealthCallback) -> Cancellable + + public func callAsFunction(_ callback: HealthCallback) -> Cancellable { + run(callback) + } +} + +extension CmixAddHealthCallback { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixAddHealthCallback { + CmixAddHealthCallback { callback in + let id = bindingsCmix.add( + callback.makeBindingsHealthCallback() + ) + return Cancellable { + bindingsCmix.removeHealthCallback(id) + } + } + } +} + +extension CmixAddHealthCallback { + public static let unimplemented = CmixAddHealthCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift new file mode 100644 index 0000000000000000000000000000000000000000..ec795556f60bf877893c3eaf903708948745934c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixConnect { + public var run: (Bool, Int, Data, Data) throws -> Connection + + public func callAsFunction( + withAuthentication: Bool, + e2eId: Int, + recipientContact: Data, + e2eParamsJSON: Data + ) throws -> Connection { + try run(withAuthentication, e2eId, recipientContact, e2eParamsJSON) + } +} + +extension CmixConnect { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixConnect { + CmixConnect { withAuthentication, e2eId, recipientContact, e2eParamsJSON in + if withAuthentication { + return .live(try bindingsCmix.connect( + withAuthentication: e2eId, + recipientContact: recipientContact, + e2eParamsJSON: e2eParamsJSON + )) + } else { + return .live(try bindingsCmix.connect( + e2eId, + recipientContact: recipientContact, + e2eParamsJSON: e2eParamsJSON + )) + } + } + } +} + +extension CmixConnect { + public static let unimplemented = CmixConnect( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift new file mode 100644 index 0000000000000000000000000000000000000000..2d4a925562bd69e87f97124a043b86296e79b123 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixGetId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension CmixGetId { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixGetId { + CmixGetId(run: bindingsCmix.getID) + } +} + +extension CmixGetId { + public static let unimplemented = CmixGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift new file mode 100644 index 0000000000000000000000000000000000000000..0e83c257e4b41aba08e97599f6a52ff7d462b60a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixHasRunningProcesses { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension CmixHasRunningProcesses { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixHasRunningProcesses { + CmixHasRunningProcesses(run: bindingsCmix.hasRunningProcessies) + } +} + +extension CmixHasRunningProcesses { + public static let unimplemented = CmixHasRunningProcesses( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift new file mode 100644 index 0000000000000000000000000000000000000000..bdf89b846172f14f34bf10c5aaee18e5b1da5af1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixIsHealthy { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension CmixIsHealthy { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixIsHealthy { + CmixIsHealthy(run: bindingsCmix.isHealthy) + } +} + +extension CmixIsHealthy { + public static let unimplemented = CmixIsHealthy( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift new file mode 100644 index 0000000000000000000000000000000000000000..8ba84385b806e193ad3f1eff0058aace33b5b28f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixMakeLegacyReceptionIdentity { + public var run: () throws -> ReceptionIdentity + + public func callAsFunction() throws -> ReceptionIdentity { + try run() + } +} + +extension CmixMakeLegacyReceptionIdentity { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixMakeLegacyReceptionIdentity { + CmixMakeLegacyReceptionIdentity { + let data = try bindingsCmix.makeLegacyReceptionIdentity() + return try ReceptionIdentity.decode(data) + } + } +} + +extension CmixMakeLegacyReceptionIdentity { + public static let unimplemented = CmixMakeLegacyReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift new file mode 100644 index 0000000000000000000000000000000000000000..67588e9571ec07818bf4d7a4ced8b7955d5e5be6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixMakeReceptionIdentity { + public var run: () throws -> ReceptionIdentity + + public func callAsFunction() throws -> ReceptionIdentity { + try run() + } +} + +extension CmixMakeReceptionIdentity { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixMakeReceptionIdentity { + CmixMakeReceptionIdentity { + let data = try bindingsCmix.makeReceptionIdentity() + return try ReceptionIdentity.decode(data) + } + } +} + +extension CmixMakeReceptionIdentity { + public static let unimplemented = CmixMakeReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift new file mode 100644 index 0000000000000000000000000000000000000000..53857634ab759436b0c243f1972b1a789f33bf8e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixNetworkFollowerStatus { + public var run: () -> NetworkFollowerStatus + + public func callAsFunction() -> NetworkFollowerStatus { + run() + } +} + +extension CmixNetworkFollowerStatus { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixNetworkFollowerStatus { + CmixNetworkFollowerStatus { + NetworkFollowerStatus( + rawValue: bindingsCmix.networkFollowerStatus() + ) + } + } +} + +extension CmixNetworkFollowerStatus { + public static let unimplemented = CmixNetworkFollowerStatus( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..a8a56a8f402eb4f8d9efe7d4ca1aca8972c76367 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift @@ -0,0 +1,28 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixRegisterClientErrorCallback { + public var run: (ClientErrorCallback) -> Void + + public func callAsFunction( + _ callback: ClientErrorCallback + ) { + run(callback) + } +} + +extension CmixRegisterClientErrorCallback { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixRegisterClientErrorCallback { + CmixRegisterClientErrorCallback { callback in + bindingsCmix.registerClientErrorCallback( + callback.makeBindingsClientError() + ) + } + } +} + +extension CmixRegisterClientErrorCallback { + public static let unimplemented = CmixRegisterClientErrorCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift new file mode 100644 index 0000000000000000000000000000000000000000..6e6a80a0efc7c2f07d15ea05680e395e0f976f39 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixStartNetworkFollower { + public var run: (Int) throws -> Void + + public func callAsFunction(timeoutMS: Int) throws { + try run(timeoutMS) + } +} + +extension CmixStartNetworkFollower { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixStartNetworkFollower { + CmixStartNetworkFollower { timeoutMS in + try bindingsCmix.startNetworkFollower(timeoutMS) + } + } +} + +extension CmixStartNetworkFollower { + public static let unimplemented = CmixStartNetworkFollower( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift new file mode 100644 index 0000000000000000000000000000000000000000..140a415ee5f2a7894387f8227835eae34d7e2cb0 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixStopNetworkFollower { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension CmixStopNetworkFollower { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixStopNetworkFollower { + CmixStopNetworkFollower(run: bindingsCmix.stopNetworkFollower) + } +} + +extension CmixStopNetworkFollower { + public static let unimplemented = CmixStopNetworkFollower( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift new file mode 100644 index 0000000000000000000000000000000000000000..967c517ba71735f9634e9544c3dd2cb9574d7574 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift @@ -0,0 +1,32 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixWaitForMessageDelivery { + public var run: (E2ESendReport, Int, MessageDeliveryCallback) throws -> Void + + public func callAsFunction( + report: E2ESendReport, + timeoutMS: Int, + callback: MessageDeliveryCallback + ) throws { + try run(report, timeoutMS, callback) + } +} + +extension CmixWaitForMessageDelivery { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixWaitForMessageDelivery { + CmixWaitForMessageDelivery { report, timeoutMS, callback in + try bindingsCmix.wait( + forMessageDelivery: try report.encode(), + mdc: callback.makeBindingsMessageDeliveryCallback(), + timeoutMS: timeoutMS + ) + } + } +} + +extension CmixWaitForMessageDelivery { + public static let unimplemented = CmixWaitForMessageDelivery( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift new file mode 100644 index 0000000000000000000000000000000000000000..3174c69f0750e8c19ddc5330354e1682909c8a17 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixWaitForNetwork { + public var run: (Int) -> Bool + + public func callAsFunction(timeoutMS: Int) -> Bool { + run(timeoutMS) + } +} + +extension CmixWaitForNetwork { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixWaitForNetwork { + CmixWaitForNetwork(run: bindingsCmix.wait(forNetwork:)) + } +} + +extension CmixWaitForNetwork { + public static let unimplemented = CmixWaitForNetwork( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift b/Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift new file mode 100644 index 0000000000000000000000000000000000000000..6ab8eddad5c12bc61862e45536ca21b7e8cc5951 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift @@ -0,0 +1,63 @@ +import Bindings + +public struct CmixManager { + public var hasStorage: CmixManagerHasStorage + public var create: CmixManagerCreate + public var load: CmixManagerLoad + public var remove: CmixManagerRemove +} + +extension CmixManager { + public static func live( + directoryPath: String = FileManager.default + .urls(for: .applicationSupportDirectory, in: .userDomainMask) + .first! + .appendingPathComponent("xx.network.client") + .path, + fileManager: FileManager = .default, + environment: Environment = .mainnet, + downloadNDF: DownloadAndVerifySignedNdf = .live, + generateSecret: GenerateSecret = .live, + passwordStorage: PasswordStorage, + newCmix: NewCmix = .live, + getCmixParams: GetCmixParams = .liveDefault, + loadCmix: LoadCmix = .live + ) -> CmixManager { + CmixManager( + hasStorage: .live( + directoryPath: directoryPath, + fileManager: fileManager + ), + create: .live( + environment: environment, + downloadNDF: downloadNDF, + generateSecret: generateSecret, + passwordStorage: passwordStorage, + directoryPath: directoryPath, + fileManager: fileManager, + newCmix: newCmix, + getCmixParams: getCmixParams, + loadCmix: loadCmix + ), + load: .live( + directoryPath: directoryPath, + passwordStorage: passwordStorage, + getCmixParams: getCmixParams, + loadCmix: loadCmix + ), + remove: .live( + directoryPath: directoryPath, + fileManager: fileManager + ) + ) + } +} + +extension CmixManager { + public static let unimplemented = CmixManager( + hasStorage: .unimplemented, + create: .unimplemented, + load: .unimplemented, + remove: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift new file mode 100644 index 0000000000000000000000000000000000000000..3c6e983871106b5dab33db0f8fb031ea91a594fa --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift @@ -0,0 +1,49 @@ +import Foundation +import XCTestDynamicOverlay + +public struct CmixManagerCreate { + public var run: () throws -> Cmix + + public func callAsFunction() throws -> Cmix { + try run() + } +} + +extension CmixManagerCreate { + public static func live( + environment: Environment, + downloadNDF: DownloadAndVerifySignedNdf, + generateSecret: GenerateSecret, + passwordStorage: PasswordStorage, + directoryPath: String, + fileManager: FileManager, + newCmix: NewCmix, + getCmixParams: GetCmixParams, + loadCmix: LoadCmix + ) -> CmixManagerCreate { + CmixManagerCreate { + let ndfData = try downloadNDF(environment) + let password = generateSecret() + try passwordStorage.save(password) + try? fileManager.removeItem(atPath: directoryPath) + try? fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true) + try newCmix( + ndfJSON: String(data: ndfData, encoding: .utf8)!, + storageDir: directoryPath, + password: password, + registrationCode: nil + ) + return try loadCmix( + storageDir: directoryPath, + password: password, + cmixParamsJSON: getCmixParams() + ) + } + } +} + +extension CmixManagerCreate { + public static let unimplemented = CmixManagerCreate( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift new file mode 100644 index 0000000000000000000000000000000000000000..29a2b559d2293742a8d188815429ec81a4a33b80 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift @@ -0,0 +1,28 @@ +import Foundation +import XCTestDynamicOverlay + +public struct CmixManagerHasStorage { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension CmixManagerHasStorage { + public static func live( + directoryPath: String, + fileManager: FileManager + ) -> CmixManagerHasStorage { + CmixManagerHasStorage { + let contents = try? fileManager.contentsOfDirectory(atPath: directoryPath) + return contents.map { $0.isEmpty == false } ?? false + } + } +} + +extension CmixManagerHasStorage { + public static let unimplemented = CmixManagerHasStorage( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift new file mode 100644 index 0000000000000000000000000000000000000000..506cca47cd901a22706366ecc850721c9594e77c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift @@ -0,0 +1,32 @@ +import XCTestDynamicOverlay + +public struct CmixManagerLoad { + public var run: () throws -> Cmix + + public func callAsFunction() throws -> Cmix { + try run() + } +} + +extension CmixManagerLoad { + public static func live( + directoryPath: String, + passwordStorage: PasswordStorage, + getCmixParams: GetCmixParams, + loadCmix: LoadCmix + ) -> CmixManagerLoad { + CmixManagerLoad { + try loadCmix( + storageDir: directoryPath, + password: passwordStorage.load(), + cmixParamsJSON: getCmixParams() + ) + } + } +} + +extension CmixManagerLoad { + public static let unimplemented = CmixManagerLoad( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift new file mode 100644 index 0000000000000000000000000000000000000000..e3c390ea66cf98bf91ad660d969153fa885a4c12 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift @@ -0,0 +1,27 @@ +import Foundation +import XCTestDynamicOverlay + +public struct CmixManagerRemove { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension CmixManagerRemove { + public static func live( + directoryPath: String, + fileManager: FileManager + ) -> CmixManagerRemove { + CmixManagerRemove { + try fileManager.removeItem(atPath: directoryPath) + } + } +} + +extension CmixManagerRemove { + public static let unimplemented = CmixManagerRemove( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift deleted file mode 100644 index 00e18a81fef8334f4e329ff2acb5931a7d58d0ce..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Connection.swift +++ /dev/null @@ -1,51 +0,0 @@ -import Bindings - -public struct Connection { - public var getId: ConnectionIdProvider - public var isAuthenticated: ConnectionAuthStatusProvider - public var getPartner: ConnectionPartnerProvider - public var send: MessageSender - public var listen: MessageListener - public var close: ConnectionCloser -} - -extension Connection { - public static func live( - bindingsConnection: BindingsConnection - ) -> Connection { - Connection( - getId: .live(bindingsConnection: bindingsConnection), - isAuthenticated: .live(bindingsConnection: bindingsConnection), - getPartner: .live(bindingsConnection: bindingsConnection), - send: .live(bindingsConnection: bindingsConnection), - listen: .live(bindingsConnection: bindingsConnection), - close: .live(bindingsConnection: bindingsConnection) - ) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> Connection { - Connection( - getId: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - isAuthenticated: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - getPartner: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - close: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection) - ) - } -} - -#if DEBUG -extension Connection { - public static let failing = Connection( - getId: .failing, - isAuthenticated: .failing, - getPartner: .failing, - send: .failing, - listen: .failing, - close: .failing - ) -} -#endif diff --git a/Sources/ElixxirDAppsSDK/Connection/Connection.swift b/Sources/ElixxirDAppsSDK/Connection/Connection.swift new file mode 100644 index 0000000000000000000000000000000000000000..0ae7cf3261117edade698e6a385263e6a1a9fa76 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Connection.swift @@ -0,0 +1,45 @@ +import Bindings + +public struct Connection { + public var isAuthenticated: ConnectionIsAuthenticated + public var getId: ConnectionGetId + public var getPartner: ConnectionGetPartner + public var registerListener: ConnectionRegisterListener + public var send: ConnectionSend + public var close: ConnectionClose +} + +extension Connection { + public static func live(_ bindingsConnection: BindingsConnection) -> Connection { + Connection( + isAuthenticated: .live(bindingsConnection), + getId: .live(bindingsConnection), + getPartner: .live(bindingsConnection), + registerListener: .live(bindingsConnection), + send: .live(bindingsConnection), + close: .live(bindingsConnection) + ) + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> Connection { + Connection( + isAuthenticated: .live(bindingsConnection), + getId: .live(bindingsConnection), + getPartner: .live(bindingsConnection), + registerListener: .live(bindingsConnection), + send: .live(bindingsConnection), + close: .live(bindingsConnection) + ) + } +} + +extension Connection { + public static let unimplemented = Connection( + isAuthenticated: .unimplemented, + getId: .unimplemented, + getPartner: .unimplemented, + registerListener: .unimplemented, + send: .unimplemented, + close: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionClose.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionClose.swift new file mode 100644 index 0000000000000000000000000000000000000000..62115a0a5336eb23d32991e345591cc6da8e69e6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionClose.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionClose { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension ConnectionClose { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionClose { + ConnectionClose(run: bindingsConnection.close) + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionClose { + ConnectionClose(run: bindingsConnection.close) + } +} + +extension ConnectionClose { + public static let unimplemented = ConnectionClose( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetId.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetId.swift new file mode 100644 index 0000000000000000000000000000000000000000..cc97621222fc78b331af2a4a4d55a32bd69bc609 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetId.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionGetId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension ConnectionGetId { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionGetId { + ConnectionGetId(run: bindingsConnection.getId) + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionGetId { + ConnectionGetId(run: bindingsConnection.getId) + } +} + +extension ConnectionGetId { + public static let unimplemented = ConnectionGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetPartner.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetPartner.swift new file mode 100644 index 0000000000000000000000000000000000000000..50f784211a1445f61d6fb00b0b80dab21031fc9b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionGetPartner.swift @@ -0,0 +1,36 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionGetPartner { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension ConnectionGetPartner { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionGetPartner { + ConnectionGetPartner { + guard let data = bindingsConnection.getPartner() else { + fatalError("BindingsConnection.getPartner returned `nil`") + } + return data + } + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionGetPartner { + ConnectionGetPartner { + guard let data = bindingsConnection.getPartner() else { + fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`") + } + return data + } + } +} + +extension ConnectionGetPartner { + public static let unimplemented = ConnectionGetPartner( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionIsAuthenticated.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionIsAuthenticated.swift new file mode 100644 index 0000000000000000000000000000000000000000..86fc7f978eeb2137843579d4127cd5f080e55f6c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionIsAuthenticated.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionIsAuthenticated { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension ConnectionIsAuthenticated { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionIsAuthenticated { + ConnectionIsAuthenticated { false } + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionIsAuthenticated { + ConnectionIsAuthenticated(run: bindingsConnection.isAuthenticated) + } +} + +extension ConnectionIsAuthenticated { + public static let unimplemented = ConnectionIsAuthenticated( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionRegisterListener.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionRegisterListener.swift new file mode 100644 index 0000000000000000000000000000000000000000..d9bd4c39569cbcdd88bbfaaeedb0dfa6af542a45 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionRegisterListener.swift @@ -0,0 +1,39 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionRegisterListener { + public var run: (Int, Listener) throws -> Void + + public func callAsFunction( + messageType: Int, + listener: Listener + ) throws { + try run(messageType, listener) + } +} + +extension ConnectionRegisterListener { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionRegisterListener { + ConnectionRegisterListener { messageType, listener in + try bindingsConnection.registerListener( + messageType, + newListener: listener.makeBindingsListener() + ) + } + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionRegisterListener { + ConnectionRegisterListener { messageType, listener in + try bindingsConnection.registerListener( + messageType, + newListener: listener.makeBindingsListener() + ) + } + } +} + +extension ConnectionRegisterListener { + public static let unimplemented = ConnectionRegisterListener( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionSend.swift b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionSend.swift new file mode 100644 index 0000000000000000000000000000000000000000..c94ce34e3d195e04cb702a01f04495046ed07195 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection/Functors/ConnectionSend.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionSend { + public var run: (Int, Data) throws -> E2ESendReport + + public func callAsFunction( + messageType: Int, + payload: Data + ) throws -> E2ESendReport { + try run(messageType, payload) + } +} + +extension ConnectionSend { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionSend { + ConnectionSend { messageType, payload in + try E2ESendReport.decode( + bindingsConnection.sendE2E(messageType, payload: payload) + ) + } + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionSend { + ConnectionSend { messageType, payload in + try E2ESendReport.decode( + bindingsConnection.sendE2E(messageType, payload: payload) + ) + } + } +} + +extension ConnectionSend { + public static let unimplemented = ConnectionSend( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/ConnectionAuthStatusProvider.swift b/Sources/ElixxirDAppsSDK/ConnectionAuthStatusProvider.swift deleted file mode 100644 index d42e78f3caf3d66b2b4756b5986c9ea6916298fc..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ConnectionAuthStatusProvider.swift +++ /dev/null @@ -1,33 +0,0 @@ -import Bindings - -public struct ConnectionAuthStatusProvider { - public var isAuthenticated: () -> Bool - - public func callAsFunction() -> Bool { - isAuthenticated() - } -} - -extension ConnectionAuthStatusProvider { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionAuthStatusProvider { - ConnectionAuthStatusProvider { false } - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionAuthStatusProvider { - ConnectionAuthStatusProvider( - isAuthenticated: bindingsAuthenticatedConnection.isAuthenticated - ) - } -} - -#if DEBUG -extension ConnectionAuthStatusProvider { - public static let failing = ConnectionAuthStatusProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ConnectionCloser.swift b/Sources/ElixxirDAppsSDK/ConnectionCloser.swift deleted file mode 100644 index eb31677de4e3c630a944229503e7f3a70289718d..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ConnectionCloser.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Bindings - -public struct ConnectionCloser { - public var close: () throws -> Void - - public func callAsFunction() throws { - try close() - } -} - -extension ConnectionCloser { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionCloser { - ConnectionCloser(close: bindingsConnection.close) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionCloser { - ConnectionCloser(close: bindingsAuthenticatedConnection.close) - } -} - -#if DEBUG -extension ConnectionCloser { - public static let failing = ConnectionCloser { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ConnectionIdProvider.swift b/Sources/ElixxirDAppsSDK/ConnectionIdProvider.swift deleted file mode 100644 index 3261dfd46f312e337bd586a0f21930087a21c273..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ConnectionIdProvider.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Bindings - -public struct ConnectionIdProvider { - public var get: () -> Int - - public func callAsFunction() -> Int { - get() - } -} - -extension ConnectionIdProvider { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionIdProvider { - ConnectionIdProvider(get: bindingsConnection.getId) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionIdProvider { - ConnectionIdProvider(get: bindingsAuthenticatedConnection.getId) - } -} - -#if DEBUG -extension ConnectionIdProvider { - public static let failing = ConnectionIdProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift deleted file mode 100644 index aa3b4d6222166480f64437e5774afcf89cdb57f2..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift +++ /dev/null @@ -1,44 +0,0 @@ -import Bindings - -public struct ConnectionMaker { - public var connect: (Bool, Data, Int) throws -> Connection - - public func callAsFunction( - withAuthentication: Bool, - recipientContact: Data, - e2eId: Int - ) throws -> Connection { - try connect(withAuthentication, recipientContact, e2eId) - } -} - -extension ConnectionMaker { - public static func live(bindingsClient: BindingsCmix) -> ConnectionMaker { - ConnectionMaker { withAuthentication, recipientContact, e2eId in - if withAuthentication { - return Connection.live( - bindingsAuthenticatedConnection: try bindingsClient.connect( - withAuthentication: e2eId, - recipientContact: recipientContact - ) - ) - } else { - return Connection.live( - bindingsConnection: try bindingsClient.connect( - e2eId, - recipientContact: recipientContact - ) - ) - } - } - } -} - -#if DEBUG -extension ConnectionMaker { - public static let failing = ConnectionMaker { _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift b/Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift deleted file mode 100644 index 8d2bcbce76c9693f3b4a615d43a5f41193551c99..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift +++ /dev/null @@ -1,41 +0,0 @@ -import Bindings - -public struct ConnectionPartnerProvider { - public var get: () -> Data - - public func callAsFunction() -> Data { - get() - } -} - -extension ConnectionPartnerProvider { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionPartnerProvider { - ConnectionPartnerProvider { - guard let data = bindingsConnection.getPartner() else { - fatalError("BindingsConnection.getPartner returned `nil`") - } - return data - } - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionPartnerProvider { - ConnectionPartnerProvider { - guard let data = bindingsAuthenticatedConnection.getPartner() else { - fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`") - } - return data - } - } -} - -#if DEBUG -extension ConnectionPartnerProvider { - public static let failing = ConnectionPartnerProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ContactFactsProvider.swift b/Sources/ElixxirDAppsSDK/ContactFactsProvider.swift deleted file mode 100644 index 2029dc6f306aa74ef1fd48da93ed5038723e5e7b..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ContactFactsProvider.swift +++ /dev/null @@ -1,34 +0,0 @@ -import Bindings - -public struct ContactFactsProvider { - public var get: (Data) throws -> [Fact] - - public func callAsFunction(contact: Data) throws -> [Fact] { - try get(contact) - } -} - -extension ContactFactsProvider { - public static let live = ContactFactsProvider { contact in - var error: NSError? - let factsData = BindingsGetFactsFromContact(contact, &error) - if let error = error { - throw error - } - guard let factsData = factsData else { - fatalError("BindingsGetFactsFromContact returned `nil` without providing error") - } - let decoder = JSONDecoder() - let facts = try decoder.decode([Fact].self, from: factsData) - return facts - } -} - -#if DEBUG -extension ContactFactsProvider { - public static let failing = ContactFactsProvider { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ContactFactsSetter.swift b/Sources/ElixxirDAppsSDK/ContactFactsSetter.swift deleted file mode 100644 index 8dd0ed98e4ed1e8449b1df3c628c71798784de23..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ContactFactsSetter.swift +++ /dev/null @@ -1,37 +0,0 @@ -import Bindings - -public struct ContactFactsSetter { - public var set: (Data, [Fact]) throws -> Data - - public func callAsFunction( - contact: Data, - facts: [Fact] - ) throws -> Data { - try set(contact, facts) - } -} - -extension ContactFactsSetter { - public static let live = ContactFactsSetter { contact, facts in - let encoder = JSONEncoder() - let factsData = try encoder.encode(facts) - var error: NSError? - let updatedContact = BindingsSetFactsOnContact(contact, factsData, &error) - if let error = error { - throw error - } - guard let updatedContact = updatedContact else { - fatalError("BindingsSetFactsOnContact returned `nil` without providing error") - } - return updatedContact - } -} - -#if DEBUG -extension ContactFactsSetter { - public static let failing = ContactFactsSetter { _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ContactFromIdentityProvider.swift b/Sources/ElixxirDAppsSDK/ContactFromIdentityProvider.swift deleted file mode 100644 index e38a7c0172494308176e4056a3774613f5216b4e..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ContactFromIdentityProvider.swift +++ /dev/null @@ -1,30 +0,0 @@ -import Bindings - -public struct ContactFromIdentityProvider { - public var get: () throws -> Data - - public func callAsFunction() throws -> Data { - try get() - } -} - -extension ContactFromIdentityProvider { - public static func live(bindingsClientE2E: BindingsE2e) -> ContactFromIdentityProvider { - ContactFromIdentityProvider { - let contactData = bindingsClientE2E.getContact() - guard let contactData = contactData else { - fatalError("BindingsGetContact returned `nil` without providing error") - } - return contactData - } - } -} - -#if DEBUG -extension ContactFromIdentityProvider { - public static let failing = ContactFromIdentityProvider { - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/ContactPubkeyProvider.swift b/Sources/ElixxirDAppsSDK/ContactPubkeyProvider.swift deleted file mode 100644 index 4f97eed0d5fc5c6a80dd7810eac225621930a36b..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/ContactPubkeyProvider.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Bindings - -public struct ContactPubkeyProvider { - public var get: (Data) throws -> Data - - public func callAsFunction(contact: Data) throws -> Data { - try get(contact) - } -} - -extension ContactPubkeyProvider { - public static let live = ContactPubkeyProvider { contact in - var error: NSError? - let pubkey = BindingsGetPubkeyFromContact(contact, &error) - if let error = error { - throw error - } - guard let pubkey = pubkey else { - fatalError("BindingsGetPubkeyFromContact returned `nil` without providing error") - } - return pubkey - } -} - -#if DEBUG -extension ContactPubkeyProvider { - public static let failing = ContactPubkeyProvider { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/DependenciesProvider.swift b/Sources/ElixxirDAppsSDK/DependenciesProvider.swift deleted file mode 100644 index d9168cd1cdca4f0f58dddd54ef85651161d26f1e..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/DependenciesProvider.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Bindings - -public struct DependenciesProvider { - public var get: () -> String - - public func callAsFunction() -> String { - get() - } -} - -extension DependenciesProvider { - public static let live = DependenciesProvider(get: BindingsGetDependencies) -} - -#if DEBUG -extension DependenciesProvider { - public static let failing = DependenciesProvider { fatalError("Not implemented") } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/E2E/E2E.swift b/Sources/ElixxirDAppsSDK/E2E/E2E.swift new file mode 100644 index 0000000000000000000000000000000000000000..e127fdace0d45e8dd1ccf2a61046b37f0af4bd9b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/E2E.swift @@ -0,0 +1,79 @@ +import Bindings + +public struct E2E { + public var getId: E2EGetId + public var getReceptionId: E2EGetReceptionId + public var getHistoricalDHPrivateKey: E2EGetHistoricalDHPrivateKey + public var getHistoricalDHPublicKey: E2EGetHistoricalDHPublicKey + public var getContact: E2EGetContact + public var getAllPartnerIds: E2EGetAllPartnerIds + public var payloadSize: E2EPayloadSize + public var partitionSize: E2EPartitionSize + public var addPartnerCallback: E2EAddPartnerCallback + public var addService: E2EAddService + public var removeService: E2ERemoveService + public var hasAuthenticatedChannel: E2EHasAuthenticatedChannel + public var requestAuthenticatedChannel: E2ERequestAuthenticatedChannel + public var resetAuthenticatedChannel: E2EResetAuthenticatedChannel + public var callAllReceivedRequests: E2ECallAllReceivedRequests + public var getReceivedRequest: E2EGetReceivedRequest + public var deleteRequest: E2EDeleteRequest + public var verifyOwnership: E2EVerifyOwnership + public var confirmReceivedRequest: E2EConfirmReceivedRequest + public var replayConfirmReceivedRequest: E2EReplayConfirmReceivedRequest + public var send: E2ESend +} + +extension E2E { + public static func live(_ bindingsE2E: BindingsE2e) -> E2E { + E2E( + getId: .live(bindingsE2E), + getReceptionId: .live(bindingsE2E), + getHistoricalDHPrivateKey: .live(bindingsE2E), + getHistoricalDHPublicKey: .live(bindingsE2E), + getContact: .live(bindingsE2E), + getAllPartnerIds: .live(bindingsE2E), + payloadSize: .live(bindingsE2E), + partitionSize: .live(bindingsE2E), + addPartnerCallback: .live(bindingsE2E), + addService: .live(bindingsE2E), + removeService: .live(bindingsE2E), + hasAuthenticatedChannel: .live(bindingsE2E), + requestAuthenticatedChannel: .live(bindingsE2E), + resetAuthenticatedChannel: .live(bindingsE2E), + callAllReceivedRequests: .live(bindingsE2E), + getReceivedRequest: .live(bindingsE2E), + deleteRequest: .live(bindingsE2E), + verifyOwnership: .live(bindingsE2E), + confirmReceivedRequest: .live(bindingsE2E), + replayConfirmReceivedRequest: .live(bindingsE2E), + send: .live(bindingsE2E) + ) + } +} + +extension E2E { + public static let unimplemented = E2E( + getId: .unimplemented, + getReceptionId: .unimplemented, + getHistoricalDHPrivateKey: .unimplemented, + getHistoricalDHPublicKey: .unimplemented, + getContact: .unimplemented, + getAllPartnerIds: .unimplemented, + payloadSize: .unimplemented, + partitionSize: .unimplemented, + addPartnerCallback: .unimplemented, + addService: .unimplemented, + removeService: .unimplemented, + hasAuthenticatedChannel: .unimplemented, + requestAuthenticatedChannel: .unimplemented, + resetAuthenticatedChannel: .unimplemented, + callAllReceivedRequests: .unimplemented, + getReceivedRequest: .unimplemented, + deleteRequest: .unimplemented, + verifyOwnership: .unimplemented, + confirmReceivedRequest: .unimplemented, + replayConfirmReceivedRequest: .unimplemented, + send: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddPartnerCallback.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddPartnerCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..06713845c9ceae677e3c33e23de60131771bd772 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddPartnerCallback.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EAddPartnerCallback { + public var run: (Data, AuthCallbacks) throws -> Cancellable + + public func callAsFunction( + partnerId: Data, + callbacks: AuthCallbacks + ) throws -> Cancellable { + try run(partnerId, callbacks) + } +} + +extension E2EAddPartnerCallback { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EAddPartnerCallback { + E2EAddPartnerCallback { partnerId, callbacks in + try bindingsE2E.addPartnerCallback( + partnerId, + cb: callbacks.makeBindingsAuthCallbacks() + ) + return Cancellable { + do { + try bindingsE2E.deletePartnerCallback(partnerId) + } catch { + fatalError("BindingsE2e.deletePartnerCallback returned error: \(error)") + } + } + } + } +} + +extension E2EAddPartnerCallback { + public static let unimplemented = E2EAddPartnerCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddService.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddService.swift new file mode 100644 index 0000000000000000000000000000000000000000..c743f14827c0465b6b315d165d0b47ebb968426e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EAddService.swift @@ -0,0 +1,29 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EAddService { + public var run: (Processor) throws -> Void + + public func callAsFunction( + processor: Processor + ) throws { + try run(processor) + } +} + +extension E2EAddService { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EAddService { + E2EAddService { processor in + try bindingsE2E.addService( + processor.serviceTag, + processor: processor.makeBindingsProcessor() + ) + } + } +} + +extension E2EAddService { + public static let unimplemented = E2EAddService( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2ECallAllReceivedRequests.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ECallAllReceivedRequests.swift new file mode 100644 index 0000000000000000000000000000000000000000..703047246fc17f6f6c9e7f92a823ec77ba07ce44 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ECallAllReceivedRequests.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2ECallAllReceivedRequests { + public var run: () -> Void + + public func callAsFunction() { + run() + } +} + +extension E2ECallAllReceivedRequests { + public static func live(_ bindingsE2E: BindingsE2e) -> E2ECallAllReceivedRequests { + E2ECallAllReceivedRequests(run: bindingsE2E.callAllReceivedRequests) + } +} + +extension E2ECallAllReceivedRequests { + public static let unimplemented = E2ECallAllReceivedRequests( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EConfirmReceivedRequest.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EConfirmReceivedRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..f83cd0772e2aae27aaf8d6edf018c406edbdcc92 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EConfirmReceivedRequest.swift @@ -0,0 +1,28 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EConfirmReceivedRequest { + public var run: (Data) throws -> Int64 + + public func callAsFunction( + partnerContact: Data + ) throws -> Int64 { + try run(partnerContact) + } +} + +extension E2EConfirmReceivedRequest { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EConfirmReceivedRequest { + E2EConfirmReceivedRequest { partnerContact in + var result: Int64 = 0 + try bindingsE2E.confirm(partnerContact, ret0_: &result) + return result + } + } +} + +extension E2EConfirmReceivedRequest { + public static let unimplemented = E2EConfirmReceivedRequest( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EDeleteRequest.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EDeleteRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..c752e4ba273e5d6e7f20d93079ce22541dbf820c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EDeleteRequest.swift @@ -0,0 +1,29 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EDeleteRequest { + public var partner: (Data) throws -> Void + public var received: () throws -> Void + public var sent: () throws -> Void + public var all: () throws -> Void +} + +extension E2EDeleteRequest { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EDeleteRequest { + E2EDeleteRequest( + partner: bindingsE2E.deleteRequest(_:), + received: bindingsE2E.deleteReceiveRequests, + sent: bindingsE2E.deleteSentRequests, + all: bindingsE2E.deleteAllRequests + ) + } +} + +extension E2EDeleteRequest { + public static let unimplemented = E2EDeleteRequest( + partner: XCTUnimplemented("\(Self.self).partner"), + received: XCTUnimplemented("\(Self.self).received"), + sent: XCTUnimplemented("\(Self.self).sent"), + all: XCTUnimplemented("\(Self.self).all") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetAllPartnerIds.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetAllPartnerIds.swift new file mode 100644 index 0000000000000000000000000000000000000000..f4375932eaf69d4b95f3d78886da972e21878a0b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetAllPartnerIds.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetAllPartnerIds { + public var run: () throws -> Data + + public func callAsFunction() throws -> Data { + try run() + } +} + +extension E2EGetAllPartnerIds { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetAllPartnerIds { + E2EGetAllPartnerIds(run: bindingsE2E.getAllPartnerIDs) + } +} + +extension E2EGetAllPartnerIds { + public static let unimplemented = E2EGetAllPartnerIds( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetContact.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetContact.swift new file mode 100644 index 0000000000000000000000000000000000000000..9dba2d2bf05daf6733ffba612d1b8d3d35bc21fd --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetContact.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetContact { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension E2EGetContact { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetContact { + E2EGetContact { + guard let data = bindingsE2E.getContact() else { + fatalError("BindingsE2e.getContact returned `nil`") + } + return data + } + } +} + +extension E2EGetContact { + public static let unimplemented = E2EGetContact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPrivateKey.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPrivateKey.swift new file mode 100644 index 0000000000000000000000000000000000000000..619bdf05f565d2ce2068684aa28f694da1b03db4 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPrivateKey.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetHistoricalDHPrivateKey { + public var run: () throws -> Data + + public func callAsFunction() throws -> Data { + try run() + } +} + +extension E2EGetHistoricalDHPrivateKey { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetHistoricalDHPrivateKey { + E2EGetHistoricalDHPrivateKey(run: bindingsE2E.getHistoricalDHPrivkey) + } +} + +extension E2EGetHistoricalDHPrivateKey { + public static let unimplemented = E2EGetHistoricalDHPrivateKey( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPublicKey.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPublicKey.swift new file mode 100644 index 0000000000000000000000000000000000000000..d4eb4aa1a0bb43226641cb6f33a7d10270ba2334 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetHistoricalDHPublicKey.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetHistoricalDHPublicKey { + public var run: () throws -> Data + + public func callAsFunction() throws -> Data { + try run() + } +} + +extension E2EGetHistoricalDHPublicKey { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetHistoricalDHPublicKey { + E2EGetHistoricalDHPublicKey(run: bindingsE2E.getHistoricalDHPubkey) + } +} + +extension E2EGetHistoricalDHPublicKey { + public static let unimplemented = E2EGetHistoricalDHPublicKey( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetId.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetId.swift new file mode 100644 index 0000000000000000000000000000000000000000..b3ee86a2e658f507a74e6055f30a1c11e50f169d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetId.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension E2EGetId { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetId { + E2EGetId(run: bindingsE2E.getID) + } +} + +extension E2EGetId { + public static let unimplemented = E2EGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceivedRequest.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceivedRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..0ac9f0c39de45a1fba06c053bfd67643b3bfc935 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceivedRequest.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetReceivedRequest { + public var run: (Data) throws -> Data + + public func callAsFunction(partnerId: Data) throws -> Data { + try run(partnerId) + } +} + +extension E2EGetReceivedRequest { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetReceivedRequest { + E2EGetReceivedRequest(run: bindingsE2E.getReceivedRequest(_:)) + } +} + +extension E2EGetReceivedRequest { + public static let unimplemented = E2EGetReceivedRequest( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceptionId.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceptionId.swift new file mode 100644 index 0000000000000000000000000000000000000000..da24b408d26f0a45cf722c5f9124ce18ad294f9e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EGetReceptionId.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EGetReceptionId { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension E2EGetReceptionId { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EGetReceptionId { + E2EGetReceptionId { + guard let data = bindingsE2E.getReceptionID() else { + fatalError("BindingsE2e.getReceptionID returned `nil`") + } + return data + } + } +} + +extension E2EGetReceptionId { + public static let unimplemented = E2EGetReceptionId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EHasAuthenticatedChannel.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EHasAuthenticatedChannel.swift new file mode 100644 index 0000000000000000000000000000000000000000..3871ce867120aa5124aa51adeb06eb144b1cb123 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EHasAuthenticatedChannel.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EHasAuthenticatedChannel { + public var run: (Data) throws -> Bool + + public func callAsFunction(partnerId: Data) throws -> Bool { + try run(partnerId) + } +} + +extension E2EHasAuthenticatedChannel { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EHasAuthenticatedChannel { + E2EHasAuthenticatedChannel { partnerId in + var result: ObjCBool = false + try bindingsE2E.hasAuthenticatedChannel(partnerId, ret0_: &result) + return result.boolValue + } + } +} + +extension E2EHasAuthenticatedChannel { + public static let unimplemented = E2EHasAuthenticatedChannel( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPartitionSize.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPartitionSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..9f7a5267856e7b6ca3439d78c275c12784a8ba61 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPartitionSize.swift @@ -0,0 +1,30 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EPartitionSize { + public var first: () -> Int + public var second: () -> Int + public var atIndex: (Int) -> Int + + subscript(payloadIndex payloadIndex: Int) -> Int { + atIndex(payloadIndex) + } +} + +extension E2EPartitionSize { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EPartitionSize { + E2EPartitionSize( + first: bindingsE2E.firstPartitionSize, + second: bindingsE2E.secondPartitionSize, + atIndex: bindingsE2E.partitionSize(_:) + ) + } +} + +extension E2EPartitionSize { + public static let unimplemented = E2EPartitionSize( + first: XCTUnimplemented("\(Self.self).first"), + second: XCTUnimplemented("\(Self.self).second"), + atIndex: XCTUnimplemented("\(Self.self).atIndex") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPayloadSize.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPayloadSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..7412be29b9ab3246a698dee3a3257ba41dd1397a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EPayloadSize.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EPayloadSize { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension E2EPayloadSize { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EPayloadSize { + E2EPayloadSize(run: bindingsE2E.payloadSize) + } +} + +extension E2EPayloadSize { + public static let unimplemented = E2EPayloadSize( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERemoveService.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERemoveService.swift new file mode 100644 index 0000000000000000000000000000000000000000..c1d33cbe0c0413d7ae792966d19387c036ab781a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERemoveService.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2ERemoveService { + public var run: (String) throws -> Void + + public func callAsFunction(tag: String) throws { + try run(tag) + } +} + +extension E2ERemoveService { + public static func live(_ bindingsE2E: BindingsE2e) -> E2ERemoveService { + E2ERemoveService(run: bindingsE2E.removeService(_:)) + } +} + +extension E2ERemoveService { + public static let unimplemented = E2ERemoveService( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EReplayConfirmReceivedRequest.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EReplayConfirmReceivedRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..3bc6096671dc08859a941bf1ee8e80519e8e667d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EReplayConfirmReceivedRequest.swift @@ -0,0 +1,28 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EReplayConfirmReceivedRequest { + public var run: (Data) throws -> Int64 + + public func callAsFunction( + partnerId: Data + ) throws -> Int64 { + try run(partnerId) + } +} + +extension E2EReplayConfirmReceivedRequest { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EReplayConfirmReceivedRequest { + E2EReplayConfirmReceivedRequest { partnerId in + var result: Int64 = 0 + try bindingsE2E.replayConfirm(partnerId, ret0_: &result) + return result + } + } +} + +extension E2EReplayConfirmReceivedRequest { + public static let unimplemented = E2EReplayConfirmReceivedRequest( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERequestAuthenticatedChannel.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERequestAuthenticatedChannel.swift new file mode 100644 index 0000000000000000000000000000000000000000..f4dccad24a4d9ccbe4d34cfcc3afff3e6935692b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ERequestAuthenticatedChannel.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2ERequestAuthenticatedChannel { + public var run: (Data, [Fact]) throws -> Int64 + + public func callAsFunction( + partnerContact: Data, + myFacts: [Fact] + ) throws -> Int64 { + try run(partnerContact, myFacts) + } +} + +extension E2ERequestAuthenticatedChannel { + public static func live(_ bindingsE2E: BindingsE2e) -> E2ERequestAuthenticatedChannel { + E2ERequestAuthenticatedChannel { partnerContact, myFacts in + var roundId: Int64 = 0 + try bindingsE2E.request( + partnerContact, + factsListJson: try myFacts.encode(), + ret0_: &roundId + ) + return roundId + } + } +} + +extension E2ERequestAuthenticatedChannel { + public static let unimplemented = E2ERequestAuthenticatedChannel( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EResetAuthenticatedChannel.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EResetAuthenticatedChannel.swift new file mode 100644 index 0000000000000000000000000000000000000000..7b987fc900c486341378cea735dbd2f81e6faf2d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EResetAuthenticatedChannel.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EResetAuthenticatedChannel { + public var run: (Data) throws -> Int64 + + public func callAsFunction(partnerContact: Data) throws -> Int64 { + try run(partnerContact) + } +} + +extension E2EResetAuthenticatedChannel { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EResetAuthenticatedChannel { + E2EResetAuthenticatedChannel { partnerContact in + var roundId: Int64 = 0 + try bindingsE2E.reset(partnerContact, ret0_: &roundId) + return roundId + } + } +} + +extension E2EResetAuthenticatedChannel { + public static let unimplemented = E2EResetAuthenticatedChannel( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2ESend.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ESend.swift new file mode 100644 index 0000000000000000000000000000000000000000..16f6d1bc6e923e9eccb725e9e0f97d597c27b13a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2ESend.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2ESend { + public var run: (Int, Data, Data, Data) throws -> Data + + public func callAsFunction( + messageType: Int, + recipientId: Data, + payload: Data, + e2eParams: Data + ) throws -> Data { + try run(messageType, recipientId, payload, e2eParams) + } +} + +extension E2ESend { + public static func live(_ bindingsE2E: BindingsE2e) -> E2ESend { + E2ESend(run: bindingsE2E.sendE2E(_:recipientId:payload:e2eParams:)) + } +} + +extension E2ESend { + public static let unimplemented = E2ESend( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/E2E/Functors/E2EVerifyOwnership.swift b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EVerifyOwnership.swift new file mode 100644 index 0000000000000000000000000000000000000000..e6011bcab9cba7cd0f19b048af4f4f6d0ca7629e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/E2E/Functors/E2EVerifyOwnership.swift @@ -0,0 +1,35 @@ +import Bindings +import XCTestDynamicOverlay + +public struct E2EVerifyOwnership { + public var run: (Data, Data, Int) throws -> Bool + + public func callAsFunction( + receivedContact: Data, + verifiedContact: Data, + e2eId: Int + ) throws -> Bool { + try run(receivedContact, verifiedContact, e2eId) + } +} + +extension E2EVerifyOwnership { + public static func live(_ bindingsE2E: BindingsE2e) -> E2EVerifyOwnership { + E2EVerifyOwnership { receivedContact, verifiedContact, e2eId in + var result: ObjCBool = false + try bindingsE2E.verifyOwnership( + receivedContact, + verifiedContact: verifiedContact, + e2eId: e2eId, + ret0_: &result + ) + return result.boolValue + } + } +} + +extension E2EVerifyOwnership { + public static let unimplemented = E2EVerifyOwnership( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Fact.swift b/Sources/ElixxirDAppsSDK/Fact.swift deleted file mode 100644 index fa4a277b64bdbfedd773167da10d29dc4bf0d379..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Fact.swift +++ /dev/null @@ -1,19 +0,0 @@ -public struct Fact: Equatable { - public init( - fact: String, - type: Int - ) { - self.fact = fact - self.type = type - } - - public var fact: String - public var type: Int -} - -extension Fact: Codable { - enum CodingKeys: String, CodingKey { - case fact = "Fact" - case type = "Type" - } -} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/FilePartTracker.swift b/Sources/ElixxirDAppsSDK/FileTransfer/FilePartTracker.swift new file mode 100644 index 0000000000000000000000000000000000000000..0cd9bf335f430365b8bf47f3c2f5924942eff12c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/FilePartTracker.swift @@ -0,0 +1,22 @@ +import Bindings + +public struct FilePartTracker { + public var getNumParts: FilePartTrackerGetNumParts + public var getPartStatus: FilePartTrackerGetPartStatus +} + +extension FilePartTracker { + public static func live(_ bindingsTracker: BindingsFilePartTracker) -> FilePartTracker { + FilePartTracker( + getNumParts: .live(bindingsTracker), + getPartStatus: .live(bindingsTracker) + ) + } +} + +extension FilePartTracker { + public static let unimplemented = FilePartTracker( + getNumParts: .unimplemented, + getPartStatus: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/FileTransfer.swift b/Sources/ElixxirDAppsSDK/FileTransfer/FileTransfer.swift new file mode 100644 index 0000000000000000000000000000000000000000..4c83984dfc6b51d778e32bc0e27e43df861e6645 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/FileTransfer.swift @@ -0,0 +1,43 @@ +import Bindings + +public struct FileTransfer { + public var closeSend: FileTransferCloseSend + public var maxFileNameLen: FileTransferMaxFilenameLen + public var maxFileSize: FileTransferMaxFileSize + public var maxFileTypeLen: FileTransferMaxFileTypeLen + public var maxPreviewSize: FileTransferMaxPreviewSize + public var receive: FileTransferReceive + public var registerReceivedProgressCallback: FileTransferRegisterReceivedProgressCallback + public var registerSentProgressCallback: FileTransferRegisterSentProgressCallback + public var send: FileTransferSend +} + +extension FileTransfer { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransfer { + FileTransfer( + closeSend: .live(bindingsFileTransfer), + maxFileNameLen: .live(bindingsFileTransfer), + maxFileSize: .live(bindingsFileTransfer), + maxFileTypeLen: .live(bindingsFileTransfer), + maxPreviewSize: .live(bindingsFileTransfer), + receive: .live(bindingsFileTransfer), + registerReceivedProgressCallback: .live(bindingsFileTransfer), + registerSentProgressCallback: .live(bindingsFileTransfer), + send: .live(bindingsFileTransfer) + ) + } +} + +extension FileTransfer { + public static let unimplemented = FileTransfer( + closeSend: .unimplemented, + maxFileNameLen: .unimplemented, + maxFileSize: .unimplemented, + maxFileTypeLen: .unimplemented, + maxPreviewSize: .unimplemented, + receive: .unimplemented, + registerReceivedProgressCallback: .unimplemented, + registerSentProgressCallback: .unimplemented, + send: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetNumParts.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetNumParts.swift new file mode 100644 index 0000000000000000000000000000000000000000..fe1ae07d70ac43d71f29ce8ec8feb7068a44e3ee --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetNumParts.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FilePartTrackerGetNumParts { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension FilePartTrackerGetNumParts { + public static func live(_ tracker: BindingsFilePartTracker) -> FilePartTrackerGetNumParts { + FilePartTrackerGetNumParts(run: tracker.getNumParts) + } +} + +extension FilePartTrackerGetNumParts { + public static let unimplemented = FilePartTrackerGetNumParts( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetPartStatus.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetPartStatus.swift new file mode 100644 index 0000000000000000000000000000000000000000..9310d3d7a3bf781e54ac478eb9d091f1489be4e5 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FilePartTrackerGetPartStatus.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FilePartTrackerGetPartStatus { + public var run: (Int) -> FilePartStatus + + public func callAsFunction(partNum: Int) -> FilePartStatus { + run(partNum) + } +} + +extension FilePartTrackerGetPartStatus { + public static func live(_ tracker: BindingsFilePartTracker) -> FilePartTrackerGetPartStatus { + FilePartTrackerGetPartStatus { partNum in + FilePartStatus(rawValue: tracker.getPartStatus(partNum)) + } + } +} + +extension FilePartTrackerGetPartStatus { + public static let unimplemented = FilePartTrackerGetPartStatus( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferCloseSend.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferCloseSend.swift new file mode 100644 index 0000000000000000000000000000000000000000..e729435f852bd9db5c124a4408a5ad4db7bf3dd8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferCloseSend.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferCloseSend { + public var run: (Data) throws -> Void + + public func callAsFunction(transferId: Data) throws { + try run(transferId) + } +} + +extension FileTransferCloseSend { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferCloseSend { + FileTransferCloseSend(run: bindingsFileTransfer.closeSend) + } +} + +extension FileTransferCloseSend { + public static let unimplemented = FileTransferCloseSend( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileSize.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..02aea297f2b67646e429635b01d5a3a5015d7d40 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileSize.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferMaxFileSize { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension FileTransferMaxFileSize { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferMaxFileSize { + FileTransferMaxFileSize(run: bindingsFileTransfer.maxFileSize) + } +} + +extension FileTransferMaxFileSize { + public static let unimplemented = FileTransferMaxFileSize( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileTypeLen.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileTypeLen.swift new file mode 100644 index 0000000000000000000000000000000000000000..2d3fe39282c2c9fafbee7986bfec70ae6648b14e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFileTypeLen.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferMaxFileTypeLen { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension FileTransferMaxFileTypeLen { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferMaxFileTypeLen { + FileTransferMaxFileTypeLen(run: bindingsFileTransfer.maxFileTypeLen) + } +} + +extension FileTransferMaxFileTypeLen { + public static let unimplemented = FileTransferMaxFileTypeLen( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFilenameLen.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFilenameLen.swift new file mode 100644 index 0000000000000000000000000000000000000000..9db1d198331b19148eda492953e1fade5252b00b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxFilenameLen.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferMaxFilenameLen { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension FileTransferMaxFilenameLen { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferMaxFilenameLen { + FileTransferMaxFilenameLen(run: bindingsFileTransfer.maxFileNameLen) + } +} + +extension FileTransferMaxFilenameLen { + public static let unimplemented = FileTransferMaxFilenameLen( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxPreviewSize.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxPreviewSize.swift new file mode 100644 index 0000000000000000000000000000000000000000..a21163b2b7bf46821348e2c8ea499e55355b06ad --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferMaxPreviewSize.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferMaxPreviewSize { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension FileTransferMaxPreviewSize { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferMaxPreviewSize { + FileTransferMaxPreviewSize(run: bindingsFileTransfer.maxPreviewSize) + } +} + +extension FileTransferMaxPreviewSize { + public static let unimplemented = FileTransferMaxPreviewSize( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferReceive.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferReceive.swift new file mode 100644 index 0000000000000000000000000000000000000000..bd79c1a5997bd2c0116d793603d9a53877013cc8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferReceive.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferReceive { + public var run: (Data) throws -> Data + + public func callAsFunction(transferId: Data) throws -> Data { + try run(transferId) + } +} + +extension FileTransferReceive { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferReceive { + FileTransferReceive(run: bindingsFileTransfer.receive) + } +} + +extension FileTransferReceive { + public static let unimplemented = FileTransferReceive( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterReceivedProgressCallback.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterReceivedProgressCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..b094b3ca0e91c3457e084dbf6f398c8a3882d74d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterReceivedProgressCallback.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferRegisterReceivedProgressCallback { + public var run: (Data, String, FileTransferProgressCallback) throws -> Void + + public func callAsFunction( + transferId: Data, + period: String, + callback: FileTransferProgressCallback + ) throws { + try run(transferId, period, callback) + } +} + +extension FileTransferRegisterReceivedProgressCallback { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) + -> FileTransferRegisterReceivedProgressCallback { + FileTransferRegisterReceivedProgressCallback { transferId, period, callback in + try bindingsFileTransfer.registerReceivedProgressCallback( + transferId, + callback: callback.makeBindingsFileTransferReceiveProgressCallback(), + period: period + ) + } + } +} + +extension FileTransferRegisterReceivedProgressCallback { + public static let unimplemented = FileTransferRegisterReceivedProgressCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterSentProgressCallback.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterSentProgressCallback.swift new file mode 100644 index 0000000000000000000000000000000000000000..c1cfcbc40b0cf0c2d9c683af90793f24e061b4a7 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferRegisterSentProgressCallback.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferRegisterSentProgressCallback { + public var run: (Data, String, FileTransferProgressCallback) throws -> Void + + public func callAsFunction( + transferId: Data, + period: String, + callback: FileTransferProgressCallback + ) throws { + try run(transferId, period, callback) + } +} + +extension FileTransferRegisterSentProgressCallback { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) + -> FileTransferRegisterSentProgressCallback { + FileTransferRegisterSentProgressCallback { transferId, period, callback in + try bindingsFileTransfer.registerSentProgressCallback( + transferId, + callback: callback.makeBindingsFileTransferSentProgressCallback(), + period: period + ) + } + } +} + +extension FileTransferRegisterSentProgressCallback { + public static let unimplemented = FileTransferRegisterSentProgressCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferSend.swift b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferSend.swift new file mode 100644 index 0000000000000000000000000000000000000000..a23f859fd76a89be876aaa4ae5b7239cff059353 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/FileTransfer/Functors/FileTransferSend.swift @@ -0,0 +1,55 @@ +import Bindings +import XCTestDynamicOverlay + +public struct FileTransferSend { + public struct Params: Equatable { + public init( + payload: FileSend, + recipientId: Data, + paramsJSON: Data, + retry: Float, + period: String + ) { + self.payload = payload + self.recipientId = recipientId + self.paramsJSON = paramsJSON + self.retry = retry + self.period = period + } + + public var payload: FileSend + public var recipientId: Data + public var paramsJSON: Data + public var retry: Float + public var period: String + } + + public var run: (Params, FileTransferProgressCallback) throws -> Data + + public func callAsFunction( + params: Params, + callback: FileTransferProgressCallback + ) throws -> Data { + try run(params, callback) + } +} + +extension FileTransferSend { + public static func live(_ bindingsFileTransfer: BindingsFileTransfer) -> FileTransferSend { + FileTransferSend { params, callback in + try bindingsFileTransfer.send( + params.payload.encode(), + recipientID: params.recipientId, + retry: params.retry, + callback: callback.makeBindingsFileTransferSentProgressCallback(), + period: params.period + ) + } + } +} + +extension FileTransferSend { + public static let unimplemented = FileTransferSend( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/AsyncRequestRestlike.swift b/Sources/ElixxirDAppsSDK/Functors/AsyncRequestRestlike.swift new file mode 100644 index 0000000000000000000000000000000000000000..597f2b96b97de4d92947250acdc21265220ff47f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/AsyncRequestRestlike.swift @@ -0,0 +1,42 @@ +import Bindings +import XCTestDynamicOverlay + +public struct AsyncRequestRestlike { + public var run: (Int, Data, RestlikeMessage, Data, RestlikeCallback) throws -> Void + + public func callAsFunction( + e2eId: Int, + recipient: Data, + request: RestlikeMessage, + paramsJSON: Data, + callback: RestlikeCallback + ) throws { + try run(e2eId, recipient, request, paramsJSON, callback) + } +} + +extension AsyncRequestRestlike { + public static let live = AsyncRequestRestlike { e2dId, recipient, request, paramsJSON, callback in + var error: NSError? + let result = BindingsAsyncRequestRestLike( + e2dId, + recipient, + try request.encode(), + paramsJSON, + callback.makeBindingsRestlikeCallback(), + &error + ) + if let error = error { + throw error + } + guard result else { + fatalError("BindingsAsyncRequestRestLike returned `false` without providing error") + } + } +} + +extension AsyncRequestRestlike { + public static let unimplemented = AsyncRequestRestlike( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/NDFDownloader.swift b/Sources/ElixxirDAppsSDK/Functors/DownloadAndVerifySignedNdf.swift similarity index 61% rename from Sources/ElixxirDAppsSDK/NDFDownloader.swift rename to Sources/ElixxirDAppsSDK/Functors/DownloadAndVerifySignedNdf.swift index fed3385073a483752931e8eade5479229512d531..2c6ba075d0a6cbea1bf7482372fc46773e8f4e44 100644 --- a/Sources/ElixxirDAppsSDK/NDFDownloader.swift +++ b/Sources/ElixxirDAppsSDK/Functors/DownloadAndVerifySignedNdf.swift @@ -1,6 +1,7 @@ import Bindings +import XCTestDynamicOverlay -public struct NDFDownloader { +public struct DownloadAndVerifySignedNdf { public var run: (Environment) throws -> Data public func callAsFunction(_ env: Environment) throws -> Data { @@ -8,8 +9,8 @@ public struct NDFDownloader { } } -extension NDFDownloader { - public static let live = NDFDownloader { env in +extension DownloadAndVerifySignedNdf { + public static let live = DownloadAndVerifySignedNdf { env in var error: NSError? let data = BindingsDownloadAndVerifySignedNdfWithUrl( env.url.absoluteString, @@ -26,11 +27,8 @@ extension NDFDownloader { } } -#if DEBUG -extension NDFDownloader { - public static let failing = NDFDownloader { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } +extension DownloadAndVerifySignedNdf { + public static let unimplemented = DownloadAndVerifySignedNdf( + run: XCTUnimplemented("\(Self.self)") + ) } -#endif diff --git a/Sources/ElixxirDAppsSDK/Functors/EnableGrpcLogs.swift b/Sources/ElixxirDAppsSDK/Functors/EnableGrpcLogs.swift new file mode 100644 index 0000000000000000000000000000000000000000..3a56000d7c8dca004cecc348c00be3ba857b6af1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/EnableGrpcLogs.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct EnableGrpcLogs { + public var run: (LogWriter) -> Void + + public func callAsFunction(_ writer: LogWriter) { + run(writer) + } +} + +extension EnableGrpcLogs { + public static let live = EnableGrpcLogs { writer in + BindingsEnableGrpcLogs(writer.makeBindingsLogWriter()) + } +} + +extension EnableGrpcLogs { + public static let unimplemented = EnableGrpcLogs( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/PasswordGenerator.swift b/Sources/ElixxirDAppsSDK/Functors/GenerateSecret.swift similarity index 51% rename from Sources/ElixxirDAppsSDK/PasswordGenerator.swift rename to Sources/ElixxirDAppsSDK/Functors/GenerateSecret.swift index 4c5b978e7fd7e14ee367f437482aee25872fd655..3cf80be8712889deb0e3e035aaa7415e186408d4 100644 --- a/Sources/ElixxirDAppsSDK/PasswordGenerator.swift +++ b/Sources/ElixxirDAppsSDK/Functors/GenerateSecret.swift @@ -1,6 +1,7 @@ import Bindings +import XCTestDynamicOverlay -public struct PasswordGenerator { +public struct GenerateSecret { public var run: (Int) -> Data public func callAsFunction(numBytes: Int = 32) -> Data { @@ -8,8 +9,8 @@ public struct PasswordGenerator { } } -extension PasswordGenerator { - public static let live = PasswordGenerator { numBytes in +extension GenerateSecret { + public static let live = GenerateSecret { numBytes in guard let secret = BindingsGenerateSecret(numBytes) else { fatalError("BindingsGenerateSecret returned `nil`") } @@ -17,10 +18,8 @@ extension PasswordGenerator { } } -#if DEBUG -extension PasswordGenerator { - public static let failing = PasswordGenerator { _ in - fatalError("Not implemented") - } +extension GenerateSecret { + public static let unimplemented = GenerateSecret( + run: XCTUnimplemented("\(Self.self)") + ) } -#endif diff --git a/Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift new file mode 100644 index 0000000000000000000000000000000000000000..6cec08fedf48901971c1f9828226ff898da0a045 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetCmixParams { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GetCmixParams { + public static let liveDefault = GetCmixParams { + guard let data = BindingsGetDefaultCMixParams() else { + fatalError("BindingsGetDefaultCMixParams returned `nil`") + } + return data + } +} + +extension GetCmixParams { + public static let unimplemented = GetCmixParams( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetDependencies.swift b/Sources/ElixxirDAppsSDK/Functors/GetDependencies.swift new file mode 100644 index 0000000000000000000000000000000000000000..67a80a4871de92f0fecda3aff9d0cda8c5f037d8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetDependencies.swift @@ -0,0 +1,20 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetDependencies { + public var run: () -> String + + public func callAsFunction() -> String { + run() + } +} + +extension GetDependencies { + public static let live = GetDependencies(run: BindingsGetDependencies) +} + +extension GetDependencies { + public static let unimplemented = GetDependencies( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetE2EFileTransferParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetE2EFileTransferParams.swift new file mode 100644 index 0000000000000000000000000000000000000000..28618064d1c2528669c6d479fe32a84f71291b4f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetE2EFileTransferParams.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetE2EFileTransferParams { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GetE2EFileTransferParams { + public static let liveDefault = GetE2EFileTransferParams { + guard let data = BindingsGetDefaultE2eFileTransferParams() else { + fatalError("BindingsGetDefaultE2eFileTransferParams returned `nil`") + } + return data + } +} + +extension GetE2EFileTransferParams { + public static let unimplemented = GetE2EFileTransferParams( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/Functors/GetE2EParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetE2EParams.swift new file mode 100644 index 0000000000000000000000000000000000000000..2ef4cbac2327187cc6791898fba3a5f52301240d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetE2EParams.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetE2EParams { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GetE2EParams { + public static let liveDefault = GetE2EParams { + guard let data = BindingsGetDefaultE2EParams() else { + fatalError("BindingsGetDefaultE2EParams returned `nil`") + } + return data + } +} + +extension GetE2EParams { + public static let unimplemented = GetE2EParams( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetFactsFromContact.swift b/Sources/ElixxirDAppsSDK/Functors/GetFactsFromContact.swift new file mode 100644 index 0000000000000000000000000000000000000000..697f799741f21feec1aba79346d6d842b7cc2338 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetFactsFromContact.swift @@ -0,0 +1,30 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetFactsFromContact { + public var run: (Data) throws -> [Fact] + + public func callAsFunction(contact: Data) throws -> [Fact] { + try run(contact) + } +} + +extension GetFactsFromContact { + public static let live = GetFactsFromContact { contact in + var error: NSError? + let data = BindingsGetFactsFromContact(contact, &error) + if let error = error { + throw error + } + guard let data = data else { + fatalError("BindingsGetFactsFromContact returned `nil` without providing error") + } + return try [Fact].decode(data) + } +} + +extension GetFactsFromContact { + public static let unimplemented = GetFactsFromContact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift new file mode 100644 index 0000000000000000000000000000000000000000..e7f04545bc0c31e535363a32ec5ecc964eedb806 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetFileTransferParams { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GetFileTransferParams { + public static let liveDefault = GetFileTransferParams { + guard let data = BindingsGetDefaultFileTransferParams() else { + fatalError("BindingsGetDefaultFileTransferParams returned `nil`") + } + return data + } +} + +extension GetFileTransferParams { + public static let unimplemented = GetCmixParams( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/Functors/GetGitVersion.swift b/Sources/ElixxirDAppsSDK/Functors/GetGitVersion.swift new file mode 100644 index 0000000000000000000000000000000000000000..9eafe8b90f99a02f0a27a6fa50132b4d5952cc3d --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetGitVersion.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetGitVersion { + public var run: () -> String + + public func callAsFunction() -> String { + run() + } +} + +extension GetGitVersion { + public static let live = GetGitVersion( + run: BindingsGetGitVersion + ) +} + +extension GetGitVersion { + public static let unimplemented = GetGitVersion( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/ContactIdProvider.swift b/Sources/ElixxirDAppsSDK/Functors/GetIdFromContact.swift similarity index 50% rename from Sources/ElixxirDAppsSDK/ContactIdProvider.swift rename to Sources/ElixxirDAppsSDK/Functors/GetIdFromContact.swift index ea291167c1cbd08555b33326b9609c170306eb14..da6fc00cd3a96db50a1f90bb2ea8ba478fe61fab 100644 --- a/Sources/ElixxirDAppsSDK/ContactIdProvider.swift +++ b/Sources/ElixxirDAppsSDK/Functors/GetIdFromContact.swift @@ -1,15 +1,16 @@ import Bindings +import XCTestDynamicOverlay -public struct ContactIdProvider { - public var get: (Data) throws -> Data +public struct GetIdFromContact { + public var run: (Data) throws -> Data public func callAsFunction(contact: Data) throws -> Data { - try get(contact) + try run(contact) } } -extension ContactIdProvider { - public static let live = ContactIdProvider { contact in +extension GetIdFromContact { + public static let live = GetIdFromContact { contact in var error: NSError? let id = BindingsGetIDFromContact(contact, &error) if let error = error { @@ -22,11 +23,8 @@ extension ContactIdProvider { } } -#if DEBUG -extension ContactIdProvider { - public static let failing = ContactIdProvider { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } +extension GetIdFromContact { + public static let unimplemented = GetIdFromContact( + run: XCTUnimplemented("\(Self.self)") + ) } -#endif diff --git a/Sources/ElixxirDAppsSDK/Functors/GetPublicKeyFromContact.swift b/Sources/ElixxirDAppsSDK/Functors/GetPublicKeyFromContact.swift new file mode 100644 index 0000000000000000000000000000000000000000..1ec9acaa82fa6d0f8dc2b6ee484706c99af757c0 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetPublicKeyFromContact.swift @@ -0,0 +1,30 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetPublicKeyFromContact { + public var run: (Data) throws -> Data + + public func callAsFunction(contact: Data) throws -> Data { + try run(contact) + } +} + +extension GetPublicKeyFromContact { + public static let live = GetPublicKeyFromContact { contact in + var error: NSError? + let key = BindingsGetPubkeyFromContact(contact, &error) + if let error = error { + throw error + } + guard let key = key else { + fatalError("BindingsGetPubkeyFromContact returned `nil` without providing error") + } + return key + } +} + +extension GetPublicKeyFromContact { + public static let unimplemented = GetPublicKeyFromContact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift new file mode 100644 index 0000000000000000000000000000000000000000..2b296b3113c25fc138043bb20a4b06828bd2b948 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetSingleUseParams { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension GetSingleUseParams { + public static let liveDefault = GetSingleUseParams { + guard let data = BindingsGetDefaultSingleUseParams() else { + fatalError("BindingsGetDefaultSingleUseParams returned `nil`") + } + return data + } +} + +extension GetSingleUseParams { + public static let unimplemented = GetCmixParams( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetVersion.swift b/Sources/ElixxirDAppsSDK/Functors/GetVersion.swift new file mode 100644 index 0000000000000000000000000000000000000000..eee1535c69deef010d0b09b5c881e1bbc439a00e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/GetVersion.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetVersion { + public var run: () -> String + + public func callAsFunction() -> String { + run() + } +} + +extension GetVersion { + public static let live = GetVersion( + run: BindingsGetVersion + ) +} + +extension GetVersion { + public static let unimplemented = GetVersion( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/InitFileTransfer.swift b/Sources/ElixxirDAppsSDK/Functors/InitFileTransfer.swift new file mode 100644 index 0000000000000000000000000000000000000000..5d9712d7da2fd078222df9f7dc5e86b73c997a81 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/InitFileTransfer.swift @@ -0,0 +1,43 @@ +import Bindings +import XCTestDynamicOverlay + +public struct InitFileTransfer { + public var run: (Int, Data, Data, ReceiveFileCallback) throws -> FileTransfer + + public func callAsFunction( + e2eId: Int, + e2eFileTransferParamsJSON: Data, + fileTransferParamsJSON: Data, + callback: ReceiveFileCallback + ) throws -> FileTransfer { + try run(e2eId, e2eFileTransferParamsJSON, fileTransferParamsJSON, callback) + } +} + +extension InitFileTransfer { + public static let live = InitFileTransfer { + e2eId, e2eFileTransferParamsJSON, fileTransferParamsJSON, callback in + + var error: NSError? + let bindingsFileTransfer = BindingsInitFileTransfer( + e2eId, + callback.makeBindingsReceiveFileCallback(), + e2eFileTransferParamsJSON, + fileTransferParamsJSON, + &error + ) + if let error = error { + throw error + } + guard let bindingsFileTransfer = bindingsFileTransfer else { + fatalError("BindingsInitFileTransfer returned `nil` without providing error") + } + return .live(bindingsFileTransfer) + } +} + +extension InitFileTransfer { + public static let unimplemented = InitFileTransfer( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/InitializeBackup.swift b/Sources/ElixxirDAppsSDK/Functors/InitializeBackup.swift new file mode 100644 index 0000000000000000000000000000000000000000..735de567642ff7a83d1aa71cc3943f4a74ea52a8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/InitializeBackup.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct InitializeBackup { + public var run: (Int, Int, String, UpdateBackupFunc) throws -> Backup + + public func callAsFunction( + e2eId: Int, + udId: Int, + password: String, + callback: UpdateBackupFunc + ) throws -> Backup { + try run(e2eId, udId, password, callback) + } +} + +extension InitializeBackup { + public static let live = InitializeBackup { e2eId, udId, password, callback in + var error: NSError? + let bindingsBackup = BindingsInitializeBackup( + e2eId, + udId, + password, + callback.makeBindingsUpdateBackupFunc(), + &error + ) + if let error = error { + throw error + } + guard let bindingsBackup = bindingsBackup else { + fatalError("BindingsInitializeBackup returned `nil` without providing error") + } + return .live(bindingsBackup) + } +} + +extension InitializeBackup { + public static let unimplemented = InitializeBackup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/Listen.swift b/Sources/ElixxirDAppsSDK/Functors/Listen.swift new file mode 100644 index 0000000000000000000000000000000000000000..56bb47addfcdfbbc71b2834281ab1cfadaa0a427 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/Listen.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct Listen { + public var run: (Int, String, SingleUseCallback) throws -> Cancellable + + public func callAsFunction( + e2eId: Int, + tag: String, + callback: SingleUseCallback + ) throws -> Cancellable { + try run(e2eId, tag, callback) + } +} + +extension Listen { + public static let live = Listen { e2eId, tag, callback in + var error: NSError? + let stopper = BindingsListen( + e2eId, + tag, + callback.makeBindingsSingleUseCallback(), + &error + ) + if let error = error { + throw error + } + guard let stopper = stopper else { + fatalError("BindingsListen returned `nil` without providing error") + } + return Cancellable { + stopper.stop() + } + } +} + +extension Listen { + public static let unimplemented = Listen( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift b/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift new file mode 100644 index 0000000000000000000000000000000000000000..c388e9a333fd6f055f0bda7282309b34e0e66043 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LoadCmix { + public var run: (String, Data, Data) throws -> Cmix + + public func callAsFunction( + storageDir: String, + password: Data, + cmixParamsJSON: Data + ) throws -> Cmix { + try run(storageDir, password, cmixParamsJSON) + } +} + +extension LoadCmix { + public static let live = LoadCmix { storageDir, password, cmixParamsJSON in + var error: NSError? + let bindingsCmix = BindingsLoadCmix(storageDir, password, cmixParamsJSON, &error) + if let error = error { + throw error + } + guard let bindingsCmix = bindingsCmix else { + fatalError("BindingsLoadCmix returned `nil` without providing error") + } + return Cmix.live(bindingsCmix) + } +} + +extension LoadCmix { + public static let unimplemented = LoadCmix( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadOrNewUserDiscovery.swift b/Sources/ElixxirDAppsSDK/Functors/LoadOrNewUserDiscovery.swift new file mode 100644 index 0000000000000000000000000000000000000000..f1817eb0a066a6c73daa6b076834cc062c5a9262 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/LoadOrNewUserDiscovery.swift @@ -0,0 +1,43 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LoadOrNewUserDiscovery { + public var run: (Int, UdNetworkStatus, String, Data) throws -> UserDiscovery + + public func callAsFunction( + e2eId: Int, + follower: UdNetworkStatus, + username: String, + registrationValidationSignature: Data + ) throws -> UserDiscovery { + try run(e2eId, follower, username, registrationValidationSignature) + } +} + +extension LoadOrNewUserDiscovery { + public static let live = LoadOrNewUserDiscovery { + e2eId, follower, username, registrationValidationSignature in + + var error: NSError? + let bindingsUD = BindingsLoadOrNewUserDiscovery( + e2eId, + follower.makeBindingsUdNetworkStatus(), + username, + registrationValidationSignature, + &error + ) + if let error = error { + throw error + } + guard let bindingsUD = bindingsUD else { + fatalError("BindingsLoadOrNewUserDiscovery returned `nil` without providing error") + } + return .live(bindingsUD) + } +} + +extension LoadOrNewUserDiscovery { + public static let unimplemented = LoadOrNewUserDiscovery( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift new file mode 100644 index 0000000000000000000000000000000000000000..64506348055577f07abf71e97c82a715d05827fb --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LoadReceptionIdentity { + public var run: (String, Int) throws -> ReceptionIdentity + + public func callAsFunction( + key: String, + cmixId: Int + ) throws -> ReceptionIdentity { + try run(key, cmixId) + } +} + +extension LoadReceptionIdentity { + public static let live = LoadReceptionIdentity { key, cmixId in + var error: NSError? + let data = BindingsLoadReceptionIdentity(key, cmixId, &error) + if let error = error { + throw error + } + guard let data = data else { + fatalError("BindingsLoadReceptionIdentity returned `nil` without providing error") + } + return try ReceptionIdentity.decode(data) + } +} + +extension LoadReceptionIdentity { + public static let unimplemented = LoadReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/Login.swift b/Sources/ElixxirDAppsSDK/Functors/Login.swift new file mode 100644 index 0000000000000000000000000000000000000000..9ca617a6dd9fadbc523e33842d26d997c55666b1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/Login.swift @@ -0,0 +1,54 @@ +import Bindings +import XCTestDynamicOverlay + +public struct Login { + public var run: (Bool, Int, AuthCallbacks?, ReceptionIdentity, Data) throws -> E2E + + public func callAsFunction( + ephemeral: Bool, + cmixId: Int, + authCallbacks: AuthCallbacks? = nil, + identity: ReceptionIdentity, + e2eParamsJSON: Data + ) throws -> E2E { + try run(ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON) + } +} + +extension Login { + public static let live = Login { ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON in + var error: NSError? + let bindingsE2E: BindingsE2e? + if ephemeral { + bindingsE2E = BindingsLogin( + cmixId, + authCallbacks?.makeBindingsAuthCallbacks(), + try identity.encode(), + e2eParamsJSON, + &error + ) + } else { + bindingsE2E = BindingsLoginEphemeral( + cmixId, + authCallbacks?.makeBindingsAuthCallbacks(), + try identity.encode(), + e2eParamsJSON, + &error + ) + } + if let error = error { + throw error + } + guard let bindingsE2E = bindingsE2E else { + let functionName = "BindingsLogin\(ephemeral ? "Ephemeral" : "")" + fatalError("\(functionName) returned `nil` without providing error") + } + return .live(bindingsE2E) + } +} + +extension Login { + public static let unimplemented = Login( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift b/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift new file mode 100644 index 0000000000000000000000000000000000000000..11e519fa41f0cc38d067e5d494c0b8dd911bb279 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift @@ -0,0 +1,37 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewBroadcastChannel { + public var run: (Int, ChannelDef) throws -> Channel + + public func callAsFunction( + cmixId: Int, + channelDef: ChannelDef + ) throws -> Channel { + try run(cmixId, channelDef) + } +} + +extension NewBroadcastChannel { + public static let live = NewBroadcastChannel { cmixId, channelDef in + var error: NSError? + let bindingsChannel = BindingsNewBroadcastChannel( + cmixId, + try channelDef.encode(), + &error + ) + if let error = error { + throw error + } + guard let bindingsChannel = bindingsChannel else { + fatalError("BindingsNewBroadcastChannel returned `nil` without providing error") + } + return .live(bindingsChannel) + } +} + +extension NewBroadcastChannel { + public static let unimplemented = NewBroadcastChannel( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/NewCmix.swift b/Sources/ElixxirDAppsSDK/Functors/NewCmix.swift new file mode 100644 index 0000000000000000000000000000000000000000..4f906a46accc4b9bafd80bfc3fbe3780e589a85c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/NewCmix.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewCmix { + public var run: (String, String, Data, String?) throws -> Void + + public func callAsFunction( + ndfJSON: String, + storageDir: String, + password: Data, + registrationCode: String? + ) throws { + try run(ndfJSON, storageDir, password, registrationCode) + } +} + +extension NewCmix { + public static let live = NewCmix { ndfJSON, storageDir, password, registrationCode in + var error: NSError? + let result = BindingsNewCmix(ndfJSON, storageDir, password, registrationCode, &error) + if let error = error { + throw error + } + if !result { + fatalError("BindingsNewCmix returned `false` without providing error") + } + } +} + +extension NewCmix { + public static let unimplemented = NewCmix( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift b/Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift new file mode 100644 index 0000000000000000000000000000000000000000..2c7bbbc7a2623aebcf40949355e72ba4bcce5493 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift @@ -0,0 +1,45 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewCmixFromBackup { + public var run: (String, String, Data, Data, Data) throws -> BackupReport + + public func callAsFunction( + ndfJSON: String, + storageDir: String, + sessionPassword: Data, + backupPassphrase: Data, + backupFileContents: Data + ) throws -> BackupReport { + try run(ndfJSON, storageDir, sessionPassword, backupPassphrase, backupFileContents) + } +} + +extension NewCmixFromBackup { + public static let live = NewCmixFromBackup { + ndfJSON, storageDir, sessionPassword, backupPassphrase, backupFileContents in + + var error: NSError? + let reportData = BindingsNewCmixFromBackup( + ndfJSON, + storageDir, + sessionPassword, + backupPassphrase, + backupFileContents, + &error + ) + if let error = error { + throw error + } + guard let reportData = reportData else { + fatalError("BindingsNewCmixFromBackup returned `nil` without providing error") + } + return try BackupReport.decode(reportData) + } +} + +extension NewCmixFromBackup { + public static let unimplemented = NewCmixFromBackup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/NewUdManagerFromBackup.swift b/Sources/ElixxirDAppsSDK/Functors/NewUdManagerFromBackup.swift new file mode 100644 index 0000000000000000000000000000000000000000..a167a0846fe571c81ce60bcd8d7a033c81e9f306 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/NewUdManagerFromBackup.swift @@ -0,0 +1,43 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewUdManagerFromBackup { + public var run: (Int, UdNetworkStatus, Fact, Fact) throws -> UserDiscovery + + public func callAsFunction( + e2eId: Int, + follower: UdNetworkStatus, + email: Fact, + phone: Fact + ) throws -> UserDiscovery { + try run(e2eId, follower, email, phone) + } +} + +extension NewUdManagerFromBackup { + public static let live = NewUdManagerFromBackup { + e2eId, follower, email, phone in + + var error: NSError? + let bindingsUD = BindingsNewUdManagerFromBackup( + e2eId, + follower.makeBindingsUdNetworkStatus(), + try email.encode(), + try phone.encode(), + &error + ) + if let error = error { + throw error + } + guard let bindingsUD = bindingsUD else { + fatalError("BindingsNewUdManagerFromBackup returned `nil` without providing error") + } + return .live(bindingsUD) + } +} + +extension NewUdManagerFromBackup { + public static let unimplemented = NewUdManagerFromBackup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/RegisterLogWriter.swift b/Sources/ElixxirDAppsSDK/Functors/RegisterLogWriter.swift new file mode 100644 index 0000000000000000000000000000000000000000..f025bb59cd053ef58f7e6bac9f53b23eb3bad5d5 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/RegisterLogWriter.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct RegisterLogWriter { + public var run: (LogWriter) -> Void + + public func callAsFunction(_ writer: LogWriter) { + run(writer) + } +} + +extension RegisterLogWriter { + public static let live = RegisterLogWriter { writer in + BindingsRegisterLogWriter(writer.makeBindingsLogWriter()) + } +} + +extension RegisterLogWriter { + public static let unimplemented = RegisterLogWriter( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/RequestRestlike.swift b/Sources/ElixxirDAppsSDK/Functors/RequestRestlike.swift new file mode 100644 index 0000000000000000000000000000000000000000..04d25ecb39daf3df05ebd7942f11f365ee4dfd6e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/RequestRestlike.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct RequestRestlike { + public var run: (Int, Data, RestlikeMessage, Data) throws -> RestlikeMessage + + public func callAsFunction( + e2eId: Int, + recipient: Data, + request: RestlikeMessage, + paramsJSON: Data + ) throws -> RestlikeMessage { + try run(e2eId, recipient, request, paramsJSON) + } +} + +extension RequestRestlike { + public static let live = RequestRestlike { e2dId, recipient, request, paramsJSON in + var error: NSError? + let responseData = BindingsRequestRestLike( + e2dId, + recipient, + try request.encode(), + paramsJSON, + &error + ) + if let error = error { + throw error + } + guard let responseData = responseData else { + fatalError("BindingsRequestRestLike returned `nil` without providing error") + } + return try RestlikeMessage.decode(responseData) + } +} + +extension RequestRestlike { + public static let unimplemented = RequestRestlike( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/RestlikeRequest.swift b/Sources/ElixxirDAppsSDK/Functors/RestlikeRequest.swift new file mode 100644 index 0000000000000000000000000000000000000000..a0e442e1383c11ed24eb7983189a8dce96c1506c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/RestlikeRequest.swift @@ -0,0 +1,57 @@ +import Bindings +import XCTestDynamicOverlay + +public struct RestlikeRequest { + public var run: (Bool, Int, Int, RestlikeMessage, Data) throws -> RestlikeMessage + + public func callAsFunction( + authenticated: Bool, + clientId: Int, + connectionId: Int, + request: RestlikeMessage, + e2eParams: Data + ) throws -> RestlikeMessage { + try run(authenticated, clientId, connectionId, request, e2eParams) + } +} + +extension RestlikeRequest { + public static let live = RestlikeRequest { + authenticated, clientId, connectionId, request, e2eParams in + + let requestData = try request.encode() + var error: NSError? + let responseData: Data? + if authenticated { + responseData = BindingsRestlikeRequest( + clientId, + connectionId, + requestData, + e2eParams, + &error + ) + } else { + responseData = BindingsRestlikeRequestAuth( + clientId, + connectionId, + requestData, + e2eParams, + &error + ) + } + if let error = error { + throw error + } + guard let responseData = responseData else { + let functionName = "BindingsRestlikeRequest\(authenticated ? "Auth" : "")" + fatalError("\(functionName) returned `nil` without providing error") + } + return try RestlikeMessage.decode(responseData) + } +} + +extension RestlikeRequest { + public static let unimplemented = RestlikeRequest( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/ResumeBackup.swift b/Sources/ElixxirDAppsSDK/Functors/ResumeBackup.swift new file mode 100644 index 0000000000000000000000000000000000000000..f557dd566fa9623a28705cdd28653f7f02c1ab47 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/ResumeBackup.swift @@ -0,0 +1,39 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ResumeBackup { + public var run: (Int, Int, UpdateBackupFunc) throws -> Backup + + public func callAsFunction( + e2eId: Int, + udId: Int, + callback: UpdateBackupFunc + ) throws -> Backup { + try run(e2eId, udId, callback) + } +} + +extension ResumeBackup { + public static let live = ResumeBackup { e2eId, udId, callback in + var error: NSError? + let bindingsBackup = BindingsResumeBackup( + e2eId, + udId, + callback.makeBindingsUpdateBackupFunc(), + &error + ) + if let error = error { + throw error + } + guard let bindingsBackup = bindingsBackup else { + fatalError("BindingsResumeBackup returned `nil` without providing error") + } + return .live(bindingsBackup) + } +} + +extension ResumeBackup { + public static let unimplemented = ResumeBackup( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/SetFactsOnContact.swift b/Sources/ElixxirDAppsSDK/Functors/SetFactsOnContact.swift new file mode 100644 index 0000000000000000000000000000000000000000..739a4f17fc9abfa63e6568d627354b29db423d83 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/SetFactsOnContact.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct SetFactsOnContact { + public var run: (Data, [Fact]) throws -> Data + + public func callAsFunction( + contact: Data, + facts: [Fact] + ) throws -> Data { + try run(contact, facts) + } +} + +extension SetFactsOnContact { + public static let live = SetFactsOnContact { contact, facts in + let factsData = try facts.encode() + var error: NSError? + let updatedContact = BindingsSetFactsOnContact(contact, factsData, &error) + if let error = error { + throw error + } + guard let updatedContact = updatedContact else { + fatalError("BindingsSetFactsOnContact returned `nil` without providing error") + } + return updatedContact + } +} + +extension SetFactsOnContact { + public static let unimplemented = SetFactsOnContact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/SetLogLevel.swift b/Sources/ElixxirDAppsSDK/Functors/SetLogLevel.swift new file mode 100644 index 0000000000000000000000000000000000000000..487bfd8e23c402c17b2f712ebf92bec520bbcc97 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/SetLogLevel.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct SetLogLevel { + public var run: (LogLevel) throws -> Bool + + public func callAsFunction(_ logLevel: LogLevel) throws -> Bool { + try run(logLevel) + } +} + +extension SetLogLevel { + public static let live = SetLogLevel { logLevel in + var error: NSError? + let result = BindingsLogLevel(logLevel.rawValue, &error) + if let error = error { + throw error + } + return result + } +} + +extension SetLogLevel { + public static let unimplemented = SetLogLevel( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift new file mode 100644 index 0000000000000000000000000000000000000000..5752bd5d91884b12b71ac6be812346b8d0e21fcb --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift @@ -0,0 +1,32 @@ +import Bindings +import XCTestDynamicOverlay + +public struct StoreReceptionIdentity { + public var run: (String, ReceptionIdentity, Int) throws -> Bool + + public func callAsFunction( + key: String, + identity: ReceptionIdentity, + cmixId: Int + ) throws -> Bool { + try run(key, identity, cmixId) + } +} + +extension StoreReceptionIdentity { + public static let live = StoreReceptionIdentity { key, identity, cmixId in + var error: NSError? + let identityData = try identity.encode() + let result = BindingsStoreReceptionIdentity(key, identityData, cmixId, &error) + if let error = error { + throw error + } + return result + } +} + +extension StoreReceptionIdentity { + public static let unimplemented = StoreReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/TransmitSingleUse.swift b/Sources/ElixxirDAppsSDK/Functors/TransmitSingleUse.swift new file mode 100644 index 0000000000000000000000000000000000000000..07af4e12ee02963c23c1c3d505b5941222c693a5 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/TransmitSingleUse.swift @@ -0,0 +1,63 @@ +import Bindings +import XCTestDynamicOverlay + +public struct TransmitSingleUse { + public struct Params: Equatable { + public init( + e2eId: Int, + recipient: Data, + tag: String, + payload: Data, + paramsJSON: Data + ) { + self.e2eId = e2eId + self.recipient = recipient + self.tag = tag + self.payload = payload + self.paramsJSON = paramsJSON + } + + public var e2eId: Int + public var recipient: Data + public var tag: String + public var payload: Data + public var paramsJSON: Data + } + + public var run: (Params, SingleUseResponse) throws -> SingleUseSendReport + + public func callAsFunction( + params: Params, + callback: SingleUseResponse + ) throws -> SingleUseSendReport { + try run(params, callback) + } +} + +extension TransmitSingleUse { + public static let live = TransmitSingleUse { params, callback in + var error: NSError? + let reportData = BindingsTransmitSingleUse( + params.e2eId, + params.recipient, + params.tag, + params.payload, + params.paramsJSON, + callback.makeBindingsSingleUseResponse(), + &error + ) + if let error = error { + throw error + } + guard let reportData = reportData else { + fatalError("BindingsTransmitSingleUse returned `nil` without providing error") + } + return try SingleUseSendReport.decode(reportData) + } +} + +extension TransmitSingleUse { + public static let unimplemented = TransmitSingleUse( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/GitVersionProvider.swift b/Sources/ElixxirDAppsSDK/GitVersionProvider.swift deleted file mode 100644 index 29ef07a39bff3323a95df2eb176985deb176e241..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/GitVersionProvider.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Bindings - -public struct GitVersionProvider { - public var get: () -> String - - public func callAsFunction() -> String { - get() - } -} - -extension GitVersionProvider { - public static let live = GitVersionProvider(get: BindingsGetGitVersion) -} - -#if DEBUG -extension GitVersionProvider { - public static let failing = GitVersionProvider { fatalError("Not implemented") } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/Cancellable.swift b/Sources/ElixxirDAppsSDK/Helpers/Cancellable.swift similarity index 100% rename from Sources/ElixxirDAppsSDK/Cancellable.swift rename to Sources/ElixxirDAppsSDK/Helpers/Cancellable.swift diff --git a/Sources/ElixxirDAppsSDK/PasswordStorage.swift b/Sources/ElixxirDAppsSDK/Helpers/PasswordStorage.swift similarity index 62% rename from Sources/ElixxirDAppsSDK/PasswordStorage.swift rename to Sources/ElixxirDAppsSDK/Helpers/PasswordStorage.swift index 89df9af8f14b84fc947e9e7ef4059488a295f504..bf84f6dd4338a62fcd1604f924099a52a36b9e36 100644 --- a/Sources/ElixxirDAppsSDK/PasswordStorage.swift +++ b/Sources/ElixxirDAppsSDK/Helpers/PasswordStorage.swift @@ -1,4 +1,5 @@ import Foundation +import XCTestDynamicOverlay public struct PasswordStorage { public struct MissingPasswordError: Error, Equatable { @@ -17,17 +18,9 @@ public struct PasswordStorage { public var load: () throws -> Data } -#if DEBUG extension PasswordStorage { - public static let failing = PasswordStorage( - save: { _ in - struct NotImplemented: Error {} - throw NotImplemented() - }, - load: { - struct NotImplemented: Error {} - throw NotImplemented() - } + public static let unimplemented = PasswordStorage( + save: XCTUnimplemented("\(Self.self).save"), + load: XCTUnimplemented("\(Self.self).load") ) } -#endif diff --git a/Sources/ElixxirDAppsSDK/IdentityMaker.swift b/Sources/ElixxirDAppsSDK/IdentityMaker.swift deleted file mode 100644 index 6e214d6c20878656a2d798a3fb6b1d956b018b11..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/IdentityMaker.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Bindings - -public struct IdentityMaker { - public var make: () throws -> Identity - - public func callAsFunction() throws -> Identity { - try make() - } -} - -extension IdentityMaker { - public static func live(bindingsClient: BindingsCmix) -> IdentityMaker { - IdentityMaker { - let data = try bindingsClient.makeIdentity() - let decoder = JSONDecoder() - return try decoder.decode(Identity.self, from: data) - } - } -} - -#if DEBUG -extension IdentityMaker { - public static let failing = IdentityMaker { - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/LogLevelConfigurator.swift b/Sources/ElixxirDAppsSDK/LogLevelConfigurator.swift deleted file mode 100644 index 6137fc838a143b09ece6ca96a07a1334108cf44f..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/LogLevelConfigurator.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Bindings - -public struct LogLevelConfigurator { - public var set: (LogLevel) throws -> Void - - public func callAsFunction(logLevel: LogLevel) throws { - try set(logLevel) - } -} - -extension LogLevelConfigurator { - public static let live = LogLevelConfigurator { logLevel in - var error: NSError? - let result = BindingsLogLevel(logLevel.rawValue, &error) - if let error = error { - throw error - } - if !result { - fatalError("BindingsLogLevel returned `false` without providing error") - } - } -} - -#if DEBUG -extension LogLevelConfigurator { - public static let failing = LogLevelConfigurator { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/LogsListener.swift b/Sources/ElixxirDAppsSDK/LogsListener.swift deleted file mode 100644 index 2b070877dbac36f8cb170fbd5ecb7af3271fbc74..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/LogsListener.swift +++ /dev/null @@ -1,40 +0,0 @@ -import Bindings - -public struct LogsListener { - public var listen: (@escaping (String) -> Void) -> Void - - public func callAsFunction(callback: @escaping (String) -> Void) { - listen(callback) - } -} - -extension LogsListener { - public static let live = LogsListener { callback in - let listener = Listener(onLog: callback) - BindingsRegisterLogWriter(listener) - } -} - -private final class Listener: NSObject, BindingsLogWriterProtocol { - init(onLog: @escaping (String) -> Void) { - self.onLog = onLog - super.init() - } - - let onLog: (String) -> Void - - func log(_ p0: String?) { - guard let p0 = p0 else { - fatalError("BindingsLogWriter.log received `nil`") - } - onLog(p0) - } -} - -#if DEBUG -extension LogsListener { - public static let failing = LogsListener { _ in - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift b/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift deleted file mode 100644 index fa6620f26f1240fc7da934ae72637b0d266ad90f..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift +++ /dev/null @@ -1,71 +0,0 @@ -import Bindings - -public struct MessageDeliveryWaiter { - public enum Result: Equatable { - case delivered(roundResults: [Int]) - case notDelivered(timedOut: Bool) - } - - public var wait: (MessageSendReport, Int, @escaping (Result) -> Void) throws -> Void - - public func callAsFunction( - report: MessageSendReport, - timeoutMS: Int, - callback: @escaping (Result) -> Void - ) throws { - try wait(report, timeoutMS, callback) - } -} - -extension MessageDeliveryWaiter { - public static func live(bindingsClient: BindingsCmix) -> MessageDeliveryWaiter { - MessageDeliveryWaiter { report, timeoutMS, callback in - let encoder = JSONEncoder() - let reportData = try encoder.encode(report) - try bindingsClient.wait( - forMessageDelivery: reportData, - mdc: Callback(onCallback: callback), - timeoutMS: timeoutMS - ) - } - } -} - -private final class Callback: NSObject, BindingsMessageDeliveryCallbackProtocol { - init(onCallback: @escaping (MessageDeliveryWaiter.Result) -> Void) { - self.onCallback = onCallback - super.init() - } - - let onCallback: (MessageDeliveryWaiter.Result) -> Void - - func eventCallback(_ delivered: Bool, timedOut: Bool, roundResults: Data?) { - if delivered, !timedOut, let roundResultsData = roundResults { - let decoder = JSONDecoder() - do { - let roundResults = try decoder.decode([Int].self, from: roundResultsData) - return onCallback(.delivered(roundResults: roundResults)) - } catch { - return onCallback(.delivered(roundResults: [Int]())) - } - } - if !delivered, roundResults == nil { - return onCallback(.notDelivered(timedOut: timedOut)) - } - fatalError(""" - BindingsMessageDeliveryCallback received invalid parameters: - - delivered → \(delivered) - - timedOut → \(timedOut) - - roundResults == nil → \(roundResults == nil) - """) - } -} - -#if DEBUG -extension MessageDeliveryWaiter { - public static let failing = MessageDeliveryWaiter { _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/MessageListener.swift b/Sources/ElixxirDAppsSDK/MessageListener.swift deleted file mode 100644 index dc2bfd1ce9a7c8b1ec55cf29ee457a0c450398a4..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/MessageListener.swift +++ /dev/null @@ -1,74 +0,0 @@ -import Bindings - -public struct MessageListener { - public var listen: (Int, String, @escaping (Message) -> Void) -> Void - - public func callAsFunction( - messageType: Int, - listenerName: String = "MessageListener", - callback: @escaping (Message) -> Void - ) { - listen(messageType, listenerName, callback) - } -} - -extension MessageListener { - public static func live( - bindingsConnection: BindingsConnection - ) -> MessageListener { - MessageListener.live( - register: bindingsConnection.registerListener(_:newListener:) - ) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> MessageListener { - MessageListener.live( - register: bindingsAuthenticatedConnection.registerListener(_:newListener:) - ) - } - - private static func live( - register: @escaping (Int, BindingsListenerProtocol) -> Void - ) -> MessageListener { - MessageListener { messageType, listenerName, callback in - register(messageType, Listener(listenerName: listenerName, onHear: callback)) - } - } -} - -private class Listener: NSObject, BindingsListenerProtocol { - init(listenerName: String, onHear: @escaping (Message) -> Void) { - self.listenerName = listenerName - self.onHear = onHear - super.init() - } - - let listenerName: String - let onHear: (Message) -> Void - let decoder = JSONDecoder() - - func hear(_ item: Data?) { - guard let item = item else { - fatalError("BindingsListenerProtocol.hear received `nil`") - } - do { - onHear(try decoder.decode(Message.self, from: item)) - } catch { - fatalError("Message decoding failed with error: \(error)") - } - } - - func name() -> String { - listenerName - } -} - -#if DEBUG -extension MessageListener { - public static let failing = MessageListener { _, _, _ in - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/MessageSender.swift b/Sources/ElixxirDAppsSDK/MessageSender.swift deleted file mode 100644 index 4e493b132666a40997a30f63e52dd58f7b3f63af..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/MessageSender.swift +++ /dev/null @@ -1,46 +0,0 @@ -import Bindings - -public struct MessageSender { - public var send: (Int, Data) throws -> MessageSendReport - - public func callAsFunction( - messageType: Int, - payload: Data - ) throws -> MessageSendReport { - try send(messageType, payload) - } -} - -extension MessageSender { - public static func live( - bindingsConnection: BindingsConnection - ) -> MessageSender { - MessageSender.live(sendE2E: bindingsConnection.sendE2E(_:payload:)) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> MessageSender { - MessageSender.live(sendE2E: bindingsAuthenticatedConnection.sendE2E(_:payload:)) - } - - private static func live( - sendE2E: @escaping (Int, Data) throws -> Data - ) -> MessageSender { - MessageSender { messageType, payload in - let reportData = try sendE2E(messageType, payload) - let decoder = JSONDecoder() - let report = try decoder.decode(MessageSendReport.self, from: reportData) - return report - } - } -} - -#if DEBUG -extension MessageSender { - public static let failing = MessageSender { _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/Models/BackupReport.swift b/Sources/ElixxirDAppsSDK/Models/BackupReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..33b5b2e24b8210dfa634f7e72149a9e2026fa7c1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/BackupReport.swift @@ -0,0 +1,43 @@ +import Foundation + +public struct BackupReport: Equatable { + public init( + ids: [Data], + params: Data + ) { + self.ids = ids + self.params = params + } + + public var ids: [Data] + public var params: Data +} + +extension BackupReport: Codable { + enum CodingKeys: String, CodingKey { + case ids = "BackupIdListJson" + case params = "BackupParams" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let idsData = try container.decode(Data.self, forKey: .ids) + ids = try JSONDecoder().decode([Data].self, from: idsData) + params = try container.decode(Data.self, forKey: .params) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + let idsData = try JSONEncoder().encode(ids) + try container.encode(idsData, forKey: .ids) + try container.encode(params, forKey: .params) + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/BroadcastMessage.swift b/Sources/ElixxirDAppsSDK/Models/BroadcastMessage.swift new file mode 100644 index 0000000000000000000000000000000000000000..19f311835766b1c95e3225b956d84b34c71cec1f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/BroadcastMessage.swift @@ -0,0 +1,33 @@ +import Foundation + +public struct BroadcastMessage: Equatable { + public init( + roundId: Int, + ephId: [Int], + payload: Data + ) { + self.roundId = roundId + self.ephId = ephId + self.payload = payload + } + + public var roundId: Int + public var ephId: [Int] + public var payload: Data +} + +extension BroadcastMessage: Codable { + enum CodingKeys: String, CodingKey { + case roundId = "RoundID" + case ephId = "EphID" + case payload = "Payload" + } + + 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/BroadcastReport.swift b/Sources/ElixxirDAppsSDK/Models/BroadcastReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..3114a12b733bd4f44829e7d55f8ed4534b2155cc --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/BroadcastReport.swift @@ -0,0 +1,29 @@ +import Foundation + +public struct BroadcastReport: Equatable { + public init( + roundId: Int, + ephId: [Int] + ) { + self.roundId = roundId + self.ephId = ephId + } + + public var roundId: Int + public var ephId: [Int] +} + +extension BroadcastReport: Codable { + enum CodingKeys: String, CodingKey { + case roundId = "RoundID" + case ephId = "EphID" + } + + 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/ChannelDef.swift b/Sources/ElixxirDAppsSDK/Models/ChannelDef.swift new file mode 100644 index 0000000000000000000000000000000000000000..3a5a501a512285c37c1692961c5c01a1b784a404 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/ChannelDef.swift @@ -0,0 +1,37 @@ +import Foundation + +public struct ChannelDef: Equatable { + public init( + name: String, + description: String, + salt: Data, + pubKey: Data + ) { + self.name = name + self.description = description + self.salt = salt + self.pubKey = pubKey + } + + public var name: String + public var description: String + public var salt: Data + public var pubKey: Data +} + +extension ChannelDef: Codable { + enum CodingKeys: String, CodingKey { + case name = "Name" + case description = "Description" + case salt = "Salt" + case pubKey = "PubKey" + } + + 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/ClientError.swift b/Sources/ElixxirDAppsSDK/Models/ClientError.swift similarity index 100% rename from Sources/ElixxirDAppsSDK/ClientError.swift rename to Sources/ElixxirDAppsSDK/Models/ClientError.swift diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/Models/E2ESendReport.swift similarity index 61% rename from Sources/ElixxirDAppsSDK/MessageSendReport.swift rename to Sources/ElixxirDAppsSDK/Models/E2ESendReport.swift index 60af863f971a1664b01e7f7849e7de6bb36c6a4a..87ab2e49371b96a3e96fa03d2bb9ee41860104a1 100644 --- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift +++ b/Sources/ElixxirDAppsSDK/Models/E2ESendReport.swift @@ -1,6 +1,6 @@ import Foundation -public struct MessageSendReport: Equatable { +public struct E2ESendReport: Equatable { public init( roundList: [Int]?, messageId: Data?, @@ -16,10 +16,18 @@ public struct MessageSendReport: Equatable { public var timestamp: Int? } -extension MessageSendReport: Codable { +extension E2ESendReport: Codable { enum CodingKeys: String, CodingKey { case roundList = "Rounds" case messageId = "MessageID" case timestamp = "Timestamp" } + + 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/Environment.swift b/Sources/ElixxirDAppsSDK/Models/Environment.swift similarity index 100% rename from Sources/ElixxirDAppsSDK/Environment.swift rename to Sources/ElixxirDAppsSDK/Models/Environment.swift diff --git a/Sources/ElixxirDAppsSDK/Models/EventReport.swift b/Sources/ElixxirDAppsSDK/Models/EventReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..e437480342d43771153069816821bcc32d1dfe27 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/EventReport.swift @@ -0,0 +1,37 @@ +import Foundation + +public struct EventReport: Equatable { + public init( + priority: Int, + category: String, + eventType: String, + details: String + ) { + self.priority = priority + self.category = category + self.eventType = eventType + self.details = details + } + + public var priority: Int + public var category: String + public var eventType: String + public var details: String +} + +extension EventReport: Codable { + enum CodingKeys: String, CodingKey { + case priority = "Priority" + case category = "Category" + case eventType = "EventType" + case details = "Details" + } + + 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/Fact.swift b/Sources/ElixxirDAppsSDK/Models/Fact.swift new file mode 100644 index 0000000000000000000000000000000000000000..456ad36c4c8d2285ffc8e2d8c06d2590740ae697 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/Fact.swift @@ -0,0 +1,39 @@ +import Foundation + +public struct Fact: Equatable { + public init( + fact: String, + type: Int + ) { + self.fact = fact + self.type = type + } + + public var fact: String + public var type: Int +} + +extension Fact: Codable { + enum CodingKeys: String, CodingKey { + case fact = "Fact" + case type = "Type" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} + +extension Array where Element == Fact { + 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/FilePartStatus.swift b/Sources/ElixxirDAppsSDK/Models/FilePartStatus.swift new file mode 100644 index 0000000000000000000000000000000000000000..e2f5e4dc0635098fc6f4f765f65e4f6f213f5018 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/FilePartStatus.swift @@ -0,0 +1,19 @@ +public enum FilePartStatus: Equatable { + case partDoesNotExist + case unsent + case arrived + case received + case unknown(code: Int) +} + +extension FilePartStatus { + public init(rawValue: Int) { + switch rawValue { + case let value where value < 0: self = .partDoesNotExist + case 0: self = .unsent + case 1: self = .arrived + case 2: self = .received + case let code: self = .unknown(code: code) + } + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/FileSend.swift b/Sources/ElixxirDAppsSDK/Models/FileSend.swift new file mode 100644 index 0000000000000000000000000000000000000000..1d925e6f4cd728b5fc364d53240c6ca61ceee4fa --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/FileSend.swift @@ -0,0 +1,37 @@ +import Foundation + +public struct FileSend: Equatable { + public init( + name: String, + type: String, + preview: Data, + contents: Data + ) { + self.name = name + self.type = type + self.preview = preview + self.contents = contents + } + + public var name: String + public var type: String + public var preview: Data + public var contents: Data +} + +extension FileSend: Codable { + enum CodingKeys: String, CodingKey { + case name = "Name" + case type = "Type" + case preview = "Preview" + case contents = "Contents" + } + + 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/LogLevel.swift b/Sources/ElixxirDAppsSDK/Models/LogLevel.swift similarity index 100% rename from Sources/ElixxirDAppsSDK/LogLevel.swift rename to Sources/ElixxirDAppsSDK/Models/LogLevel.swift diff --git a/Sources/ElixxirDAppsSDK/Message.swift b/Sources/ElixxirDAppsSDK/Models/Message.swift similarity index 85% rename from Sources/ElixxirDAppsSDK/Message.swift rename to Sources/ElixxirDAppsSDK/Models/Message.swift index b6fc6c4c205d3e7299804dbaac3b9f3f0fdb782a..3abaec655124e10c8089249dac2c7170f416ed3c 100644 --- a/Sources/ElixxirDAppsSDK/Message.swift +++ b/Sources/ElixxirDAppsSDK/Models/Message.swift @@ -46,4 +46,12 @@ extension Message: Codable { case encrypted = "Encrypted" case roundId = "RoundId" } + + 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/NetworkFollowerStatus.swift b/Sources/ElixxirDAppsSDK/Models/NetworkFollowerStatus.swift similarity index 87% rename from Sources/ElixxirDAppsSDK/NetworkFollowerStatus.swift rename to Sources/ElixxirDAppsSDK/Models/NetworkFollowerStatus.swift index 8630aafe29e7f7f3703abb701bb5df1f4c3fc2b0..ab6996ceb184ffb98cd74051d79ab461168b3fb5 100644 --- a/Sources/ElixxirDAppsSDK/NetworkFollowerStatus.swift +++ b/Sources/ElixxirDAppsSDK/Models/NetworkFollowerStatus.swift @@ -1,6 +1,5 @@ public enum NetworkFollowerStatus: Equatable { case stopped - case starting case running case stopping case unknown(code: Int) @@ -10,7 +9,6 @@ extension NetworkFollowerStatus { public init(rawValue: Int) { switch rawValue { case 0: self = .stopped - case 1_000: self = .starting case 2_000: self = .running case 3_000: self = .stopping case let code: self = .unknown(code: code) @@ -20,7 +18,6 @@ extension NetworkFollowerStatus { public var rawValue: Int { switch self { case .stopped: return 0 - case .starting: return 1_000 case .running: return 2_000 case .stopping: return 3_000 case .unknown(let code): return code diff --git a/Sources/ElixxirDAppsSDK/Models/Progress.swift b/Sources/ElixxirDAppsSDK/Models/Progress.swift new file mode 100644 index 0000000000000000000000000000000000000000..ba2e199db7fb504d790ef6ef514c1e25f9c794eb --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/Progress.swift @@ -0,0 +1,37 @@ +import Foundation + +public struct Progress: Equatable { + public init( + completed: Bool, + transmitted: Int, + total: Int, + error: String? + ) { + self.completed = completed + self.transmitted = transmitted + self.total = total + self.error = error + } + + public var completed: Bool + public var transmitted: Int + public var total: Int + public var error: String? +} + +extension Progress: Codable { + enum CodingKeys: String, CodingKey { + case completed = "Completed" + case transmitted = "Transmitted" + case total = "Total" + case error = "Err" + } + + 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/ReceivedFile.swift b/Sources/ElixxirDAppsSDK/Models/ReceivedFile.swift new file mode 100644 index 0000000000000000000000000000000000000000..d5c12370a6a42f2d416007b85c119fe627faffca --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/ReceivedFile.swift @@ -0,0 +1,45 @@ +import Foundation + +public struct ReceivedFile: Equatable { + public init( + transferId: Data, + senderId: Data, + preview: Data, + name: String, + type: String, + size: Int + ) { + self.transferId = transferId + self.senderId = senderId + self.preview = preview + self.name = name + self.type = type + self.size = size + } + + public var transferId: Data + public var senderId: Data + public var preview: Data + public var name: String + public var type: String + public var size: Int +} + +extension ReceivedFile: Codable { + enum CodingKeys: String, CodingKey { + case transferId = "TransferID" + case senderId = "SenderID" + case preview = "Preview" + case name = "Name" + case type = "Type" + case size = "Size" + } + + 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/Identity.swift b/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift similarity index 64% rename from Sources/ElixxirDAppsSDK/Identity.swift rename to Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift index f192f6af836c7e7ffc85122e4fc5e49f7a042430..312ec2c3956be5b36ad238bb0eeea8cf862d654d 100644 --- a/Sources/ElixxirDAppsSDK/Identity.swift +++ b/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift @@ -1,6 +1,6 @@ import Foundation -public struct Identity: Equatable { +public struct ReceptionIdentity: Equatable { public init( id: Data, rsaPrivatePem: Data, @@ -19,11 +19,19 @@ public struct Identity: Equatable { public var dhKeyPrivate: Data } -extension Identity: Codable { +extension ReceptionIdentity: Codable { enum CodingKeys: String, CodingKey { case id = "ID" case rsaPrivatePem = "RSAPrivatePem" case salt = "Salt" case dhKeyPrivate = "DHKeyPrivate" } + + 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/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift similarity index 79% rename from Sources/ElixxirDAppsSDK/RestlikeMessage.swift rename to Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift index 884afde1848f98dacab224047a0333b1788ea4d5..4c33ec5ad026d9461b8bccf8d0c8f0a59827004f 100644 --- a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift +++ b/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift @@ -34,4 +34,12 @@ extension RestlikeMessage: Codable { case uri = "URI" case error = "Error" } + + 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/SingleUseCallbackReport.swift b/Sources/ElixxirDAppsSDK/Models/SingleUseCallbackReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..a4acd5536503612e3260dc89e81088302e03d3da --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/SingleUseCallbackReport.swift @@ -0,0 +1,59 @@ +import Foundation + +public struct SingleUseCallbackReport: Equatable { + public init( + rounds: [Int], + payload: Data, + partner: Data, + ephId: EphId + ) { + self.rounds = rounds + self.payload = payload + self.partner = partner + self.ephId = ephId + } + + public var rounds: [Int] + public var payload: Data + public var partner: Data + public var ephId: EphId +} + +extension SingleUseCallbackReport { + public struct EphId: Equatable { + public init( + ephId: [Int], + source: Data + ) { + self.ephId = ephId + self.source = source + } + + public var ephId: [Int] + public var source: Data + } +} + +extension SingleUseCallbackReport: Codable { + enum CodingKeys: String, CodingKey { + case rounds = "Rounds" + case payload = "Payload" + case partner = "Partner" + case ephId = "EphID" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} + +extension SingleUseCallbackReport.EphId: Codable { + enum CodingKeys: String, CodingKey { + case ephId = "EphId" + case source = "Source" + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/SingleUseResponseReport.swift b/Sources/ElixxirDAppsSDK/Models/SingleUseResponseReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..0aea471e2c7421c3b622f96065932dac221b1750 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/SingleUseResponseReport.swift @@ -0,0 +1,59 @@ +import Foundation + +public struct SingleUseResponseReport: Equatable { + public init( + rounds: [Int], + payload: Data, + receptionId: ReceptionId, + error: String? + ) { + self.rounds = rounds + self.payload = payload + self.receptionId = receptionId + self.error = error + } + + public var rounds: [Int] + public var payload: Data + public var receptionId: ReceptionId + public var error: String? +} + +extension SingleUseResponseReport { + public struct ReceptionId: Equatable { + public init( + ephId: [Int], + source: Data + ) { + self.ephId = ephId + self.source = source + } + + public var ephId: [Int] + public var source: Data + } +} + +extension SingleUseResponseReport: Codable { + enum CodingKeys: String, CodingKey { + case rounds = "Rounds" + case payload = "Payload" + case receptionId = "ReceptionID" + case error = "Err" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} + +extension SingleUseResponseReport.ReceptionId: Codable { + enum CodingKeys: String, CodingKey { + case ephId = "EphId" + case source = "Source" + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift b/Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift new file mode 100644 index 0000000000000000000000000000000000000000..f86f26ceaf84e3c1782a840d5f619ec69623cdf1 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift @@ -0,0 +1,51 @@ +import Foundation + +public struct SingleUseSendReport: Equatable { + public init( + rounds: [Int], + ephId: EphId + ) { + self.rounds = rounds + self.ephId = ephId + } + + public var rounds: [Int] + public var ephId: EphId +} + +extension SingleUseSendReport { + public struct EphId: Equatable { + public init( + ephId: [Int], + source: Data + ) { + self.ephId = ephId + self.source = source + } + + public var ephId: [Int] + public var source: Data + } +} + +extension SingleUseSendReport: Codable { + enum CodingKeys: String, CodingKey { + case rounds = "Rounds" + case ephId = "EphID" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} + +extension SingleUseSendReport.EphId: Codable { + enum CodingKeys: String, CodingKey { + case ephId = "EphId" + case source = "Source" + } +} diff --git a/Sources/ElixxirDAppsSDK/Models/UserDiscoveryConfig.swift b/Sources/ElixxirDAppsSDK/Models/UserDiscoveryConfig.swift new file mode 100644 index 0000000000000000000000000000000000000000..27ea98cf2c973002b8e9d71f9ffceeba92b7cf17 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Models/UserDiscoveryConfig.swift @@ -0,0 +1,13 @@ +import Foundation + +public struct UserDiscoveryConfig: Equatable { + public init(cert: Data, address: Data, contact: Data) { + self.cert = cert + self.address = address + self.contact = contact + } + + public var cert: Data + public var address: Data + public var contact: Data +} diff --git a/Sources/ElixxirDAppsSDK/NetworkFollower.swift b/Sources/ElixxirDAppsSDK/NetworkFollower.swift deleted file mode 100644 index d4afa8c71ff37ed2b9cd26d7a90c4b68fa5b374b..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkFollower.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Bindings - -public struct NetworkFollower { - public var status: NetworkFollowerStatusProvider - public var start: NetworkFollowerStarter - public var stop: NetworkFollowerStopper -} - -extension NetworkFollower { - public static func live(bindingsClient: BindingsCmix) -> NetworkFollower { - NetworkFollower( - status: .live(bindingsClient: bindingsClient), - start: .live(bindingsClient: bindingsClient), - stop: .live(bindingsClient: bindingsClient) - ) - } -} - -#if DEBUG -extension NetworkFollower { - public static let failing = NetworkFollower( - status: .failing, - start: .failing, - stop: .failing - ) -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkFollowerStarter.swift b/Sources/ElixxirDAppsSDK/NetworkFollowerStarter.swift deleted file mode 100644 index 3bc7a46080c9e43c630e25dd0052f787c50e9cc2..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkFollowerStarter.swift +++ /dev/null @@ -1,26 +0,0 @@ -import Bindings - -public struct NetworkFollowerStarter { - public var start: (_ timeoutMS: Int) throws -> Void - - public func callAsFunction(timeoutMS: Int) throws { - try start(timeoutMS) - } -} - -extension NetworkFollowerStarter { - public static func live(bindingsClient: BindingsCmix) -> NetworkFollowerStarter { - NetworkFollowerStarter { timeoutMS in - try bindingsClient.startNetworkFollower(timeoutMS) - } - } -} - -#if DEBUG -extension NetworkFollowerStarter { - public static let failing = NetworkFollowerStarter { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkFollowerStatusProvider.swift b/Sources/ElixxirDAppsSDK/NetworkFollowerStatusProvider.swift deleted file mode 100644 index 04ca4d2a55195aa031c8f5aff95763f288fb4912..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkFollowerStatusProvider.swift +++ /dev/null @@ -1,26 +0,0 @@ -import Bindings - -public struct NetworkFollowerStatusProvider { - public var status: () -> NetworkFollowerStatus - - public func callAsFunction() -> NetworkFollowerStatus { - status() - } -} - -extension NetworkFollowerStatusProvider { - public static func live(bindingsClient: BindingsCmix) -> NetworkFollowerStatusProvider { - NetworkFollowerStatusProvider { - let rawValue = bindingsClient.networkFollowerStatus() - return NetworkFollowerStatus(rawValue: rawValue) - } - } -} - -#if DEBUG -extension NetworkFollowerStatusProvider { - public static let failing = NetworkFollowerStatusProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkFollowerStopper.swift b/Sources/ElixxirDAppsSDK/NetworkFollowerStopper.swift deleted file mode 100644 index 1b8ed6ab582430d231fdf01900941aba00e0d42d..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkFollowerStopper.swift +++ /dev/null @@ -1,24 +0,0 @@ -import Bindings - -public struct NetworkFollowerStopper { - public var stop: () throws -> Void - - public func callAsFunction() throws { - try stop() - } -} - -extension NetworkFollowerStopper { - public static func live(bindingsClient: BindingsCmix) -> NetworkFollowerStopper { - NetworkFollowerStopper(stop: bindingsClient.stopNetworkFollower) - } -} - -#if DEBUG -extension NetworkFollowerStopper { - public static let failing = NetworkFollowerStopper { - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkHealthListener.swift b/Sources/ElixxirDAppsSDK/NetworkHealthListener.swift deleted file mode 100644 index 50628c4ae46a3c4614bf1cc257c920d2cd0ad2b8..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkHealthListener.swift +++ /dev/null @@ -1,42 +0,0 @@ -import Bindings - -public struct NetworkHealthListener { - public var listen: (@escaping (Bool) -> Void) -> Cancellable - - public func callAsFunction(callback: @escaping (Bool) -> Void) -> Cancellable { - listen(callback) - } -} - -extension NetworkHealthListener { - public static func live(bindingsClient: BindingsCmix) -> NetworkHealthListener { - NetworkHealthListener { callback in - let listener = Listener(onCallback: callback) - let id = bindingsClient.registerNetworkHealthCB(listener) - return Cancellable { - bindingsClient.unregisterNetworkHealthCB(id) - } - } - } -} - -private final class Listener: NSObject, BindingsNetworkHealthCallbackProtocol { - init(onCallback: @escaping (Bool) -> Void) { - self.onCallback = onCallback - super.init() - } - - let onCallback: (Bool) -> Void - - func callback(_ p0: Bool) { - onCallback(p0) - } -} - -#if DEBUG -extension NetworkHealthListener { - public static let failing = NetworkHealthListener { _ in - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkHealthProvider.swift b/Sources/ElixxirDAppsSDK/NetworkHealthProvider.swift deleted file mode 100644 index 65d8944da93045d390b76c4431e68554daa65625..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkHealthProvider.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Bindings - -public struct NetworkHealthProvider { - public var get: () -> Bool - - public func callAsFunction() -> Bool { - get() - } -} - -extension NetworkHealthProvider { - public static func live(bindingsClient: BindingsCmix) -> NetworkHealthProvider { - NetworkHealthProvider(get: bindingsClient.isNetworkHealthy) - } -} - -#if DEBUG -extension NetworkHealthProvider { - public static let failing = NetworkHealthProvider { - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/NetworkWaiter.swift b/Sources/ElixxirDAppsSDK/NetworkWaiter.swift deleted file mode 100644 index 4782ab90c62cc6fd06c8d42d9b2842c1f790611d..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/NetworkWaiter.swift +++ /dev/null @@ -1,25 +0,0 @@ -import Bindings - -public struct NetworkWaiter { - public var wait: (_ timeoutMS: Int) -> Bool - - public func callAsFunction(timeoutMS: Int) -> Bool { - wait(timeoutMS) - } -} - -extension NetworkWaiter { - public static func live(bindingsClient: BindingsCmix) -> NetworkWaiter { - NetworkWaiter { timeoutMS in - bindingsClient.wait(forNetwork: timeoutMS) - } - } -} - -#if DEBUG -extension NetworkWaiter { - public static let failing = NetworkWaiter { _ in - fatalError("Not implemented") - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift b/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift deleted file mode 100644 index efe42bc5210035e22e0157e5aec4307d811981a2..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift +++ /dev/null @@ -1,48 +0,0 @@ -import Bindings - -public struct RestlikeRequestSender { - public var send: (Int, Int, RestlikeMessage) throws -> RestlikeMessage - - public func callAsFunction( - clientId: Int, - connectionId: Int, - request: RestlikeMessage - ) throws -> RestlikeMessage { - try send(clientId, connectionId, request) - } -} - -extension RestlikeRequestSender { - public static func live(authenticated: Bool) -> RestlikeRequestSender { - RestlikeRequestSender { clientId, connectionId, request in - let encoder = JSONEncoder() - let requestData = try encoder.encode(request) - var error: NSError? - let responseData: Data? - if authenticated { - responseData = BindingsRestlikeRequestAuth(clientId, connectionId, requestData, &error) - } else { - responseData = BindingsRestlikeRequest(clientId, connectionId, requestData, &error) - } - if let error = error { - throw error - } - guard let responseData = responseData else { - let functionName = "BindingsRestlikeRequest\(authenticated ? "Auth" : "")" - fatalError("\(functionName) returned `nil` without providing error") - } - let decoder = JSONDecoder() - let response = try decoder.decode(RestlikeMessage.self, from: responseData) - return response - } - } -} - -#if DEBUG -extension RestlikeRequestSender { - public static let failing = RestlikeRequestSender { _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryConfirmFact.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryConfirmFact.swift new file mode 100644 index 0000000000000000000000000000000000000000..cad19c795866f6ee0086b3901692fa9638f9ef94 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryConfirmFact.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryConfirmFact { + public var run: (String, String) throws -> Void + + public func callAsFunction( + confirmationId: String, + code: String + ) throws { + try run(confirmationId, code) + } +} + +extension UserDiscoveryConfirmFact { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryConfirmFact { + UserDiscoveryConfirmFact(run: bindingsUD.confirmFact(_:code:)) + } +} + +extension UserDiscoveryConfirmFact { + public static let unimplemented = UserDiscoveryConfirmFact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetContact.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetContact.swift new file mode 100644 index 0000000000000000000000000000000000000000..19d7fb76c0a17fdcf6374f00eedad8be2d68ceba --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetContact.swift @@ -0,0 +1,23 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryGetContact { + public var run: () throws -> Data + + public func callAsFunction() throws -> Data { + try run() + } +} + +extension UserDiscoveryGetContact { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryGetContact { + UserDiscoveryGetContact(run: bindingsUD.getContact) + } +} + +extension UserDiscoveryGetContact { + public static let unimplemented = UserDiscoveryGetContact( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetFacts.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetFacts.swift new file mode 100644 index 0000000000000000000000000000000000000000..a6029083f85603c8c7c6590562f75aa5f36b061a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetFacts.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryGetFacts { + public var run: () throws -> [Fact] + + public func callAsFunction() throws -> [Fact] { + try run() + } +} + +extension UserDiscoveryGetFacts { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryGetFacts { + UserDiscoveryGetFacts { + guard let data = bindingsUD.getFacts() else { + fatalError("BindingsUserDiscovery.getFacts returned `nil`") + } + return try [Fact].decode(data) + } + } +} + +extension UserDiscoveryGetFacts { + public static let unimplemented = UserDiscoveryGetFacts( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetId.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetId.swift new file mode 100644 index 0000000000000000000000000000000000000000..77de9ad9d6dcc6d4db4fe936a257b9fd8352e190 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryGetId.swift @@ -0,0 +1,23 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryGetId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension UserDiscoveryGetId { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryGetId { + UserDiscoveryGetId(run: bindingsUD.getID) + } +} + +extension UserDiscoveryGetId { + public static let unimplemented = UserDiscoveryGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryPermanentDeleteAccount.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryPermanentDeleteAccount.swift new file mode 100644 index 0000000000000000000000000000000000000000..3f570e1e1919c2fe6887b232c65a7eb28c9d77ad --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryPermanentDeleteAccount.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryPermanentDeleteAccount { + public var run: (Fact) throws -> Void + + public func callAsFunction(_ fact: Fact) throws { + try run(fact) + } +} + +extension UserDiscoveryPermanentDeleteAccount { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryPermanentDeleteAccount { + UserDiscoveryPermanentDeleteAccount { fact in + try bindingsUD.permanentDeleteAccount(fact.encode()) + } + } +} + +extension UserDiscoveryPermanentDeleteAccount { + public static let unimplemented = UserDiscoveryPermanentDeleteAccount( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryRemoveFact.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryRemoveFact.swift new file mode 100644 index 0000000000000000000000000000000000000000..3996ba446981172e0e24477c92fd032b377eb53a --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoveryRemoveFact.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoveryRemoveFact { + public var run: (Fact) throws -> Void + + public func callAsFunction(_ fact: Fact) throws { + try run(fact) + } +} + +extension UserDiscoveryRemoveFact { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoveryRemoveFact { + UserDiscoveryRemoveFact { fact in + try bindingsUD.removeFact(fact.encode()) + } + } +} + +extension UserDiscoveryRemoveFact { + public static let unimplemented = UserDiscoveryRemoveFact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySendRegisterFact.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySendRegisterFact.swift new file mode 100644 index 0000000000000000000000000000000000000000..78c9a77fd99e1d292bbc1ae2263668ab3bc11f53 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySendRegisterFact.swift @@ -0,0 +1,29 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoverySendRegisterFact { + public var run: (Fact) throws -> String + + public func callAsFunction(_ fact: Fact) throws -> String { + try run(fact) + } +} + +extension UserDiscoverySendRegisterFact { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoverySendRegisterFact { + UserDiscoverySendRegisterFact { fact in + var error: NSError? + let confirmationId = bindingsUD.sendRegisterFact(try fact.encode(), error: &error) + if let error = error { + throw error + } + return confirmationId + } + } +} + +extension UserDiscoverySendRegisterFact { + public static let unimplemented = UserDiscoverySendRegisterFact( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySetAlternative.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySetAlternative.swift new file mode 100644 index 0000000000000000000000000000000000000000..731518eb8868f40d77639e55306e345d8a79be36 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/Functors/UserDiscoverySetAlternative.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UserDiscoverySetAlternative { + public var run: (UserDiscoveryConfig?) throws -> Void + + public func callAsFunction(_ config: UserDiscoveryConfig?) throws { + try run(config) + } +} + +extension UserDiscoverySetAlternative { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscoverySetAlternative { + UserDiscoverySetAlternative { config in + if let config = config { + try bindingsUD.setAlternative( + config.cert, + altAddress: config.address, + contactFile: config.contact + ) + } else { + try bindingsUD.unsetAlternativeUserDiscovery() + } + } + } +} + +extension UserDiscoverySetAlternative { + public static let unimplemented = UserDiscoverySetAlternative( + run: XCTUnimplemented("\(Self.self)") + ) +} + diff --git a/Sources/ElixxirDAppsSDK/UserDiscovery/UserDiscovery.swift b/Sources/ElixxirDAppsSDK/UserDiscovery/UserDiscovery.swift new file mode 100644 index 0000000000000000000000000000000000000000..a0935d810b19e6145274edd6d301901ceb36e31c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/UserDiscovery/UserDiscovery.swift @@ -0,0 +1,40 @@ +import Bindings + +public struct UserDiscovery { + public var setAlternative: UserDiscoverySetAlternative + public var getId: UserDiscoveryGetId + public var getContact: UserDiscoveryGetContact + public var getFacts: UserDiscoveryGetFacts + public var sendRegisterFact: UserDiscoverySendRegisterFact + public var confirmFact: UserDiscoveryConfirmFact + public var removeFact: UserDiscoveryRemoveFact + public var permanentDeleteAccount: UserDiscoveryPermanentDeleteAccount +} + +extension UserDiscovery { + public static func live(_ bindingsUD: BindingsUserDiscovery) -> UserDiscovery { + UserDiscovery( + setAlternative: .live(bindingsUD), + getId: .live(bindingsUD), + getContact: .live(bindingsUD), + getFacts: .live(bindingsUD), + sendRegisterFact: .live(bindingsUD), + confirmFact: .live(bindingsUD), + removeFact: .live(bindingsUD), + permanentDeleteAccount: .live(bindingsUD) + ) + } +} + +extension UserDiscovery { + public static let unimplemented = UserDiscovery( + setAlternative: .unimplemented, + getId: .unimplemented, + getContact: .unimplemented, + getFacts: .unimplemented, + sendRegisterFact: .unimplemented, + confirmFact: .unimplemented, + removeFact: .unimplemented, + permanentDeleteAccount: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/VersionProvider.swift b/Sources/ElixxirDAppsSDK/VersionProvider.swift deleted file mode 100644 index bec9b293ca43a57f42feb3a3f6a8703c239b613f..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/VersionProvider.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Bindings - -public struct VersionProvider { - public var get: () -> String - - public func callAsFunction() -> String { - get() - } -} - -extension VersionProvider { - public static let live = VersionProvider(get: BindingsGetVersion) -} - -#if DEBUG -extension VersionProvider { - public static let failing = VersionProvider { fatalError("Not implemented") } -} -#endif diff --git a/Tests/ElixxirDAppsSDKTests/FactTests.swift b/Tests/ElixxirDAppsSDKTests/FactTests.swift deleted file mode 100644 index 21820a78c9a744322a8d81823f81d486ace91be6..0000000000000000000000000000000000000000 --- a/Tests/ElixxirDAppsSDKTests/FactTests.swift +++ /dev/null @@ -1,30 +0,0 @@ -import CustomDump -import XCTest -@testable import ElixxirDAppsSDK - -final class FactTests: XCTestCase { - func testCoding() throws { - let jsonString = """ - { - "Fact": "Zezima", - "Type": 0 - } - """ - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let fact = try decoder.decode(Fact.self, from: jsonData) - - XCTAssertNoDifference(fact, Fact( - fact: "Zezima", - type: 0 - )) - - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedFact = try encoder.encode(fact) - let decodedFact = try decoder.decode(Fact.self, from: encodedFact) - - XCTAssertNoDifference(decodedFact, fact) - } -} diff --git a/Tests/ElixxirDAppsSDKTests/IdentityTests.swift b/Tests/ElixxirDAppsSDKTests/IdentityTests.swift deleted file mode 100644 index b517634542976037ab5793b47d0314b0cc5f15eb..0000000000000000000000000000000000000000 --- a/Tests/ElixxirDAppsSDKTests/IdentityTests.swift +++ /dev/null @@ -1,34 +0,0 @@ -import CustomDump -import XCTest -@testable import ElixxirDAppsSDK - -final class IdentityTests: XCTestCase { - func testCoding() throws { - let jsonString = """ - { - "ID": "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RSAPrivatePem": "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", - "Salt": "4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=", - "DHKeyPrivate": "eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" - } - """ - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let identity = try decoder.decode(Identity.self, from: jsonData) - - XCTAssertNoDifference(identity, Identity( - id: Data(base64Encoded: "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD")!, - rsaPrivatePem: Data(base64Encoded: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==")!, - salt: Data(base64Encoded: "4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=")!, - dhKeyPrivate: Data(base64Encoded: "eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==")! - )) - - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedIdentity = try encoder.encode(identity) - let decodedIdentity = try decoder.decode(Identity.self, from: encodedIdentity) - - XCTAssertNoDifference(decodedIdentity, identity) - } -} diff --git a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift deleted file mode 100644 index 52f3364049620ead64fb1c146677c02a66ed8dcb..0000000000000000000000000000000000000000 --- a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift +++ /dev/null @@ -1,46 +0,0 @@ -import CustomDump -import XCTest -@testable import ElixxirDAppsSDK - -final class MessageSendReportTests: XCTestCase { - func testCoding() throws { - let jsonString = """ - { - "Rounds": [1,5,9], - "MessageID": "51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=", - "Timestamp": 1653582683183384000 - } - """ - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let report = try decoder.decode(MessageSendReport.self, from: jsonData) - - XCTAssertNoDifference(report, MessageSendReport( - roundList: [1, 5, 9], - messageId: Data(base64Encoded: "51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=")!, - timestamp: 1_653_582_683_183_384_000 - )) - - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedReport = try encoder.encode(report) - let decodedReport = try decoder.decode(MessageSendReport.self, from: encodedReport) - - XCTAssertNoDifference(decodedReport, report) - } - - func testDecodeEmpty() throws { - let jsonString = "{}" - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let report = try decoder.decode(MessageSendReport.self, from: jsonData) - - XCTAssertNoDifference(report, MessageSendReport( - roundList: nil, - messageId: nil, - timestamp: nil - )) - } -} diff --git a/Tests/ElixxirDAppsSDKTests/MessageTests.swift b/Tests/ElixxirDAppsSDKTests/MessageTests.swift deleted file mode 100644 index 148314598a7a04b8600ea4322f83842e69d24d21..0000000000000000000000000000000000000000 --- a/Tests/ElixxirDAppsSDKTests/MessageTests.swift +++ /dev/null @@ -1,44 +0,0 @@ -import CustomDump -import XCTest -@testable import ElixxirDAppsSDK - -final class MessageTests: XCTestCase { - func testCoding() throws { - let jsonString = """ - { - "MessageType": 1, - "ID": "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=", - "Payload": "7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==", - "Sender": "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "RecipientID": "amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", - "EphemeralID": 17, - "Timestamp": 1653580439357351000, - "Encrypted": false, - "RoundId": 19 - } - """ - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let message = try decoder.decode(Message.self, from: jsonData) - - XCTAssertNoDifference(message, Message( - messageType: 1, - id: Data(base64Encoded: "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=")!, - payload: Data(base64Encoded: "7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==")!, - sender: Data(base64Encoded: "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD")!, - recipientId: Data(base64Encoded: "amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD")!, - ephemeralId: 17, - timestamp: 1_653_580_439_357_351_000, - encrypted: false, - roundId: 19 - )) - - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedMessage = try encoder.encode(message) - let decodedMessage = try decoder.decode(Message.self, from: encodedMessage) - - XCTAssertNoDifference(decodedMessage, message) - } -} diff --git a/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..6eea07267c36108b22b9efa4cc6ec51b4acbf83c --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift @@ -0,0 +1,33 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class BackupReportTests: XCTestCase { + func testCoding() throws { + let ids: [Data] = [ + "id1".data(using: .utf8)!, + "id2".data(using: .utf8)!, + "id3".data(using: .utf8)!, + ] + let idsB64 = try JSONEncoder().encode(ids).base64EncodedString() + let paramsB64 = "cGFyYW1z" + let jsonString = """ + { + "BackupIdListJson": "\(idsB64)", + "BackupParams": "\(paramsB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try BackupReport.decode(jsonData) + + XCTAssertNoDifference(model, BackupReport( + ids: ids, + params: Data(base64Encoded: paramsB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try BackupReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/BroadcastMessageTests.swift b/Tests/ElixxirDAppsSDKTests/Models/BroadcastMessageTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..3b6fa7ab7841365647fed1755575612cadcc25b4 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/BroadcastMessageTests.swift @@ -0,0 +1,31 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class BroadcastMessageTests: XCTestCase { + func testCoding() throws { + let roundId: Int = 42 + let ephId: [Int] = [0, 0, 0, 0, 0, 0, 24, 61] + let payloadB64 = "SGVsbG8sIGJyb2FkY2FzdCBmcmllbmRzIQ==" + let jsonString = """ + { + "RoundID": \(roundId), + "EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))], + "Payload": "\(payloadB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try BroadcastMessage.decode(jsonData) + + XCTAssertNoDifference(model, BroadcastMessage( + roundId: roundId, + ephId: ephId, + payload: Data(base64Encoded: payloadB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try BroadcastMessage.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/BroadcastReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/BroadcastReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..c354553ca641f0d6f1ebcc5584533ec247ddb9dd --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/BroadcastReportTests.swift @@ -0,0 +1,28 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class BroadcastReportTests: XCTestCase { + func testCoding() throws { + let roundId: Int = 42 + let ephId: [Int] = [0, 0, 0, 0, 0, 0, 24, 61] + let jsonString = """ + { + "RoundID": \(roundId), + "EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))] + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try BroadcastReport.decode(jsonData) + + XCTAssertNoDifference(model, BroadcastReport( + roundId: roundId, + ephId: ephId + )) + + let encodedModel = try model.encode() + let decodedModel = try BroadcastReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift b/Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..0c3bdc9066b9cebdbd17911a165f35eb7dfaaf1b --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift @@ -0,0 +1,34 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class ChannelDefTests: XCTestCase { + func testCoding() throws { + let name = "My broadcast channel" + let description = "A broadcast channel for me to test things" + let saltB64 = "gpUqW7N22sffMXsvPLE7BA==" + let pubKeyB64 = "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0=" + let jsonString = """ + { + "Name": "\(name)", + "Description": "\(description)", + "Salt": "\(saltB64)", + "PubKey": "\(pubKeyB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try ChannelDef.decode(jsonData) + + XCTAssertNoDifference(model, ChannelDef( + name: name, + description: description, + salt: Data(base64Encoded: saltB64)!, + pubKey: Data(base64Encoded: pubKeyB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try ChannelDef.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/E2ESendReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/E2ESendReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..db3bdd3bac97e7e5ff2e1830abe19fd4f6ec230a --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/E2ESendReportTests.swift @@ -0,0 +1,43 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class E2ESendReportTests: XCTestCase { + func testCoding() throws { + let rounds = [1, 5, 9] + let messageIdB64 = "51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=" + let timestamp: Int = 1_653_582_683_183_384_000 + let jsonString = """ + { + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "MessageID": "\(messageIdB64)", + "Timestamp": \(timestamp) + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try E2ESendReport.decode(jsonData) + + XCTAssertNoDifference(model, E2ESendReport( + roundList: rounds, + messageId: Data(base64Encoded: messageIdB64)!, + timestamp: timestamp + )) + + let encodedModel = try model.encode() + let decodedModel = try E2ESendReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } + + func testDecodeEmpty() throws { + let jsonString = "{}" + let jsonData = jsonString.data(using: .utf8)! + let model = try E2ESendReport.decode(jsonData) + + XCTAssertNoDifference(model, E2ESendReport( + roundList: nil, + messageId: nil, + timestamp: nil + )) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/EventReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/EventReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..22307d4e431ff798cfa9e25124685a759fc74c45 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/EventReportTests.swift @@ -0,0 +1,34 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class EventReportTests: XCTestCase { + func testCoding() throws { + let priority: Int = 1 + let category = "Test Events" + let eventType = "Ping" + let details = "This is an example of an event report" + let jsonString = """ + { + "Priority": \(priority), + "Category": "\(category)", + "EventType": "\(eventType)", + "Details": "\(details)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try EventReport.decode(jsonData) + + XCTAssertNoDifference(model, EventReport( + priority: priority, + category: category, + eventType: eventType, + details: details + )) + + let encodedModel = try model.encode() + let decodedModel = try EventReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/FactTests.swift b/Tests/ElixxirDAppsSDKTests/Models/FactTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..581cca3b7975bba89078c1deabb415f01a39ed0b --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/FactTests.swift @@ -0,0 +1,28 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class FactTests: XCTestCase { + func testCoding() throws { + let factValue = "Zezima" + let factType: Int = 0 + let jsonString = """ + { + "Fact": "\(factValue)", + "Type": \(factType) + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try Fact.decode(jsonData) + + XCTAssertNoDifference(model, Fact( + fact: factValue, + type: factType + )) + + let encodedModel = try model.encode() + let decodedModel = try Fact.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/FileSendTests.swift b/Tests/ElixxirDAppsSDKTests/Models/FileSendTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..d0fbf2752cf82f411964343b5ae26f4dc96c9e60 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/FileSendTests.swift @@ -0,0 +1,34 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class FileSendTests: XCTestCase { + func testCoding() throws { + let name = "testfile.txt" + let type = "text file" + let previewB64 = "aXQncyBtZSBhIHByZXZpZXc=" + let contentsB64 = "VGhpcyBpcyB0aGUgZnVsbCBjb250ZW50cyBvZiB0aGUgZmlsZSBpbiBieXRlcw==" + let jsonString = """ + { + "Name": "\(name)", + "Type": "\(type)", + "Preview": "\(previewB64)", + "Contents": "\(contentsB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try FileSend.decode(jsonData) + + XCTAssertNoDifference(model, FileSend( + name: name, + type: type, + preview: Data(base64Encoded: previewB64)!, + contents: Data(base64Encoded: contentsB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try FileSend.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/MessageTests.swift b/Tests/ElixxirDAppsSDKTests/Models/MessageTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..ba9f63df2857d76d5b3004c2151d518e955e1d82 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/MessageTests.swift @@ -0,0 +1,49 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class MessageTests: XCTestCase { + func testCoding() throws { + let type: Int = 1 + let idB64 = "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w=" + let payloadB64 = "7TzZKgNphT5UooNM7mDSwtVcIs8AIu4vMKm4ld6GSR8YX5GrHirixUBAejmsgdroRJyo06TkIVef7UM9FN8YfQ==" + let senderB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let recipientIdB64 = "amFrZXh4MzYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let ephemeralId: Int = 17 + let timestamp: Int = 1_653_580_439_357_351_000 + let encrypted = false + let roundId: Int = 19 + let jsonString = """ + { + "MessageType": \(type), + "ID": "\(idB64)", + "Payload": "\(payloadB64)", + "Sender": "\(senderB64)", + "RecipientID": "\(recipientIdB64)", + "EphemeralID": \(ephemeralId), + "Timestamp": \(timestamp), + "Encrypted": \(encrypted), + "RoundId": \(roundId) + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try Message.decode(jsonData) + + XCTAssertNoDifference(model, Message( + messageType: 1, + id: Data(base64Encoded: idB64)!, + payload: Data(base64Encoded: payloadB64)!, + sender: Data(base64Encoded: senderB64)!, + recipientId: Data(base64Encoded: recipientIdB64)!, + ephemeralId: ephemeralId, + timestamp: timestamp, + encrypted: encrypted, + roundId: roundId + )) + + let encodedModel = try model.encode() + let decodedModel = try Message.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift b/Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..557eac6840f3e356066252bb331d83b54fa1c7fc --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift @@ -0,0 +1,57 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class ProgressTests: XCTestCase { + func testCoding() throws { + let completed = false + let transmitted: Int = 128 + let total: Int = 2048 + let jsonString = """ + { + "Completed": \(completed), + "Transmitted": \(transmitted), + "Total": \(total), + "Err": null + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try Progress.decode(jsonData) + + XCTAssertNoDifference(model, Progress( + completed: completed, + transmitted: transmitted, + total: total, + error: nil + )) + + let encodedModel = try model.encode() + let decodedModel = try Progress.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } + + func testDecodingProgressWithError() throws { + let completed = false + let transmitted: Int = 128 + let total: Int = 2048 + let error = "something went wrong" + let jsonString = """ + { + "Completed": \(completed), + "Transmitted": \(transmitted), + "Total": \(total), + "Err": "\(error)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try Progress.decode(jsonData) + + XCTAssertNoDifference(model, Progress( + completed: completed, + transmitted: transmitted, + total: total, + error: error + )) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/ReceivedFileTests.swift b/Tests/ElixxirDAppsSDKTests/Models/ReceivedFileTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..f04720e525d074f9307e36e54464b6bd5fa62e8a --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/ReceivedFileTests.swift @@ -0,0 +1,40 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class ReceivedFileTests: XCTestCase { + func testCoding() throws { + let transferIdB64 = "B4Z9cwU18beRoGbk5xBjbcd5Ryi9ZUFA2UBvi8FOHWo=" + let senderIdB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let previewB64 = "aXQncyBtZSBhIHByZXZpZXc=" + let name = "testfile.txt" + let type = "text file" + let size: Int = 2048 + let jsonString = """ + { + "TransferID": "\(transferIdB64)", + "SenderID": "\(senderIdB64)", + "Preview": "\(previewB64)", + "Name": "\(name)", + "Type": "\(type)", + "Size": \(size) + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try ReceivedFile.decode(jsonData) + + XCTAssertNoDifference(model, ReceivedFile( + transferId: Data(base64Encoded: transferIdB64)!, + senderId: Data(base64Encoded: senderIdB64)!, + preview: Data(base64Encoded: previewB64)!, + name: name, + type: type, + size: size + )) + + let encodedModel = try model.encode() + let decodedModel = try ReceivedFile.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/ReceptionIdentityTests.swift b/Tests/ElixxirDAppsSDKTests/Models/ReceptionIdentityTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..9e00d0354ab907dca9a5d5857933c9ebd0f7ccbc --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/ReceptionIdentityTests.swift @@ -0,0 +1,34 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class ReceptionIdentityTests: XCTestCase { + func testCoding() throws { + let idB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let rsaPrivatePemB64 = "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBNU15dTdhYjBJOS9UL1BFUUxtd2x3ejZHV3FjMUNYemVIVXhoVEc4bmg1WWRWSXMxCmJ2THpBVjNOMDJxdXN6K2s4TVFEWjBtejMzdkswUmhPczZIY0NUSFdzTEpXRkE5WWpzWWlCRi9qTDd1bmd1ckIKL2tvK1JJSnNrWGFWaEZaazRGdERoRXhTNWY4RnR0Qmk1NmNLZmdJQlVKT3ozZi9qQllTMkxzMlJ6cWV5YXM3SApjV2RaME9TclBTT3BiYlViU1FPbS9LWnlweGZHU21yZ2oxRUZuU1dZZ2xGZTdUOTRPbHF5MG14QTV5clVXbHorCk9sK3hHbXpCNUp4WUFSMU9oMFQrQTk4RWMrTUZHNm43L1MraDdzRDgybGRnVnJmbStFTzRCdmFKeTRESGZGMWgKNnp6QnVnY25NUVFGc0dLeDFYWC9COTVMdUpPVjdyeXlDbzZGbHdJREFRQUJBb0lCQVFDaUh6OGNlcDZvQk9RTAphUzBVRitHeU5VMnlVcVRNTWtTWThoUkh1c09CMmFheXoybHZVb3RLUHBPbjZRSWRWVTJrcE4vY2dtY0lSb2x5CkhBMDRUOHJBWVNaRlVqaVlRajkzKzRFREpJYXd2Z0YyVEs1bFoyb3oxVTdreStncU82V0RMR2Z0Q0wvODVQWEIKa210aXhnUXpRV3g1RWcvemtHdm03eURBalQxeDloNytsRjJwNFlBam5kT2xTS0dmQjFZeTR1RXBQd0kwc1lWdgpKQWc0MEFxbllZUmt4emJPbmQxWGNjdEJFN2Z1VDdrWXhoeSs3WXYrUTJwVy9BYmh6NGlHOEY1MW9GMGZwV0czCmlISDhsVXZFTkp2SUZEVHZ0UEpESlFZalBRN3lUbGlGZUdrMXZUQkcyQkpQNExzVzhpbDZOeUFuRktaY1hOQ24KeHVCendiSlJBb0dCQVBUK0dGTVJGRHRHZVl6NmwzZmg3UjJ0MlhrMysvUmpvR3BDUWREWDhYNERqR1pVd1RGVQpOS2tQTTNjS29ia2RBYlBDb3FpL0tOOVBibk9QVlZ3R3JkSE9vSnNibFVHYmJGamFTUzJQMFZnNUVhTC9rT2dUCmxMMUdoVFpIUWk1VUlMM0p4M1Z3T0ZRQ3RQOU1UQlQ0UEQvcEFLbDg3VTJXN3JTY1dGV1ZGbFNkQW9HQkFPOFUKVmhHWkRpVGFKTWVtSGZIdVYrNmtzaUlsam9aUVVzeGpmTGNMZ2NjV2RmTHBqS0ZWTzJNN3NqcEJEZ0w4NmFnegorVk14ZkQzZ1l0SmNWN01aMVcwNlZ6TlNVTHh3a1dRY1hXUWdDaXc5elpyYlhCUmZRNUVjMFBlblVoWWVwVzF5CkpkTC8rSlpQeDJxSzVrQytiWU5EdmxlNWdpcjlDSGVzTlR5enVyckRBb0dCQUl0cTJnN1RaazhCSVFUUVNrZ24Kb3BkRUtzRW4wZExXcXlBdENtVTlyaWpHL2l2eHlXczMveXZDQWNpWm5VVEp0QUZISHVlbXVTeXplQ2g5QmRkegoyWkRPNUdqQVBxVHlQS3NudFlNZkY4UDczZ1NES1VSWWVFbHFDejdET0c5QzRzcitPK3FoN1B3cCtqUmFoK1ZiCkNuWllNMDlBVDQ3YStJYUJmbWRkaXpLbEFvR0JBSmo1dkRDNmJIQnNISWlhNUNJL1RZaG5YWXUzMkVCYytQM0sKMHF3VThzOCtzZTNpUHBla2Y4RjVHd3RuUU4zc2tsMk1GQWFGYldmeVFZazBpUEVTb0p1cGJzNXA1enNNRkJ1bwpncUZrVnQ0RUZhRDJweTVwM2tQbDJsZjhlZXVwWkZScGE0WmRQdVIrMjZ4eWYrNEJhdlZJeld3NFNPL1V4Q3crCnhqbTNEczRkQW9HQWREL0VOa1BjU004c1BCM3JSWW9MQ2twcUV2U0MzbVZSbjNJd3c1WFAwcDRRVndhRmR1ckMKYUhtSE1EekNrNEUvb0haQVhFdGZ2S2tRaUI4MXVYM2c1aVo4amdYUVhXUHRteTVIcVVhcWJYUTlENkxWc3B0egpKL3R4SWJLMXp5c1o2bk9IY1VoUUwyVVF6SlBBRThZNDdjYzVzTThEN3kwZjJ0QURTQUZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==" + let saltB64 = "4kk02v0NIcGtlobZ/xkxqWz8uH/ams/gjvQm14QT0dI=" + let dhKeyPrivateB64 = "eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" + let jsonString = """ + { + "ID": "\(idB64)", + "RSAPrivatePem": "\(rsaPrivatePemB64)", + "Salt": "\(saltB64)", + "DHKeyPrivate": "\(dhKeyPrivateB64)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try ReceptionIdentity.decode(jsonData) + + XCTAssertNoDifference(model, ReceptionIdentity( + id: Data(base64Encoded: idB64)!, + rsaPrivatePem: Data(base64Encoded: rsaPrivatePemB64)!, + salt: Data(base64Encoded: saltB64)!, + dhKeyPrivate: Data(base64Encoded: dhKeyPrivateB64)! + )) + + let encodedModel = try model.encode() + let decodedModel = try ReceptionIdentity.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/RestlikeMessageTests.swift b/Tests/ElixxirDAppsSDKTests/Models/RestlikeMessageTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..7fca8d7267ac87d8936cb0dbc4a5826cb5a5f076 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/RestlikeMessageTests.swift @@ -0,0 +1,40 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class RestlikeMessageTests: XCTestCase { + func testCoding() throws { + let version: Int = 1 + let headersB64 = "Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==" + let contentB64 = "VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=" + let method: Int = 2 + let uri = "xx://CmixRestlike/rest" + let error = "" + let jsonString = """ + { + "Version": \(version), + "Headers": "\(headersB64)", + "Content": "\(contentB64)", + "Method": \(method), + "URI": "\(uri)", + "Error": "\(error)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try RestlikeMessage.decode(jsonData) + + XCTAssertNoDifference(model, RestlikeMessage( + version: version, + headers: Data(base64Encoded: headersB64)!, + content: Data(base64Encoded: contentB64)!, + method: method, + uri: uri, + error: error + )) + + let encodedModel = try model.encode() + let decodedModel = try RestlikeMessage.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/SingleUseCallbackReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/SingleUseCallbackReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..0f478cb70b764e9ec733b0f4fd29cb114c540a3b --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/SingleUseCallbackReportTests.swift @@ -0,0 +1,41 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class SingleUseCallbackReportTests: XCTestCase { + func testCoding() throws { + let rounds: [Int] = [1, 5, 9] + let payloadB64 = "rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==" + let partnerB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let ephId: [Int] = [0, 0, 0, 0, 0, 0, 3, 89] + let ephIdSourceB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let jsonString = """ + { + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "Payload": "\(payloadB64)", + "Partner": "\(partnerB64)", + "EphID": { + "EphId": [\(ephId.map { "\($0)" }.joined(separator: ", "))], + "Source": "\(ephIdSourceB64)" + } + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try SingleUseCallbackReport.decode(jsonData) + + XCTAssertNoDifference(model, SingleUseCallbackReport( + rounds: rounds, + payload: Data(base64Encoded: payloadB64)!, + partner: Data(base64Encoded: partnerB64)!, + ephId: .init( + ephId: ephId, + source: Data(base64Encoded: ephIdSourceB64)! + ) + )) + + let encodedModel = try model.encode() + let decodedModel = try SingleUseCallbackReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/SingleUseResponseReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/SingleUseResponseReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..f4bd95f92b294d9302ff60c3b8607bd86c134fe0 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/SingleUseResponseReportTests.swift @@ -0,0 +1,71 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class SingleUseResponseReportTests: XCTestCase { + func testCoding() throws { + let rounds: [Int] = [1, 5, 9] + let payloadB64 = "rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==" + let receptionIdEphId: [Int] = [0, 0, 0, 0, 0, 0, 3, 89] + let receptionIdSourceB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let jsonString = """ + { + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "Payload": "\(payloadB64)", + "ReceptionID": { + "EphId": [\(receptionIdEphId.map { "\($0)" }.joined(separator: ", "))], + "Source": "\(receptionIdSourceB64)" + }, + "Err": null + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try SingleUseResponseReport.decode(jsonData) + + XCTAssertNoDifference(model, SingleUseResponseReport( + rounds: rounds, + payload: Data(base64Encoded: payloadB64)!, + receptionId: .init( + ephId: receptionIdEphId, + source: Data(base64Encoded: receptionIdSourceB64)! + ), + error: nil + )) + + let encodedModel = try model.encode() + let decodedModel = try SingleUseResponseReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } + + func testDecodingReportWithError() throws { + let rounds: [Int] = [1, 5, 9] + let payloadB64 = "rSuPD35ELWwm5KTR9ViKIz/r1YGRgXIl5792SF8o8piZzN6sT4Liq4rUU/nfOPvQEjbfWNh/NYxdJ72VctDnWw==" + let receptionIdEphId: [Int] = [0, 0, 0, 0, 0, 0, 3, 89] + let receptionIdSourceB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let error = "something went wrong" + let jsonString = """ + { + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "Payload": "\(payloadB64)", + "ReceptionID": { + "EphId": [\(receptionIdEphId.map { "\($0)" }.joined(separator: ", "))], + "Source": "\(receptionIdSourceB64)" + }, + "Err": "\(error)" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try SingleUseResponseReport.decode(jsonData) + + XCTAssertNoDifference(model, SingleUseResponseReport( + rounds: rounds, + payload: Data(base64Encoded: payloadB64)!, + receptionId: .init( + ephId: receptionIdEphId, + source: Data(base64Encoded: receptionIdSourceB64)! + ), + error: error + )) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..2a23b72e0e06707cf6e72f436b06974d368cf1f6 --- /dev/null +++ b/Tests/ElixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift @@ -0,0 +1,35 @@ +import CustomDump +import XCTest +@testable import ElixxirDAppsSDK + +final class SingleUseSendReportTests: XCTestCase { + func testCoding() throws { + let rounds: [Int] = [1, 5, 9] + let ephId: [Int] = [0, 0, 0, 0, 0, 0, 3, 89] + let ephIdSourceB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" + let jsonString = """ + { + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "EphID": { + "EphId": [\(ephId.map { "\($0)" }.joined(separator: ", "))], + "Source": "\(ephIdSourceB64)" + } + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try SingleUseSendReport.decode(jsonData) + + XCTAssertNoDifference(model, SingleUseSendReport( + rounds: rounds, + ephId: .init( + ephId: ephId, + source: Data(base64Encoded: ephIdSourceB64)! + ) + )) + + let encodedModel = try model.encode() + let decodedModel = try SingleUseSendReport.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +} diff --git a/Tests/ElixxirDAppsSDKTests/RestlikeMessageTests.swift b/Tests/ElixxirDAppsSDKTests/RestlikeMessageTests.swift deleted file mode 100644 index 164fce5bcc4822d6c8c33b8133f11486cdc953b7..0000000000000000000000000000000000000000 --- a/Tests/ElixxirDAppsSDKTests/RestlikeMessageTests.swift +++ /dev/null @@ -1,38 +0,0 @@ -import CustomDump -import XCTest -@testable import ElixxirDAppsSDK - -final class RestlikeMessageTests: XCTestCase { - func testCoding() throws { - let jsonString = """ - { - "Version": 1, - "Headers": "Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==", - "Content": "VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=", - "Method": 2, - "URI": "xx://CmixRestlike/rest", - "Error": "" - } - """ - let jsonData = jsonString.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.dataDecodingStrategy = .base64 - let message = try decoder.decode(RestlikeMessage.self, from: jsonData) - - XCTAssertNoDifference(message, RestlikeMessage( - version: 1, - headers: Data(base64Encoded: "Y29udGVudHM6YXBwbGljYXRpb24vanNvbg==")!, - content: Data(base64Encoded: "VGhpcyBpcyBhIHJlc3RsaWtlIG1lc3NhZ2U=")!, - method: 2, - uri: "xx://CmixRestlike/rest", - error: "" - )) - - let encoder = JSONEncoder() - encoder.dataEncodingStrategy = .base64 - let encodedMessage = try encoder.encode(message) - let decodedMessage = try decoder.decode(RestlikeMessage.self, from: encodedMessage) - - XCTAssertNoDifference(decodedMessage, message) - } -}