Note:The Web and Mobile SDKs preserve the user keyshare with the individual, giving
them complete control. You must use the SDKs with the user-controlled wallet
product. Additionally, the Web and Mobile SDKs support only the user-controlled
wallet product.
Install the SDK
You can set up the React Native SDK by downloading it from GitHub.SDK architecture
You must use Web, iOS, Android or React Native SDKs to access the user-controlled Programmable Wallet product. The SDK secures, manages, and communicates with your server to ensure your user’s keyshare, always stays with them and is not exposed to your servers. To learn more, see SDK Architecture for User-Controlled Wallets.SDK API references
WalletSdk
implements IWalletIWalletSdk
interface IWalletSdk| Properties |
|---|
sdkVersion: SdkVersion SDK version |
| Methods |
|---|
init: (configuration: Configuration) => Promise<void> Configure the Circle endpoint for SDK to connect, reject Promise if the endpoint and appId’s format are invalid. |
setSecurityQuestions: (securityQuestions: SecurityQuestion[]) => void Set the security question list, throw Throwable when the SecurityQuestion array is empty or contains any question whose title length is not 2~512. |
addListener: (listener: EventListener) => void Register an EventListener for the app to handle events, e.g. forgot PIN. |
removeAllListeners: () => void Unregister all EventListener. |
execute: ( userToken: string, encryptionKey: string, challengeIds: string[], successCallback: SuccessCallback, errorCallback: ErrorCallback ) => void Execute the operations by challengeId and trigger the SuccessCallback with SuccessResult after sending the request to Circle endpoint successfully. ErrorCallback will be triggered when parameters are null or invalid. |
executeWithKeyShare: ( userToken: string, encryptionKey: string, pinCodeDeviceShare: string, challengeIds: string[], successCallback: SuccessCallback, errorCallback: ErrorCallback ) => void Execute the operations by challengeId and PIN code device share and trigger the SuccessCallback with SuccessResult after sending the request to Circle endpoint successfully. ErrorCallback will be triggered when parameters are null or invalid. |
getDeviceId: () => string? Get device ID |
performLogin: ( provider: SocialProvider, deviceToken: string, deviceEncryptionKey: string, successCallback: LoginSuccessCallback, errorCallback: ErrorCallback) ) => void Execute social provider login flow to get userToken, encryptionKey, refreshToken and OAuthInfo object. ErrorCallback will be triggered when parameters are null or invalid. |
performLogout: ( provider: SocialProvider, successCallback: LoginSuccessCallback, errorCallback: ErrorCallback) ) => void Clean login data, includes provider’s data |
setBiometricsPin: ( userToken: string, encryptionKey: string, successCallback: SuccessCallback, errorCallback: ErrorCallback ) => void Setup BiometricsForPin and trigger the SuccessCallback with SuccessResult after finishing the operation successfully. ErrorCallback will be triggered when parameters are null or invalid. |
setDismissOnCallbackMap: (map: Map<ErrorCode, boolean>) => void The SDK UI can be dismissed if there’s an error or warning during execute() and setBiometricsPin(). App can specify ErrorCode as true in the map to dismiss. |
moveTaskToFront: () => void Bring the SDK UI to foreground. After calling moveRnTaskToFront() and finishing the flow on React Native UI, e.g. forgot PIN flow, apps can back to SDK UI by calling moveTaskToFront() and continue the SDK task. |
moveRnTaskToFront: () => void Bring the React Native Activity / ViewController to front. In some cases, apps may need to go back to React Native UI during execute() or setBiometricsPin, e.g., receive an error, warning or event like forgotPin. |
setTextConfigsMap: (map: Map<TextsKey, TextConfig[]>) => void Define strings with specific configurations for special text customization. All keys are listed in A Index Table. |
setIconTextConfigsMap: ( map: Map<IconTextsKey, Array<IconTextConfig>> ) => void Define icon and string sets with specific configurations for icon text list item customization. All keys are listed in B Index Table. |
setTextConfigMap: (map: Map<TextKey, TextConfig>) => void Define strings with specific configurations for general string customization. It will replace values. All keys are listed in C Index Table. |
setImageMap: (map: Map<ImageKey, ImageSourcePropType>) => void Define image resource for image customization. All keys are listed in D Index Table. |
setDateFormat: (format: DateFormat) => void Set display date format, e.g. the answer of a security question in which inputType is datePicker. All supported formats are listed in DateFormat. The default format is “YYYY-MM-DD”. |
setDebugging: (debugging: boolean) => void Android only. true: default value, check customization map value and print warn level log. false: skip checking and turn off the log. |
setCustomUserAgent: (userAgent: string) => void Set custom user agent value. |
setErrorStringMap: (map: Map<ErrorCode, string) => void Define error message for customization. |
SdkVersion
interface SdkVersion| Properties |
|---|
rn: string Programmable Wallet React Native SDK version. |
native: string Programmable Wallet Native SDK version. |
Configuration
interface Configuration| Properties |
|---|
endpoint: string The endpoint SDK connects. |
appId: string Application ID, retrieved from Circle Developer Services Console. |
settingsManagement?: SettingsManagement Extra settings for SDK |
SettingsManagement
interface SettingsManagement| Properties |
|---|
enableBiometricsPin: boolean Enable biometrics to protect PIN code. |
SecurityQuestion
class SecurityQuestion| Properties |
|---|
title: string The question string. |
inputType: InputType The input type of the question. Support text input and timePicker. |
| Constructor |
|---|
constructor(title: string, inputType?: InputType) Initialize a SecurityQuestion, use InputType.text as default value. |
SocialProvider
To specify a social provider to operate on. SeeWalletSdk.performLogin(),
WalletSdk.performLogout().
Javascript
InputType
Enumerates the types of security questions.JavaScript
LoginResult
Interface LoginResult| Properties |
|---|
userToken?: string User token |
encryptionKey?: string Encryption key |
refreshToken?: string Refresh token |
oauthInfo?: OauthInfo OauthInfo for social login |
OauthInfo
Interface OauthInfo| Properties |
|---|
provider?: string Provider |
scope?: string[] Scope |
socialUserUUID?: string Social user UUID |
socialUserInfo?: SocialUserInfo SocialUserInfo for Social login for social login |
SocialUserInfo
Interface SocialUserInfo| Properties |
|---|
name?: string Name |
email?: string |
phone?: string Phone |
SuccessResult
interface SuccessResult| Properties |
|---|
result: ExecuteResult Execute result. |
warning?: ExecuteWarning Execute warning. |
Error
interface Error| Properties |
|---|
code: string Error code. |
message: string Error message. |
LoginSuccessCallback
type SuccessCallback| Type declaration |
|---|
(result: LoginResult) => void Callback when the operation is executed successfully. |
SuccessCallback
type SuccessCallback| Type declaration |
|---|
(result: SuccessResult) => void Callback when the operation is executed successfully. |
ErrorCallback
type ErrorCallback| Type declaration |
|---|
(error: Error) => void The callback is triggered when a failure occurs in operation or is canceled by the user. |
ExecuteResult
interface ExecuteResult| Properties |
|---|
resultType: ExecuteResultType The type of the operation that the challenge represents. |
status: ExecuteResultStatus The status of the execution. |
data?: ExecuteResultData The data of the execution. |
ExecuteResultData
interface ExecuteResultData| Properties |
|---|
signature?: string The signature for SIGN_MESSAGE and SIGN_TYPEDDATA. |
ExecuteResultType
Enumerates the types of challenges supportedJavaScript
ExecuteResultStatus
Enumerates the possible statuses for a challengeJavaScript
EventListener
type EventListener| Type declaration |
|---|
(event: ExecuteEvent) => void Event listener for receiving ExecuteEvent. |
ExecuteEvent
Enumerates the possible eventJavaScript
ErrorCode
Enumerates the types of error codeJavaScript
TextConfig
Data-only class for text customization.class TextConfig
| Properties |
|---|
text?: string Text to display |
gradientColors?: string[] Array of Gradient text color. Only used by TextsKey.enterPinCodeHeadline, TextsKey.securityIntroHeadline, TextsKey.newPinCodeHeadline |
textColor?: string Text color |
font?: string Font |
| Constructor |
|---|
constructor( text?: string, gradientColorsOrTextColor: string[] | string, font?: string ) |
TextConfig
Data-only class for icon text list item customization.class IconTextConfig
| Properties |
|---|
image:ImageSourcePropType The image source for customization. |
textConfig: TextConfig Text config for text customization. |
| Constructor |
|---|
constructor(image: ImageSourcePropType, textConfig: TextConfig) |
TextsKey
Enum for setTextConfigsMap().See A Index Table.
IconTextsKey
Enum for setIconTextConfigsMap().See B Index Table.
TextKey
Enum for setTextConfigMap().See C Index Table.
ImageKey
Enum for setImageMap().See D Index Table.
DateFormat
Enum for setDateFormat().JavaScript
SampleCode
JavaScript
JavaScript