Skip to main content

Configuration

Custom storage

Beacon iOS SDK is not a stateless library and bases part of its functionality on preserved data. By default the SDK stores its data in UserDefaults. However, it is possible to override the default storage and provide your own implementation. The BeaconCore package ships with 3 public protocols that can be satisfied and provided externally during the Beacon.WalletClient setup: Storage, ExtendedStorage (an extended version of Storage) and SecureStorage.

import BeaconCore
import BeaconClientWallet

Beacon.WalletClient.create(
with: .init(
...,
storage: MyStorage() /* or MyExtendedStorage() */,
secureStorage: MySecureStorage()
)
)

struct MyStorage: Storage {
// implementation
}

struct MyExtendedStorage: ExtendedStorage {
// implementation
}

struct MySecureStorage: SecureStorage {
// implementation
}

Plugins

Some packages may require additional data to store. Those packages usually come with their own storage plugin protocols which can be satisfied and provided externally.

BeaconTransportP2PMatrix

The BeaconTransportP2PMatrix package defines P2PMatrixStoragePlugin and ExtendedP2PMatrixStoragePlugin protocols.

import BeaconClientWallet
import BeaconTransportP2PMatrix

Beacon.WalletClient.create(
with: .init(
...,
connections: [try Transport.P2P.Matrix.connection(storagePlugin: MyP2PMatrixStoragePlugin() /* or MyExtendedP2PMatrixStoragePlugin */)]
)
)

struct MyP2PMatrixStoragePlugin: P2pMatrixStoragePlugin {
// implementation
}

struct MyExtendedP2PMatrixStoragePlugin: ExtendedP2pMatrixStoragePlugin {
// implementation
}

Custom Matrix nodes

You can provide your own Matrix node URLs while setting Beacon.WalletClient up with the BeaconTransportP2PMatrix transport layer. Use the Transport.P2P.Matrix.connection factory arguments to set your values.

import BeaconClientWallet
import BeaconTransportP2PMatrix

Beacon.WalletClient.create(
...,
connections: [try Transport.P2P.Matrix.connection(matrixNodes: ["my.matrix.node"])]
)

Custom URLSession

You can use your own URLSession implementation while setting Beacon.WalletClient up with BeaconTransportP2PMatrix transport layer. Use the Transport.P2P.Matrix.connection factory arguments to provide an instance.

import Foundation
import BeaconClientWallet
import BeaconTransportP2PMatrix

Beacon.WalletClient.create(
...,
connections: [urlSession: MyURLSession()]
)

struct MyURLSession: URLSession {
// implementation
}