Installation
At the moment, the following modules are subject to installation:
- SpatiumSDKSwift - the main Spatium SDK package containing protocol and core cryptography logic.
- SignerClientSwift - an auxiliary package that contains specific components for working with the SDK and Spatium Signer Service.
Access
General Information
The SpatiumSDKSwift package is distributed as a binary .xcframework containing the following architectures:
- macox (x86_64, arm64)
- ios (arm64)
- simulator (x86_64, arm64)
A zip archive of the framework is available at the following link: https://registry.spatium.io/repository/files-releases-sdk/SpatiumSDKSwift.xcframework.zip
, checksum: 3a7bbcec02276166f56ac988da57172f93bea23b1cea48811624fdc05c25c11d
.
To download the package (or install it as a dependency), you must specify access credentials received directly from the Spatium team.
The SignerClientSwift package is distributed as a public swiftpm package: https://bitbucket.org/caspiantechnologies/spatium-signer-client-swift.git and already includes a configured dependency on SpatiumSDKSwift.
swiftpm
To successfully install the package as a swiftpm dependency, you must also specify access credentials; the easiest way to do this is by creating a .netrc
file in the user's home folder with the following contents:
Example dependency configuration in swiftpm for SpatiumSDKSwift:
targets: [
...
.binaryTarget(
name: "SpatiumSDKSwift",
url: "https://registry.spatium.io/repository/files-releases-sdk/SpatiumSDKSwift.xcframework.zip",
checksum: "3a7bbcec02276166f56ac988da57172f93bea23b1cea48811624fdc05c25c11d"
),
...
.target(
name: <your_target>,
dependencies: [
"SpatiumSDKSwift"
]
),
...
],
Example dependency configuration in swiftpm for SignerClientSwift:
dependencies: [
...
.package(url: "https://bitbucket.org/caspiantechnologies/spatium-signer-client-swift.git", .upToNextMajor(from: "1.0.1")),
...
],
targets: [
...
.target(
name: <your_target>,
dependencies: [
.product(name: "SignerClientSwift", package: "spatium-signer-client-swift"),
]
),
...
]
Connection
The following snippet allows you to verify a connection by registering a new pair of secrets and synchronizing the public key.
import SpatiumSDKSwift
import SignerClientSwift
func test() async throws {
let auth = AuthorizationSession(
url: "https://cloud.spatium.net/authorization/v1",
tokenId: UUID().uuidString,
permissions: ["read", "secret"]
)
let clientCache = MemoryStorageDriver()
let clientStorage = MemoryStorageDriver()
let clientCrypto = SpatiumCrypto(cache: clientCache, storage: clientStorage)
let clientProtocol = SignerClient(
url: "https://cloud.spatium.net/signer/v1",
auth: auth,
crypto: clientCrypto,
timeout: 15 * 1000
)
// Retrieve a securityToken for an existing user via Cloud API
try await clientProtocol.auth.establish([securityToken])
try await clientProtocol.connect(timeout: 10 * 1000)
defer {
clientProtocol.disconnect()
}
let secretId = UUID().uuidString
try await clientProtocol.generateDistributedSecret(
secretId: secretId
);
let syncSessionId = UUID().uuidString
let publicKey = try await syncDistributedEcdsaKey(
driver: clientProtocol,
secretId: secretId,
syncSessionId: syncSessionId,
curve: .secp256k1,
derivationCoin: 0,
derivationAccount: 0
)
}