diff --git a/README.md b/README.md index b3de7cb..8e613fa 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,12 @@ A minimal example for initiating the SDK is as follows: ```jsx import { W3SSdk } from '@circle-fin/w3s-pw-web-sdk' -const sdk = new W3SSdk() - -sdk.setAppSettings({ - appId: '', +const sdk = new W3SSdk({ + appSettings: { + appId: '' + }, }) + sdk.setAuthentication({ userToken: '', encryptionKey: '', diff --git a/docs/customization.md b/docs/customization.md index a5f55c0..332d65d 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -19,6 +19,11 @@ - [SecurityIntros](#securityintros) - [SecurityQuestions](#securityquestions) - [SecuritySummary](#securitysummary) + - [SsoConfirm](#ssoconfirm) + - [TransactionRequest](#transactionrequest) + - [ContractInteraction](#contractinteraction) + - [SignatureRequest](#signaturerequest) + - [EmailOtp](#emailotp) - [ThemeColor](#themecolor) - [Resources](#resources) - [CustomLinks](#customlinks) @@ -31,14 +36,13 @@ - [setThemeColor](#setthemecolor) - [setCustomLinks](#setcustomlinks) - [setOnForgotPin](#setonforgotpin) + - [setOnResendOtpEmail](#setonresendotpemail) --- ## Overview -`w3s-pw-web-sdk` is a comprehensive toolkit designed for developers to enhance user interaction with W3S services through customization. This SDK excels in providing extensive customization options, allowing developers to tailor the user experience to meet specific needs. Key areas of customization include security questions, localization settings, UI themes, and resource management. With its flexible customization capabilities, the SDK empowers developers to create a more personalized and engaging interface for web3 service interactions. - -This customization-focused approach enables the integration of custom security questions, adaptation to various languages and regional settings, and the application of unique themes and resource elements. By leveraging these customization features, developers can significantly enhance the user experience, ensuring that the interface aligns with the branding and usability requirements of their applications. +Programmable Wallets Web SDK provides customization functionality that enables developers to tailor the desired user experience for the end-users. The scope includes customization of security questions, adaptation to various languages and regional settings, predefined error message, and unique themes and resource elements. ## Enums @@ -77,6 +81,7 @@ Holds localization settings. - `securityIntros` [\](#securityintros) The settings for `SecurityIntros` screen. - `securityQuestions` [\](#securityquestions) The settings for `SecurityQuestions` screen. - `securitySummary` [\](#securitysummary) The settings for `SecuritySummary` screen. +- `ssoConfirm` [\](#ssoconfirm) The settings for `SsoConfirm` screen. ### Common @@ -85,6 +90,7 @@ Holds localization settings for common texts. - `continue` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Continue text - `showPin` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Show pin text - `hidePin` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Hide pin text +- `confirm` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Confirm text ### ConfirmPincode @@ -160,6 +166,93 @@ Holds localization settings for `SecuritySummary` screen. - `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text - `question` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Question text +### SsoConfirm + +Holds localization settings for `SsoConfirm` screen. + +- `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text +- `headline` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Headline text + +### TransactionRequest + +Holds localization settings for a transaction request screen. + +- `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text. +- `subtitle` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Subtitle text. +- `mainCurrency` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Main currency details: + - `amount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Main currency amount. + - `symbol` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Main currency symbol. +- `exchangeValue` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Exchange currency details: + - `amount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Exchange currency amount. + - `symbol` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange currency symbol. +- `fromLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) From label text. +- `from` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) From address or label text. +- `toLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) To label text. +- `to` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) To addresses. +- `networkFeeLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee label text. +- `networkFeeTip` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee tooltip text. +- `networkFee` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee amount. +- `exchangeNetworkFee` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange network fee amount. +- `totalLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Total label text. +- `total` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Total amounts. +- `exchangeTotalValue` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange total value. +- `rawTxDescription` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Raw transaction description. +- `rawTx` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Raw transaction data. + +### ContractInteraction + +Holds localization settings for a contract interaction screen. + +- `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text. +- `subtitle` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Subtitle text. +- `mainCurrency` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Main currency details: + - `amount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Main currency amount. + - `symbol` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Main currency symbol. +- `exchangeValue` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Exchange value details: + - `amount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Exchange value amount. + - `symbol` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange value symbol. +- `fromLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) From label text. +- `from` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) From address or label text. +- `contractAddressLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Contract address label text. +- `contractInfo` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Contract information. +- `networkFeeLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee label text. +- `networkFeeTip` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee tooltip text. +- `networkFee` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Network fee amount. +- `exchangeNetworkFee` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange network fee amount. +- `totalLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Total label text. +- `total` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Total amounts. +- `exchangeTotalValue` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Exchange total value. +- `dataDetails` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Data details: + - `dataDetailsLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Data details label. + - `callData` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) Call data: + - `callDataLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Call data label. + - `data` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Call data string. + - `abiInfo` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) ABI information: + - `functionNameLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Function name label. + - `functionName` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Function name string. + - `parametersLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Parameters label. + - `parameters` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Parameters strings. + +### SignatureRequest + +Holds localization settings for a signature request screen. + +- `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text. +- `contractName` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Contract name. +- `contractUrl` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Contract URL. +- `subtitle` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Subtitle text. +- `descriptionLabel` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Description label text. +- `description` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Description text. + +### EmailOtp + +Holds localization settings for an email OTP (One-Time Password) screen. + +- `title` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Title text. +- `subtitle` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Subtitle text. +- `resendHint` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Resend hint text. +- `resend` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Resend button text. + ### ThemeColor Holds customization color settings. @@ -172,7 +265,7 @@ Holds customization color settings. - `error` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Error color, e.g. `'#FF0000'` or `'red'`. - `textMain` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Main text color, e.g. `'#000000'` or `'black'`. - `textMain2` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Main text color 2, e.g. `'#000000'` or `'black'`. -- `textAuxiliary` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Auxiliary text color, e.g. `'#000000'` or `'black'`. +- `textAuxiliary` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Primary auxiliary color, e.g. `'#000000'` or `'black'`. - `textAuxiliary2` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Auxiliary text color 2, e.g. `'#000000'` or `'black'`. - `textSummary` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Summary text color, e.g. `'#000000'` or `'black'`. - `textSummaryHighlight` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Summary highlight text color, e.g. `'#000000'` or `'black'`. @@ -180,6 +273,8 @@ Holds customization color settings. - `pinDotBase` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Fill color for pincode input dot, e.g. `'#FFFFFF'` or `'white'`. - `pinDotBaseBorder` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Stroke color for pincode input dot, e.g. `'#000000'` or `'black'`. - `pinDotActivated` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Fill color for inputted pincode input dot, e.g. `'#0000ff'` or `'blue'`. +- `enteredPinText` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Text color for entered pincode input, e.g. `'#000000'` or `'black'`. +- `inputText` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Text color for text input, e.g. `'#000000'` or `'black'`. - `inputBorderFocused` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Outline color for text input on focused, e.g. `'#0000ff'` or `'blue'`. - `inputBorderFocusedError` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Outline color for text input when error, e.g. `'#FF0000'` or `'red'`. - `inputBg` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Background color for text input, e.g. `'#FFFFFF'` or `'white'`. @@ -240,7 +335,7 @@ Holds custom links. Sets custom security questions. - `questions` [\](#questiontype) Array of `SecurityQuestion` -- `requiredCount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Required count of `SecurityQuestion`. The value is 2 by default. +- `requiredCount` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Required count of `SecurityQuestion`. The value is 2 by default. - `securityConfirmItems` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#array_type) Array of customized disclaimers on `SecurityConfirm` screen. The value is `undefined` by default. ##### setLocalizations @@ -273,3 +368,9 @@ Sets callback function for `ForgotPin` button click event - `onForgotPin` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Callback function - `shouldCloseModalOnForgotPin` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type) Should close modal on forgot pin click event + +##### setOnResendOtpEmail + +Sets callback function for `Resend OTP Email` button click event + +- `onResendOtpEmail` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Callback function diff --git a/docs/usage.md b/docs/usage.md index 389ea2f..006c231 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -10,25 +10,38 @@ - [ChallengeStatus](#challengestatus) - [ErrorCode](#errorcode) - [Interfaces](#interfaces) + - [Configs](#configs) - [AppSettings](#appsettings) - [Authentication](#authentication) + - [LoginConfigs](#loginconfigs) + - [Definitions](#definitions) + - [SocialLoginProvider](#socialloginprovider) - [Challenge](#challenge) - - [SignMessageResult](#signmessageresult) - [ChallengeResult](#challengeresult) + - [SignMessageResult](#signmessageresult) + - [SignTransactionResult](#signtransactionresult) + - [SocialLoginResult](#socialloginresult) + - [EmailLoginResult](#emailloginresult) + - [OauthInfo](#oauthinfo) - [Error](#error) + - [SocialLoginCompleteCallback](#sociallogincompletecallback) - [Class Definition](#class-definition) - [W3SSdk](#w3ssdk) - [Constructor](#constructor) - [Methods](#methods) - [setAppSettings](#setappsettings) - [setAuthentication](#setauthentication) + - [updateConfigs](#updateconfigs) + - [getDeviceId](#getdeviceid) + - [performLogin](#performlogin) + - [verifyOtp](#verifyotp) - [execute](#execute) --- ## Overview -`w3s-pw-web-sdk` offers developers a suite of tools and interfaces for interacting with W3S services. This SDK supports various challenge types, including wallet creation and transaction handling, making it an essential tool for developers working with web3 services. +Programmable Wallets Web SDK secures the process when users input their secret data, for example, PIN code and recovery questions. It also has various interfaces to interact with the [W3S APIs](https://developers.circle.com/w3s/reference/createuserwithpinchallenge) as in wallet creation, transaction initiation, also sign message (EIP-191) and sign typed-data (EIP-712) via the `challengeId`. ## Enums @@ -143,6 +156,7 @@ enum enum ErrorCode { biometricsUserLockoutPermanent = 155714, biometricsUserNotAllowPermission = 155715, biometricsInternalError = 155716, + invalidUserSecret= 155718, walletIdNotFound = 156001, tokenIdNotFound = 156002, transactionIdNotFound = 156003, @@ -153,6 +167,12 @@ enum enum ErrorCode { ## Interfaces +### Configs + +- `appSettings` [\](#appsettings) Application settings object +- `authentication` [\](#authentication) Authentication object +- `socialLoginConfig` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) Social login configuration object + ### AppSettings Holds application settings. @@ -166,33 +186,111 @@ Holds authentication information. - `userToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) User token - `encryptionKey` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Encryption key +### LoginConfigs + +Holds login configuration information. + +- `google` [\ | undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) (optional): Configuration for Google login. + - `clientId` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Google client ID. + - `redirectUri` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Google redirect URI. +- `facebook` [\ | undefined](<[#facebook](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects)>) (optional): Configuration for Facebook login. + - `appId` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Facebook app ID. + - `redirectUri` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Facebook redirect URI. +- `apple` [\ | undefined](https://firebase.google.com/docs/reference/kotlin/com/google/firebase/FirebaseOptions) (optional): Configuration for Apple login, using Firebase. +- `deviceToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Device token. +- `deviceEncryptionKey` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type): Device encryption key. +- `otpToken` [\ | undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) (optional): OTP token. + +#### Definitions + +- **google**: Configuration object for Google login. + - **clientId**: The Client ID for Google login. + - **redirectUri**: The Redirect URI for Google login. +- **facebook**: Configuration object for Facebook login. + - **appId**: The App ID for Facebook login. + - **redirectUri**: The Redirect URI for Facebook login. +- **apple**: Configuration for Apple login, using Firebase. +- **FirebaseOptions**: The Firebase configuration object. +- **deviceToken**: The token used to identify the device. +- **deviceEncryptionKey**: The encryption key used for the device. +- **otpToken**: The optional OTP token for verification. + +### SocialLoginProvider + +- `APPLE` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Apple login provider +- `FACEBOOK` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Facebook login provider +- `GOOGLE` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Google login provider + ### Challenge Holds information about a challenge. - `challengeId` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Challenge Id +### ChallengeResult + +Holds the basic information of a challenge. + +- `type` [\](#challengetype) Challenge type +- `status` [\](#challengestatus) Challenge status + ### SignMessageResult -Holds the result of a sign message or sign typed-data challenge. +Inherits from [ChallengeResult](#challengeresult). Holds the result of a sign message or sign typed-data challenge. - `signature` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Signature result after signing -### ChallengeResult +### SignTransactionResult -Holds the result of a challenge. +Inherits from [ChallengeResult](#challengeresult). Holds the result of a sign transaction challenge. -- `type` [\](#challengetype) Challenge type -- `status` [\](#challengestatus) Challenge status -- `data` [\](#signmessageresult) Sign message response +- `signature` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Signature result after signing +- `txHash` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Transaction hash +- `signedTransaction` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Signed transaction + +### SocialLoginResult + +Holds the result of a social login. + +- `userToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) User token +- `encryptionKey` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Encryption key +- `refreshToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Refresh token +- `oAuthInfo` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) OAuth information + +### EmailLoginResult + +Holds the result of an email login. + +- `userToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) User token +- `encryptionKey` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Encryption key +- `refreshToken` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Refresh token + +### OauthInfo + +Holds the OAuth information. + +- `provider` [\](#socialloginprovider) Social login +- `scope` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) OAuth scope +- ssoUserUUID [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) SSO user UUID +- `ssoUserInfo` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects) SSO user information + - email [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Email + - name [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Name + - phone [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Phone ### Error Holds error information. -- `code` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Internal error code +- `code` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) Internal error code - `message` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Error message +### SocialLoginCompleteCallback + +Callback function for social login completion. + +- `error` [\](#error) Presents if error occurs +- `result` [\](#socialloginresult) | [\](#emailloginresult) | undefined> Presents and contains the result of the social login when the social login is completed + ## Class Definition ### W3SSdk @@ -201,6 +299,11 @@ Holds error information. Initializes a new instance of `W3SSdk`. +The constructor initializes a new instance of the W3SSdk class. If an instance already exists, it will set up the instance with the provided configurations and callback function, then return the existing instance. If an instance does not already exist, it will create a new one, setting up with the provided configurations and callback function, and assign the created instance to W3SSdk.instance. + +- `configs` [\](#configs) Configurations object +- `socialLoginCompleteCallback` [\](#sociallogincompletecallback) Callback function + #### Methods ##### setAppSettings @@ -215,11 +318,34 @@ Sets the authentication information. - `auth` [\](#authentication) Authentication object +##### updateConfigs + +Updates the configurations. + +- `configs` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) Configurations object +- `onSocialLoginComplete` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Callback function + - `error` [\](#error) Presents if error occurs + - `result` [\](#socialloginresult) | [\](#emailloginresult) | undefined> Presents and contains the result of the social login when the social login is completed + +##### getDeviceId + +Gets the device ID. + +##### performLogin + +Performs a social login. + +- `provider` [\](#socialloginprovider) Social login provider + +##### verifyOtp + +Verifies the OTP. + ##### execute Executes a challenge. - `challengeId` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type) Challenge ID -- `onCompleted` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Callback function +- `onCompleted` [\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Callback function - `error` [\](#error) Presents if error occurs - - `result`[\](#challengeresult) Presents when success + - `result`<[ChallengeResult](#challengeresult) | [SignMessageResult](#signmessageresult) | [SignTransactionResult](#signtransactionresult) | undefined> Presents and contains the result of the challenge when the challenge is completed diff --git a/package.json b/package.json index fe25f42..7421e42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@circle-fin/w3s-pw-web-sdk", - "version": "1.0.20", + "version": "1.0.21", "description": "Javascript/Typescript SDK for Circle Programmable Wallets", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 077387e..6db53f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,11 +105,14 @@ export class W3SSdk { /** * Sets the application settings. + * This method will be deprecated in the future. Please use the constructor to set the application settings. * @param appSettings - Application settings. */ setAppSettings(appSettings: AppSettings): void { if (this.configs) { this.configs.appSettings = appSettings + } else { + this.configs = { appSettings } } } @@ -120,6 +123,13 @@ export class W3SSdk { setAuthentication(auth: Authentication): void { if (this.configs) { this.configs.authentication = auth + } else { + this.configs = { + appSettings: { + appId: '', + }, + authentication: auth, + } } }