Releases: trilemma-dev/SecureXPC
Releases · trilemma-dev/SecureXPC
0.8.0
This is a big release! Continued thanks to @amomchilov for his contributions and code reviews.
New functionality
- Adds built-in support for macOS Ventura's new
SMAppService's daemons & agents.- For simple configurations, just call
XPCServer.forMachService()and an auto-configured server will be returned.
- For simple configurations, just call
- Experimental support for shared memory has been added. Shared memory is truly shared between processes, no encoding or decoding occurs like with typical XPC communication.
- A friendly to use, although quite basic, data structure
SharedTrivialdemonstrates this functionality. - The building block pieces available through
SharedSemaphore,SharedMemory, andSharedRawMemoryshould enable you to build your own custom multi-process data structures. - This support is experimental and while it remains experimental breaking changes to it will not be considered for SerVer purposes.
- A friendly to use, although quite basic, data structure
XPCClientnow provides the unforgeable identity of the server it is connected to via itsserverIdentityasync property (or the equivalent callback function).XPCClientnow automatically verifies the identity of the server in common cases and this can be customized withXPCClient.ServerRequirement.XPCServerinstances now always have anendpointproperty (previously only those also conforming toXPCNonBlockingServerhad this property).- Send
IOSurfaceinstances over XPC connections using theIOSurfaceForXPCproperty wrapper. Datainstances and arrays of trivial types can optionally be more efficiently sent across XPC connections by using theDataOptimizedForXPCandArrayOptimizedForXPCproperty wrappers.
Breaking changes
XPCServerretrieval has been simplified. There are now just three main entry points:XPCServer.forThisXPCService()XPCServer.forMachService()XPCServer.makeAnonymous()
XPCServerretrieval is now more customizable.- To customize a Mach service use
XPCServer.MachServiceCriteriathen callXPCServer.forMachService(withCriteria:) - To customize an anonymous server use
XPCServer.makeAnonymous(withClientRequirement:)
- To customize a Mach service use
XPCServer's client requirements no longer require usingSecRequirementdirectly (although that's still supported).- Requirements are now created using
XPCServer.ClientRequirementand declarative in nature:XPCServer.makeAnonymous(withClientRequirement: try .sameTeamIdentifier || try .teamIdentifier("Q55ZG849VX"))
- Requirements are now created using
XPCClient's factory methods have been tweaked to now optionally take aXPCClient.ServerRequirementinstance.XPCFileDescriptorContainerhas been replaced by theFileHandleForXPCandFileDescriptorForXPCproperty wrappers.XPCRequestContexthas been renamed toXPCServer.ClientIdentity.- Several
XPCErrorcases have been removed and a few have been added. - The underlying interprocess communication protocol between the client and server has changed (to support the client's ability to verify the server's identity). This means if you update SecureXPC, you need to do so for both your client and server implementations at the same time.
0.7.0
This release adds numerous improvements that result in breaking changes.
Breaking changes
XPCServer'stargetQueueproperty has been removed and replaced with ahandlerQueueproperty with improved documentation. This queue is only used when running synchronous handlers. By default a concurrent queue is used to run synchronous handlers, but this can be set to a serial queue if desired.XPCClientandXPCServer'sserviceNameproperty has been replaced by aconnectionDescriptorproperty. This property returns a type ofXPCConnectionDescriptorwhich describes the connection and for non-anonymous connections includes the name.XPCServerEndpointnow also has aconnectionDescriptorproperty which returns a value matching that of theXPCServerfrom which it was created.- Most of
XPCError's cases now have named parameters for their associated values. For exampleXPCError.routeMismatch(routeName:description:).
0.6.0
This release adds automatic support for login items.
New functionality
- Call
XPCServer.forThisLoginItem()to be returned an auto-configuredXPCServerfor login items installed withSMLoginItemSetEnabled. This works for both sandboxed and non-sandboxed login items.
Breaking changes
- The underlying interprocess communication protocol between the client and server has changed (to support the above mentioned new functionality). This is true even if you are not using login items. This means if you update SecureXPC, you need to do so for both your client and server implementations at the same time.
0.5.2
This minor release introduces a new capability for file descriptors.
New functionality
- Adds
XPCFileDescriptorContainerwhich can wrap a native file descriptor, aFileHandle, or aFileDescriptorenabling sending of live file descriptors across an XPC connection.
0.5.1
0.5.0
This release contains a major new capability - sending multiple replies from the server for the same request.
New functionality
- Routes can now use sequential replies. On the server, a handler registered for a route with a sequential reply is passed a
SequentialResultProviderwith which it can send arbitrarily many responses to the client. On the client side these are exposed as anAsyncThrowingStream(or for the closure-based version as a callback providedSequentialResults).- The server side implementation can choose to finish a sequence or it can continue to provide values indefinitely. Amongst other use cases this is intended to replace any scenarios where the client is currently polling for new values - now the server can stream those to the client upon request.
Breaking changes
- The
NonBlockingServerprotocol has been renamed toXPCNonBlockingServer. - The underlying interprocess communication protocol between the client and server has changed (to support the above mentioned new functionality). This means if you update
SecureXPC, you need to do so for both your client and server implementations at the same time.
0.4.0
This release adds a bit of new functionality and also contains some minor breaking changes. Continued thanks to @amomchilov for all of his contributions and code reviews.
New functionality
- Support for all custom errors so long as they're
Codable. Simply define them as part of anXPCRoute(doing so is optional) and they'll be decoded by the client. This is highly convenient when using theasyncsend messages as the error itself will be throw. When using the closure based variants the error will be encapsulated within aHandlerError. - An
asyncclosure/function can now be used as the error handler for anXPCServer. - Within a closure registered with and called by an
XPCServerthe newly addedXPCRequestContextcan be used to access information about the request's client process. Usage of this information is entirely optional and likely not needed by most daemons and applications.
Breaking changes
- All of the
routenamed parameters forXPCClient'ssendandsendMessagefunctions have been renamed toto. Otherwise functionality remains unchanged. - To add an error handler to an
XPCServerinstead of assigning a closure toerrorHandler, it must now be added using thesetErrorHandlerfunction. There are two variants of this function with identical names: one forasyncand one for "standard" synchronous closures. - The
XPCError.othercase no longer exists.
0.3.1
0.3.0
This release adds significant new functionality and also contains many breaking changes. Big thanks to @amomchilov for all of the work he contributed to this release.
New functionality
- XPC services: create a server with
XPCServer.forThisXPCService()and communicate with it usingXPCClient.forXPCService(named:). - Anonymous XPC: useful for testing and some advanced multiprocess communication scenarios.
- Swift concurrency:
awaitsends from the client and registerasyncroutes with the server side (available on macOS 10.15 and later). - A server's dispatch queue can now be set.
- Endpoints can be retrieved for anonymous and XPC Mach servers, optionally sent over another XPC connection, and used to create clients.
- Anonymous and XPC Mach servers can be started in a non-blocking manner.
- Improved error types and messages.
Changes
- XPC Mach servers are now retrieved with
XPCServer.forThisBlessedHelperTool()orXPCServer.forThisMachService(named:clientRequirements:). - To start a server in a blocking manner, use
startAndBlock().start()now starts the server and then returns. - XPC Mach clients are now retrieved with
XPCClient.forMachService(named:). - The client's
sendandsendMessagefunctions which do not receive a reply must now either provide anonCompletionhandler or explicitly pass innilto indicate they do not want to be informed of completion or any errors. - The clients
sendandsendMessagefunctions which receive a reply have had theirwithReplyparameter renamed towithResponse. - The client's
sendandsendMessagefunctions no longerthrow; all errors are passed to either theonCompletionorwithResponsehandler. - Routes are now constructed with a builder pattern, for example:
XPCRoute.named("bedazzle").withMessageType(String.self).withReplyType(Bool.self)
Other additions
- Over 100 tests have been added.
0.2.2
- Renames
XPCMachServer.forBlessedExecutable()toXPCMachServer.forBlessedHelperTool()to better align with the naming convention used by Apple inSMJobBlessdocumentation - Minor documentation improvements