Share Transfer Module - tKey iOS SDK
The ShareTransferModule is a Swift module that provides functions for requesting, approving and transfering a share to another device.
To use the ShareTransferModule in your Swift project, you will need to import the module as follows:
import tkey_pkg
ShareTransferModule
is a class that provides the following methods:
Function | Description | Arguments | Async | return |
---|---|---|---|---|
request_new_share | request a new share | threshold_key: ThresholdKey, user_agent: String, available_share_indexes: String | Yes | String |
add_custom_info_to_request | Add custom info to share request | threshold_key: ThresholdKey, enc_pub_key_x: String, custom_info: String | Yes | void |
look_for_request | Returns an array of indexes of pending requests | threshold_key: ThresholdKey | Yes | [String] |
approve_request | approve the shareStore to be shared | threshold_key: ThresholdKey, enc_pub_key_x: String, share_store: ShareStore | Yes | void |
approve_request_with_share_index | approve sharing with share index | threshold_key: ThresholdKey, enc_pub_key_x: String, share_index: String | Yes | void |
get_store | Get share transfer store | threshold_key: ThresholdKey | Yes | ShareTransferStore |
set_store | Set share transfer store | threshold_key: ThresholdKey, store: ShareTransferStore | Yes | Bool |
delete_store | Delete share transfer store | threshold_key: ThresholdKey, enc_pub_key_x: String | Yes | Bool |
get_current_encryption_key | Get security questions stored in tKey | threshold_key: ThresholdKey | No | String |
request_status_check | start request status checking | threshold_key: ThresholdKey, enc_pub_key_x: String, delete_request_on_completion: Bool | Yes | ShareStore |
cleanup_request | cleanup the request | threshold_key: ThresholdKey | No | Bool |
request_new_share()
request_new_share(threshold_key: ThresholdKey, user_agent: String, available_share_indexes: String ) async throws -> String
Request a new share for the given user.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
user_agent | String | A string representing the user's user agent. |
available_share_indexes | String | A string representing the available share indexes for the user. |
Returns
- String: A string representing the requested share.
add_custom_info_to_request()
add_custom_info_to_request(threshold_key: ThresholdKey, enc_pub_key_x: String, custom_info: String ) async throws
Adds custom information to a share request.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
enc_pub_key_x | String | A string representing the user's encryption public key. |
custom_info | String | A string representing the custom information to add to the request. |
look_for_request()
look_for_request(threshold_key: ThresholdKey ) async throws -> [String]
Check the status of the user's share request.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
Returns
- [String]: An array of strings representing the status of the user's share request.
approve_request()
approve_request(threshold_key: ThresholdKey, enc_pub_key_x: String, share_store: ShareStore ) async throws
Approves a share request for the user.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
enc_pub_key_x | String | A string representing the user's encryption public key. |
share_store | ShareStore | A ShareStore object representing the user's share store. |
approve_request_with_share_index()
approve_request_with_share_index(threshold_key: ThresholdKey, enc_pub_key_x: String, share_index: String ) async throws
Approves a share request for the user using a specific share index.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
enc_pub_key_x | String | A string representing the user's encryption public key. |
share_index | String | A string representing the specific share index to use for the share request. |
get_store()
get_store(threshold_key: ThresholdKey ) async throws -> ShareTransferStore
Get the user's share store.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
Returns
- ShareTransferStore: A ShareTransferStore object representing the user's share store.
set_store()
set_store(threshold_key: ThresholdKey, store: ShareTransferStore ) async throws -> Bool
Set the user's share store.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
store | ShareTransferStore | A ShareTransferStore object representing the user's share store. |
Returns
- Bool: A boolean value indicating whether the operation was successful.
delete_store()
delete_store(threshold_key: ThresholdKey, enc_pub_key_x: String ) async throws -> Bool
Delete the user's share store.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
enc_pub_key_x | String | A string representing the user's encryption public key. |
Returns
- Bool: A boolean value indicating whether the operation was successful.
get_current_encryption_key()
get_current_encryption_key(threshold_key: ThresholdKey) throws -> String
This method is used to get the current encryption key for the given threshold_key.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
Returns
- String: A string value representing the current encryption key.
Throws
- ShareTransferError: If there is an issue with the underlying share transfer module.
- RuntimeError: If there is an issue with the runtime environment.
request_status_check()
request_status_check(threshold_key: ThresholdKey, enc_pub_key_x: String, delete_request_on_completion: Bool ) async throws -> ShareStore
This method is used to check the status of a request for the specified enc_pub_key_x under the given threshold_key.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
enc_pub_key_x | String | A string representing the user's encryption public key. |
delete_request_on_completion | Bool | A boolean value indicating whether the request should be deleted upon completion. |
Returns
- ShareStore: A ShareStore object representing the current status of the request.
Throws
- ShareTransferError: If there is an issue with the underlying share transfer module.
- RuntimeError: If there is an issue with the runtime environment.
cleanup_request()
cleanup_request(threshold_key: ThresholdKey) throws
This method is used to clean up any remaining requests for the specified threshold_key.
Parameters
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the user's threshold key. |
Returns
- Void
Throws
- ShareTransferError: If there is an issue with the underlying share transfer module.
- RuntimeError: If there is an issue with the runtime environment.