{"id":21659969,"url":"https://github.com/OpenST/ost-wallet-sdk-ios","last_synced_at":"2025-07-17T23:30:29.966Z","repository":{"id":51372608,"uuid":"157694871","full_name":"OpenST/ost-wallet-sdk-ios","owner":"OpenST","description":"OST Platform Wallet SDK for iOS","archived":false,"fork":false,"pushed_at":"2021-05-13T01:29:37.000Z","size":47885,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":10,"default_branch":"develop","last_synced_at":"2024-11-25T09:45:14.881Z","etag":null,"topics":["brand-tokens","ios","key-management-sdk","ost","ost-platform"],"latest_commit_sha":null,"homepage":"https://ost.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenST.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-15T10:41:11.000Z","updated_at":"2023-07-01T12:04:06.000Z","dependencies_parsed_at":"2022-08-28T17:21:17.254Z","dependency_job_id":null,"html_url":"https://github.com/OpenST/ost-wallet-sdk-ios","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/OpenST/ost-wallet-sdk-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenST%2Fost-wallet-sdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenST%2Fost-wallet-sdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenST%2Fost-wallet-sdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenST%2Fost-wallet-sdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenST","download_url":"https://codeload.github.com/OpenST/ost-wallet-sdk-ios/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenST%2Fost-wallet-sdk-ios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265678448,"owners_count":23810114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brand-tokens","ios","key-management-sdk","ost","ost-platform"],"created_at":"2024-11-25T09:31:58.912Z","updated_at":"2025-07-17T23:30:29.368Z","avatar_url":"https://github.com/OpenST.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# OST Wallet SDK iOS\n\n## Introduction\n\nOST iOS Wallet SDK is a mobile application development SDK that enables developers to integrate the functionality of a non-custodial crypto-wallet into consumer applications. \n\nThe iOS Wallet SDK...\n\n- Safely generates and stores keys on the user's mobile device\n- Signs data as defined by contracts using EIP-1077 and EIP-712\n- Enables users to recover access to their Brand Tokens in case the user loses their authorized device\u003c/br\u003e\n\nStarting version `2.3.0` the SDK also provides built-in user interface components which are configurable and support content and theme customization. Please refer to [OST Wallet UI](./documentation/OstWalletUI.md).\n\n## Support\n\n- iOS version : 9.0 and above (**recommended version 10.3** )\n- Swift version: 4.2\n\n## Dependencies\nWe use open-source code from the projects listed below. The `Set-up` section below provides instructions on adding the packages to your code. \n- [Alamofire](https://github.com/Alamofire/Alamofire)\n- [CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift)\n- [EthereumKit](https://github.com/D-Technologies/EthereumKit)\n- [FMDB](https://github.com/ccgus/fmdb)\n- [BigInt](https://github.com/attaswift/BigInt)\n- [TrustKit](https://github.com/datatheorem/TrustKit)\n\n\n## Table of Contents\n\n- [Set-up](#set-up)\n  * [A). Installing iOS Wallet SDK using Carthage](#a--installing-ios-wallet-sdk-using--carthage--https---githubcom-carthage-carthage-)\n    + [i). Installing Carthage](#i--installing--carthage--https---githubcom-carthage-carthage-)\n    + [ii). Installing wallet SDK using Carthage](#ii--installing-wallet-sdk-using-carthage)\n    + [iii). Copying the `OstWalletSdk.framework` file in your Xcode project](#iii--copying-the--ostwalletsdkframework--file-in-your-xcode-project)\n    + [iv). Adding the `OstWalletSdk` dependencies in your Xcode project](#iv--adding-the--ostwalletsdk--dependencies-in-your-xcode-project)\n    + [v). Adding SDK configuration file](#v--adding-sdk-configuration-file)\n    + [vi). Add `NSFaceIDUsageDescription` description in `info.plist`](#vi--add--nsfaceidusagedescription--description-in--infoplist-)\n    + [vii). Initialize the Wallet SDK](#vii--initialize-the-wallet-sdk)\n- [OST Wallet SDK APIs](#ost-wallet-sdk-apis)\n  * [Types of Methods](#types-of-methods)\n- [Workflows](#workflows)\n  * [setupDevice](#setupdevice)\n  * [activateUser](#activateuser)\n  * [addSession](#addsession)\n  * [performQRAction](#performqraction)\n  * [getDeviceMnemonics](#getdevicemnemonics)\n  * [executeTransaction](#executetransaction)\n  * [authorizeCurrentDeviceWithMnemonics](#authorizecurrentdevicewithmnemonics)\n  * [resetPin](#resetpin)\n  * [initiateDeviceRecovery](#initiatedevicerecovery)\n  * [abortDeviceRecovery](#abortdevicerecovery)\n  * [logoutAllSessions](#logoutallsessions)\n  * [revokeDevice](#revokedevice)\n  * [updateBiometricPreference](#updatebiometricpreference)\n- [Getters](#getters)\n  * [getAddDeviceQRCode](#getadddeviceqrcode)\n  * [getUser](#getuser)\n  * [getToken](#gettoken)\n  * [user.getCurrentDevice](#usergetcurrentdevice)\n  * [isBiometricEnabled](#isbiometricenabled)\n  * [getActiveSessions](#getactivesessions)\n- [OST Workflow Delegate Protocol](#ost-workflow-delegate-protocol)\n  * [flowComplete](#flowcomplete)\n  * [flowInterrupt](#flowinterrupt)\n  * [requestAcknowledged](#requestacknowledged)\n  * [getPin](#getpin)\n  * [pinValidated](#pinvalidated)\n  * [invalidPin](#invalidpin)\n  * [registerDevice](#registerdevice)\n  * [verifyData](#verifydata)\n- [OST JSON APIs](#ost-json-apis)\n- [Classes](#classes)\n  * [OstApiError](#ostapierror)\n    + [A). Methods](#a--methods)\n  * [OstError](#osterror)\n    + [A). Properties](#a--properties)\n  * [OstContextEntity](#ostcontextentity)\n  * [i) Properties](#i--properties)\n- [OST Workflow Context](#ost-workflow-context)\n  * [i) Properties](#i--properties-1)\n    + [a) workflowType](#a--workflowtype)\n\n\n## Set-up\n\n### A). Installing iOS Wallet SDK using [Carthage](https://github.com/Carthage/Carthage)\n\n#### i). Installing [Carthage](https://github.com/Carthage/Carthage)\n\nGet [Carthage](https://github.com/Carthage/Carthage) by running the following command on terminal\n\n```bash\nbrew install carthage\n```\n\nYou can also choose [other methods](https://github.com/Carthage/Carthage/#installing-carthage) to install [Carthage](https://github.com/Carthage/Carthage)\n\n\u003cbr\u003e\n\n#### ii). Installing wallet SDK using Carthage\nCarthage looks at a file called `Cartfile` to determine which libraries to install. Create a file in the same directory as your Xcode project called `Cartfile` and enter the following to tell Carthage which dependencies we want:\n\nAdd following entry in your `Cartfile`\n\n```bash\ngithub \"ostdotcom/ost-wallet-sdk-ios\"  == 2.4.1\n```\n\nNow to actually install everything run the following in your terminal:\n\n```bash\ncarthage update --platform iOS\n\n```\n\nA `Cartfile.resolved` file and a `Carthage` directory will appear in the same directory where your `.xcodeproj` or `.xcworkspace` is.\n\n\n\u003cbr\u003e\n\n#### iii). Copying the `OstWalletSdk.framework` file in your Xcode project\n\nOpen your project in Xcode, click on the project file in the left section of the screen and scroll down to the `Linked Frameworks and Libraries` section in Xcode.\n\n`Carthage` folder will have the `.framework` files that we will add in Xcode project.\n\nNow open the `Carthage/Build/iOS` folder in Finder:\n\nRun this command\n\n```bash\nopen Carthage/Build/iOS\n```\n\nOpen application target, under General tab, drag the built `OstWalletSdk.framework` binary from `Carthage/Build/iOS` folder into Linked Frameworks and Libraries section.\n\n![copy-framework-file](https://dev.ost.com/platform/docs/sdk/assets/copy-framework-file.png)\n\n#### iv). Adding the `OstWalletSdk` dependencies in your Xcode project\nWe need to add the `.framework` files of dependencies present inside `Carthage/Build/iOS`.\n\nOpen `application targets` in Xcode. Under `Build Phases` click `+` icon and choose `New Run Script Phase`. Add the following command.\n\n```bash\n/usr/local/bin/carthage copy-frameworks\n```\n\nClick the `+` under `Input Files` and add the following framework entires:\n\n```\n$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework\n$(SRCROOT)/Carthage/Build/iOS/BigInt.framework\n$(SRCROOT)/Carthage/Build/iOS/CryptoEthereumSwift.framework\n$(SRCROOT)/Carthage/Build/iOS/CryptoSwift.framework\n$(SRCROOT)/Carthage/Build/iOS/EthereumKit.framework\n$(SRCROOT)/Carthage/Build/iOS/FMDB.framework\n$(SRCROOT)/Carthage/Build/iOS/SipHash.framework\n$(SRCROOT)/Carthage/Build/iOS/TrustKit.framework\n$(SRCROOT)/Carthage/Build/iOS/OstWalletSdk.framework\n```\n\n\n![copy-framework-file](https://dev.ost.com/platform/docs/sdk/assets/add-dependency-framework-files.png)\n\n#### v). Adding SDK configuration file\n\nCreate `OstWalletSdk.plist` file. This file has configuration attributes used by OstWalletSdk. You should copy paste the configuration values from below snippet.\n\nCopy paste this configuration file.\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n \u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n \u003cplist version=\"1.0\"\u003e\n \u003cdict\u003e\n    \u003ckey\u003eBlockGenerationTime\u003c/key\u003e\n    \u003cinteger\u003e3\u003c/integer\u003e\n    \u003ckey\u003ePricePointTokenSymbol\u003c/key\u003e\n    \u003cstring\u003eOST\u003c/string\u003e\n    \u003ckey\u003ePricePointCurrencySymbol\u003c/key\u003e\n    \u003cstring\u003eUSD\u003c/string\u003e\n    \u003ckey\u003eRequestTimeoutDuration\u003c/key\u003e\n    \u003cinteger\u003e30\u003c/integer\u003e\n    \u003ckey\u003ePinMaxRetryCount\u003c/key\u003e\n    \u003cinteger\u003e3\u003c/integer\u003e\n    \u003ckey\u003eSessionBufferTime\u003c/key\u003e\n    \u003cinteger\u003e3600\u003c/integer\u003e\n    \u003ckey\u003eUseSeedPassword\u003c/key\u003e\n\t\u003cfalse/\u003e\n    \u003ckey\u003eEnableIOSDeviceRestore\u003c/key\u003e\n\t\u003cfalse/\u003e\n \u003c/dict\u003e\n \u003c/plist\u003e\n```\n\n1. BlockGenerationTime: The time in seconds it takes to mine a block on auxiliary chain.\n2. PricePointTokenSymbol: This is the symbol of base currency. So its value will be `OST`.\n3. PricePointCurrencySymbol: It is the symbol of quote currency used in price conversion.\n4. RequestTimeoutDuration: Request timeout in seconds for https calls made by ostWalletSdk.\n5. PinMaxRetryCount: Maximum retry count to get the wallet Pin from user.\n6. SessionBufferTime: Buffer expiration time for session keys in seconds. Default value is 3600 seconds.\n7. UseSeedPassword: The seed password is salt to PBKDF2 used to generate seed from the mnemonic. When `UseSeedPassword` set to true, different deterministic salts are used for different keys.\n8. EnableIOSDeviceRestore: When `EnableIOSDeviceRestore` set to true, After reinstallation, SDK check for available device key in Keychain for given `user id`.\n\n**These configurations are MANDATORY for successful operation. Failing to set them will significantly impact usage.**\n\n#### vi). Add `NSFaceIDUsageDescription` description in `info.plist`\n\nThe iOS Wallet SDK can use FaceID in lieu of fingerprint if the hardware supports it. To support faceID, please include [NSFaceIDUsageDescription](https://developer.apple.com/documentation/bundleresources/information_property_list/nsfaceidusagedescription) key in your application's `info.plist` file and describe its usage.\n\n**Note: [NSFaceIDUsageDescription](https://developer.apple.com/documentation/bundleresources/information_property_list/nsfaceidusagedescription) key is supported in iOS 11 and later.**\n\n#### vii). Initialize the Wallet SDK\nSDK initialization should happen before calling any other `workflow`. To initialize the SDK, we need to call `init` workflow of Wallet SDK. It initializes all the required instances and run db migrations.\n\nRecommended location to call **OstWalletSdk.initialize()** is in [application](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622921-application) method of [UIApplicationDelegate](https://developer.apple.com/documentation/uikit/uiapplicationdelegate).\n\n```swift\nfunc application(_ application: UIApplication,\n                didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n    do {\n        try OstWalletSdk.init(apiEndPoint: \u003cOST_PLATFORM_API_ENDPOINT\u003e)\n     } catch let ostError {\n           // Handle error here\n     }\n     return true\n}\n```\n\n\n```\nOstWalletSdk.initialize(apiEndPoint: String)\n```\n\n| Parameter | Description |\n|---|---|\n| **apiEndPoint** \u003cbr\u003e **String**\t| OST PLATFORM API ENDPOINT: \u003cbr\u003e 1. Sandbox Environment: `https://api.ost.com/testnet/v2/` \u003cbr\u003e 2. Production Environment: `https://api.ost.com/mainnet/v2/` |\n\n\n## OST Wallet SDK APIs\n\n### Types of Methods\n\n1. `Workflows`: Workflows are the core functions provided by wallet SDK to do wallet related actions. Workflows can be called directly by importing the SDK.\n\n    * Callbacks must confirm to `OstWorkflowDelegate` protocol. The `OstWorkflowDelegate` protocol defines methods that allow application to interact with `OstWalletSdk`.\n\n2. `Getters`: The SDK provides getter methods that applications can use for various purposes. These methods provide the application with data as available in the device's database. These functions are synchronous and will return the value when requested.\n\n3. `JSON APIs`: Allows application to access OST Platform APIs. \n\n\n## Workflows\n\n### setupDevice\nThis workflow needs `userId` and `tokenId` so `setupDevice` should be called when the application has determined that the user is logged in state. Using the mapping between userId in OST Platform and your app user, you have access to `userId` and `tokenId`.\n\n**If the user is logged in, then `setupDevice` should be called every time the app launches, this ensures that the current device is registered before communicating with OST Platform server.**\n\n\n```\nOstWalletSdk.setupDevice(\n    userId: String,\n    tokenId: String,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform  |\n| **tokenId** \u003cbr\u003e **String**\t| Unique identifier of the token economy |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t|An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).\u003cbr\u003e This object should implement `registerDevice` callback function. `registerDevice` will be called during the execution of this workflow.  |\n\n\n### activateUser\nIt `authorizes` the registered device and activates the user. User activation deploys TokenHolder and Device manager contracts on blockchain. Session keys are also created and authorized during `activateUser` workflow. So after `user activation`, users can perform wallet actions like executing transactions and reset pin. `activateUser` needs to be executed once for a user in an economy.\n\n```\nOstWalletSdk.activateUser(\n    userId: String,\n    userPin: String,\n    passphrasePrefix: String,\n    spendingLimit: String,\n    expireAfterInSecs: TimeInterval,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform  |\n| **userPin** \u003cbr\u003e **String**\t| User's PIN created during wallet setup.|\n| **passphrasePrefix** \u003cbr\u003e **String**\t| A constant unique identifier for your user. |\n| **spendingLimit** \u003cbr\u003e **String**\t| Spending limit of session key in [atto BT](https://dev.ost.com/platform/docs/guides/execute-transactions/).  |\n| **expireAfterInSec** \u003cbr\u003e **TimeInterval**\t| Expire time of session key in seconds. |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n### addSession\nThis workflow will create and authorize the session key that is needed to do the transactions. This flow should be called if the session key is expired or not present. \n\n```\nOstWalletSdk.addSession(\n    userId: String,\n    spendingLimit: String,\n    expireAfterInSecs: TimeInterval,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t|  Unique identifier of the user stored in OST Platform|\n| **spendingLimit** \u003cbr\u003e **String**\t| Spending limit of session key in [atto BT](https://dev.ost.com/platform/docs/guides/execute-transactions/).   |\n| **expireAfterInSecs** \u003cbr\u003e **long**\t| Expire time of session key in seconds.  |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol). |\n\n\n### performQRAction\nThis workflow will perform operations after reading data from a QR-Code. This workflow can be used to add a new device and to execute transactions.\n\n```\nOstWalletSdk.performQRAction(\n    userId: String,\n    payload: String,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform|\n| **data** \u003cbr\u003e **String**\t| JSON object string scanned from QR code. \u003cbr\u003e [Sample QRCode JSON](https://dev.ost.com/platform/docs/guides/execute-transactions/#generating-qrcode-with-transaction-data) |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol). |\n\n\n### getDeviceMnemonics\nTo get the 12 words recovery phrase of the current device key. Users will use it to prove that it is their wallet.  \n\n```\nOstWalletSdk.getDeviceMnemonics(\n    userId: String,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol). |\n\n\n### executeTransaction\nWorkflow should be used when user wants to transfer tokens.\n\n```\nOstWalletSdk.executeTransaction(\n    userId: String,\n    tokenHolderAddresses: [String],\n    amounts: [String],\n    transactionType: OstExecuteTransactionType,\n    meta: [String: String],\n    options: [String: Any],\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform|\n| **tokenHolderAddresses** \u003cbr\u003e **[String]**\t|  **TokenHolder**  addresses of beneficiary users.  |\n| **amounts** \u003cbr\u003e **[String]**\t| Array of Amount to be transferred in atto.  |\n| **transactionType** \u003cbr\u003e **OstExecuteTransactionType**\t| Transaction type can take one of the two values: \u003cbr\u003e 1. `DirectTransfer`:  In this type of transaction, the amount of brand token will be transferred directly to the receiver user. \u003cbr\u003e 2. `Pay`: In this type of transaction the amount of fiat passed will first be converted into brand token and after this conversion the transfer will happen in converted brand token amount.|\n| **meta** \u003cbr\u003e **[String: String]**\t| Dictionary object having extra information that a developer can pass about the transfer. This dictionary object can have 3 properties. \u003cbr\u003e\u003cbr\u003eExample meta:  \u003cbr\u003e[\u003cbr\u003e\u0026nbsp; \u0026nbsp;\"name\":\"Thanks for like\", \u003cbr\u003e\u0026nbsp; \u0026nbsp;\"type\": \"user_to_user\" (it can take one of the following values: `user_to_user`, `user_to_company` and `company_to_user`), \u003cbr\u003e\u0026nbsp; \u0026nbsp;  \"details\": \"like\"\u003cbr\u003e] |\n| **options** \u003cbr\u003e **[String: Any]**\t| Optional settings parameters. You can set following values: \u003cbr\u003e 1. `currency_code`: Currency code for the pay currency. \u003cbr\u003e Example: `{\"currency_code\": \"USD\"}`|\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol). |\n\n\n### authorizeCurrentDeviceWithMnemonics\nTo add a new device using 12 words recovery phrase. \n\n```\nOstWalletSdk.authorizeCurrentDeviceWithMnemonics(\n    userId: String,\n    mnemonics: [String],\n    delegate: OstWorkflowDelegate\n)\n\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform|\n| **mnemonics** \u003cbr\u003e **[String]**\t| Array of String having 12 words |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n### resetPin\nTo change the PIN.\n\n**User will have to provide the current PIN in order to change it.**\n\n```\nOstWalletSdk.resetPin(\n    userId: String,\n    passPhrasePrefix: String,\n    oldUserPin: String,\n    newUserPin: String,\n    delegate: OstWorkflowDelegate\n)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **passPhrasePrefix** \u003cbr\u003e **String**\t| A constant unique identifier for a your user. |\n| **oldUserPin** \u003cbr\u003e **String**\t| Current wallet PIN  |\n| **newUserPin** \u003cbr\u003e **String**\t| New wallet PIN |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n\n### initiateDeviceRecovery\nA user can control their tokens using their authorized device(s). If a user loses their authorized device, the user can recover access to her tokens by authorizing a new device by initiating the recovery process.\n\n```swift\nOstWalletSdk.initiateDeviceRecovery(\n    userId: String,\n    recoverDeviceAddress: String,\n    userPin: String,\n    passphrasePrefix: String,\n    delegate: OstWorkflowDelegate\n    )\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **recoverDeviceAddress** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **userPin** \u003cbr\u003e **String**\t| User's Wallet PIN  |\n| **passPhrasePrefix** \u003cbr\u003e **String**\t| A constant unique identifier for a your user. |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate** | An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol). |\n\n\n### abortDeviceRecovery\nTo abort the initiated device recovery.\n\n```swift\nOstWalletSdk.abortDeviceRecovery(\n    userId: String,\n    userPin: String,\n    passphrasePrefix: String,\n    delegate: OstWorkflowDelegate)\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **userPin** \u003cbr\u003e **String**\t| User's Wallet PIN  |\n| **passPhrasePrefix** \u003cbr\u003e **String**\t| A constant unique identifier for a your user. |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n### logoutAllSessions\nTo revoke all sessions associated with the provided userId.\n\n```swift\nOstWalletSdk.logoutAllSessions(\n    userId: String,\n    delegate: OstWorkflowDelegate)\n```\n\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n### revokeDevice\nTo revoke device access.\n\n```Swift\nOstWalletSdk.revokeDevice(\n    userId: String,\n    deviceAddressToRevoke: String,\n    delegate: OstWorkflowDelegate) \n```\n\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n|\t**deviceAddressToRevoke** \u003cbr\u003e **String**| Wallet address of the device to revoke. |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n### updateBiometricPreference\nTo enable or disable the biometric.\n\n```Swift\nOstWalletSdk.updateBiometricPreference(\n    userId: String,\n    enable: Bool,\n    delegate: OstWorkflowDelegate) \n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier for the user of economy |\n| **enable** \u003cbr\u003e **Bool**| Preference to use the biometric. |\n| **delegate** \u003cbr\u003e **OstWorkflowDelegate**\t| An instance of a class that implements the callback function available in `OstWorkflowDelegate` protocol. These callback functions are needed for communication between app and wallet SDK. Implement `flowComplete` and `flowInterrupt` callback functions to get the workflow status. Details about other callback function can be found in [OstWorkflowDelegate protocol reference](#ostworkflowdelegate-protocol).  |\n\n\n\n\n## Getters\n\n### getAddDeviceQRCode\nThis workflow will return the QRCode in the form of [CIImage object](https://developer.apple.com/documentation/coreimage/ciimage) that can be used to show on screen. This QRCode can then be scanned to add the new device.\n\n```Swift\nOstWalletSdk.getAddDeviceQRCode(\n    userId: String\n) throws -\u003e CIImage?\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform |\n\n\n**Returns**\n\n| Type | Description |\n|---|---|\n| **CIImage**\t| QRCode [CIImage](https://developer.apple.com/documentation/coreimage/ciimage) object. |\n\n\n### getUser\nGet user entity for given userId.\n\n```Swift\nOstWalletSdk.getUser(userId: String) \n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform |\n\n\n**Returns**\n\n| Type | Description |\n|---|---|\n| **User**\t| The user object |\n\n\n\n### getToken \nGet token entity for given tokenId.\n\n```Swift\nOstWalletSdk.getToken(tokenId: String) \n```\n\n| Parameter | Description |\n|---|---|\n| **tokenId** \u003cbr\u003e **String**\t| Unique identifier of the token |\n\n**Returns**\n\n\n| Type      | Description      |\n|-----------|------------------|\n| **Token**\t| The token object |\n\n\n### user.getCurrentDevice\nGet current device of user.\n\n```Swift\nlet user: OstUser = OstWalletSdk.getUser(userId: String)\nlet device: OstCurrentDevice = user.getCurrentDevice()\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user stored in OST Platform |\n\n\n**Returns**\n\n| Type        | Description       |\n|-------------|-------------------|\n| **device**\t| The device object |\n\n### isBiometricEnabled\nGet biometric preference of the user.\n\n```Swift\nOstWalletSdk.isBiometricEnabled(userId: String) \n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**    | Unique identifier of the user stored in OST Platform |\n\n\n**Returns**\n\n| Type                            | Description |\n|---------------------------------|---------------------------------------------------|\n| **Preference** \u003cbr\u003e **Bool**      | `true` if user has enabled biometric verfication. |\n\n\n### getActiveSessions\nGet active sessions for given spending limit.\nIf  passed spending limit is nil, return all active sessions.\n```Swift\nOstWalletSdk.getActiveSessions(\n    userId: String, \n    spendingLimit: String?\n) -\u003e [OstSession]\n```\n\n| Parameter | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**    | Unique identifier of the user stored in OST Platform |\n| **spendingLimit** \u003cbr\u003e **String**    | Transction amount |\n\n\n**Returns**\n\n| Type                            | Description |\n|---------------------------------|---------------------------------------------------|\n| **OstSession** \u003cbr\u003e **Array**      | List of active sessions |\n\n\n## OST Workflow Delegate Protocol\n\n### flowComplete\nThis function will be called by SDK when a workflow is completed. The details of workflow and the entity that was updated during the workflow will be available in the arguments.\n\n```\nfunc flowComplete(\n        workflowContext: OstWorkflowContext, \n        ostContextEntity: OstContextEntity\n        )\n```\n\n| Argument | Description |\n|---|---|\n| **ostWorkflowContext** \u003cbr\u003e **OstWorkflowContext**\t|\tInformation about the workflow\t|\n| **ostContextEntity** \u003cbr\u003e **OstContextEntity**\t| Information about the entity |\n\n\n### flowInterrupt\nThis function will be called by SDK when a workflow fails or cancelled. The workflow details and error details will be available in the arguments.\n\n```\nfunc flowInterrupted(\n        workflowContext: OstWorkflowContext, \n        error: OstError\n)\n```\n\n| Argument | Description |\n|---|---|\n| **ostWorkflowContext** \u003cbr\u003e **OstWorkflowContext**\t| Information about the workflow |\n| **ostError** \u003cbr\u003e **OstError**\t| ostError object will have details about the error that interrupted the flow |\n\n\n### requestAcknowledged\nThis function will be called by SDK when the core API request was successful which happens during the execution of workflows. At this stage the workflow is not completed but it shows that the main communication between the wallet SDK and OST Platform server is complete. \u003cbr\u003eOnce the workflow is complete, the `app` will receive the details in `flowComplete` function and if the workflow fails then app will receive the details in `flowInterrupt` function. \n\n```\nfunc requestAcknowledged(\n        workflowContext: OstWorkflowContext, \n        ostContextEntity: OstContextEntity\n        )\n```\n\n| Argument | Description |\n|---|---|\n| **ostWorkflowContext** \u003cbr\u003e **OstWorkflowContext**\t| Information about the workflow |\n| **ostContextEntity** \u003cbr\u003e **OstContextEntity**\t| Information about the entity |\n\n\n### getPin\nThis function will be called by SDK when it needs to get the PIN from the `app` user to authenticate any authorized action.\n\n\u003cbr\u003e**Expected Function Definition:** Developers of client company are expected to launch their UI to get the PIN from the user and pass back this PIN to SDK by calling **delegate.pinEntered(_ userPin: String, passphrasePrefix: String)** \n\n```\nfunc getPin(\n        _ userId: String, \n        delegate: OstPinAcceptDelegate\n        )\n```\n\n| Argument | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user |\n| **delegate** \u003cbr\u003e **OstPinAcceptDelegate**\t| **delegate.pinEntered(_ userPin: String, passphrasePrefix: String)** should be called to pass the PIN back to SDK. \u003cbr\u003e For some reason if the developer wants to cancel the current workflow they can do it by calling **delegate.cancelFlow()**|\n\n### pinValidated\nThis function will be called by SDK when PIN is validated. \n\n```\nfunc pinValidated(_ userId: String)\n```\n\n| Argument | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t| Unique identifier of the user |\n\n\n\n### invalidPin\nThis function will be called by SDK when the entered PIN is incorrect and `app` user has to provide the PIN again. Developers are expected to get the PIN from user again and pass back the PIN back to the SDK by calling  **delegate.pinEntered(_ userPin: String, passphrasePrefix: String)** .\n\n```\nfunc invalidPin(\n        _ userId: String, \n        delegate: OstPinAcceptDelegate\n        )\n```\n\n| Argument | Description |\n|---|---|\n| **userId** \u003cbr\u003e **String**\t|\tUnique identifier of the user\t|\n| **delegate** \u003cbr\u003e **OstPinAcceptDelegate**\t| **delegate.pinEntered(_ userPin: String, passphrasePrefix: String)** should be called to again pass the PIN back to SDK. \u003cbr\u003e For some reason if the developer wants to cancel the current workflow they can do it by calling **delegate.cancelFlow()** |\n\n\n### registerDevice\nThis function will be called by SDK to register the device.\u003cbr\u003e **Expected Function Definition:** Developers of client company are expected to register the device by communicating with their company's server. On client company's server they can use `Server SDK` to register this device in OST Platform. Once device is registered on OST client company's server will receive the newly created `device` entity. This device entity should be passed back to the `app`.\u003cbr\u003e\n\nFinally they should pass back this newly created device entity back to the wallet SDK by calling **delegate.deviceRegistered(_ apiResponse: [String: Any])**.\n\n```\nfunc registerDevice(\n        _ apiParams: [String: Any], \n        delegate: OstDeviceRegisteredDelegate\n        )\n```\n\n| Argument | Description |\n|---|---|\n| **apiParams** \u003cbr\u003e **[String: Any]**\t|\tDevice information for registration\t|\n| **delegate** \u003cbr\u003e **OstDeviceRegisteredDelegate**\t| **delegate.deviceRegistered(_ apiResponse: [String: Any] )** should be called to pass the newly created device entity back to SDK. \u003cbr\u003eIn case data if there is some issue while registering the device then the current workflow should be canceled  by calling **delegate.cancelFlow()** |\n\n\n### verifyData\nThis function will be called by SDK to verify the data during `performQRAction` workflow.\n\n\n```\nfunc verifyData(\n        workflowContext: OstWorkflowContext, \n        ostContextEntity: OstContextEntity, \n        delegate: OstValidateDataDelegate\n        )\n```\n\n\n| Argument | Description |\n|---|---|\n| **workflowContext** \u003cbr\u003e **OstWorkflowContext**\t| Information about the current workflow during which this callback will be called\t|\n| **ostContextEntity** \u003cbr\u003e **OstContextEntity**\t| Information about the entity |\n| **delegate** \u003cbr\u003e **OstValidateDataDelegate**\t| **delegate.dataVerified()** should be called if the data is verified successfully. \u003cbr\u003eIn case data is not verified the current workflow should be canceled by calling **delegate.cancelFlow()**|\n\n\n## OST JSON APIs\nWhile the getter methods provide application with data stored in device's database, the JSON API methods make API calls to OST Platform servers. Please refer to [OST JSON API](/documentation/OstJsonApi.md) for documentation.\n\n## Classes\n\n1. OstApiError\n2. OstError\n3. OstContextEntity\n\n### OstApiError\nThis class is used to provide API related error details in [flowInterrupt](#2-flowinterrupt) callback function. \n\nYou can call following methods on the object of this class to get more details about the error.\n\n#### A). Methods\n\n1. `public func getApiErrorCode() -\u003e String?`\n2. `public func getApiErrorMessage() -\u003e String?`\n3. `public func getApiInternalId() -\u003e String?`\n4. `public func isBadRequest() -\u003e Bool`\n5. `public func isDeviceTimeOutOfSync() -\u003e Bool`\n6. `public func isApiSignerUnauthorized() -\u003e Bool`\n\n\n### OstError\nThis class is used to provide error details in [flowInterrupt](#2-flowinterrupt) callback function. \n\nYou can read following properties on the object of this class to get more details about the error.\n\n#### A). Properties\n\n1. public internal(set) var isApiError = false\n2. public let internalCode:String\n3. public let errorMessage:String\n4. public let messageTextCode:OstErrorText;\n5. public var errorInfo: [String: Any]? = nil\n\n\u003cbr\u003e\n\n### OstContextEntity\n \nThis class provides context about the `entity` that is being changed during a [workflow](#workflows). Callback functions that needs to know about the `entity` will receive an object of this class as an argument. \n\n\n`entityType` property will return one of the values from this enum.\n\n```swift\npublic enum OstEntityType {\n    case device,\n    user,\n    array,\n    session,\n    transaction,\n    recoveryOwner,\n    string,\n    dictionary,\n    tokenHolder\n}\n```\n\nYou can read the following properties to get more details about the entity.\n\n### i) Properties\n\n```swift\npublic private(set) var entity: Any?\npublic private(set) var entityType: OstEntityType\n```\n\n## OST Workflow Context\nThis class provides context about the current [workflow](#workflows). Callback function that needs to know about the current [workflow](#workflows) will get the object of this class as an argument.\n\n\n`workflowType` property will take one of the values from this enum.\n\n```swift\npublic enum OstWorkflowType {\n    case setupDevice,\n    activateUser,\n    addSession,\n    getDeviceMnemonics,\n    performQRAction,\n    executeTransaction,\n    authorizeDeviceWithQRCode,\n    authorizeDeviceWithMnemonics,\n    initiateDeviceRecovery,\n    abortDeviceRecovery,\n    revokeDeviceWithQRCode,\n    resetPin,\n    logoutAllSessions\n}\n```\n\nYou can read the following properties to get more details about the current [workflow](#workflows).\n\n### i) Properties\n\n#### a) workflowType\n\n```swift\npublic let workflowType: OstWorkflowType\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenST%2Fost-wallet-sdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOpenST%2Fost-wallet-sdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenST%2Fost-wallet-sdk-ios/lists"}