Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-native-c8osdk
Advanced tools
This is the Convertigo provider for React Native
Convertigo Client SDK is a set of libraries used by mobile or Windows desktop applications to access Convertigo Server services. An application using the SDK can easily access Convertigo services such as Sequences and Transactions.
The Client SDK will abstract the programmer from handling the communication protocols, local cache, FullSync off line data managment, UI thread management and remote logging. So the developer can focus on building the application.
Client SDK is available for:
Using npm:
npm install --save react-native-c8osdk
or using yarn:
yarn add react-native-c8osdk
react-native link react-native-c8osdk
Then for each platform:
Add the following dependencies to your the target of your Podfile
pod 'SwiftyJSON', '4.0.0'
pod 'Alamofire', '4.7.2'
pod 'AEXML', '4.3.0'
Also append the following posinstall script to your Podfile
post_install do |installer|
# List of Pods to use as Swift 4.1
myTargets = ['SwiftyJSON', 'Alamofire', 'AEXML']
installer.pods_project.targets.each do |target|
if myTargets.include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
This will configure your pods in the correct swift version.
Then run Pod install
Please be sure to use the workspace and not the project, so be sure to open Project.xcworkspace
Finnaly go to main's Project target => Build Phases => Link Binary with Libraries and add C8o.framework
There is nothing more than the react-native cli link, mentioned above, to do for android
import {C8oSettings, C8o, C8oLogLevel} from "react-native-c8osdk";
C8o Object must first be instanciated and then can be initialized, with a endpoint string parameter
// Instanciate C8o
let c8o: C8o = new C8o();
// Init C8o instance with a given endpoint, for example:
c8o.init("http://c8o-dev.convertigo.net:80/cems/projects/ClientSDKtestig");
The endpoint is the mandatory setting to get a C8o instance, but there is additional settings through the C8oSettings class.
A C8oSettings instance should be passed after the endpoint. Settings are copied inside the C8o instance.
Setters of C8oSettings always return its own instance and can be chained.
A C8oSettings can be instantiated from an existing C8oSettings or C8o instance.
// Instanciate C8oSettings
let settings = new C8oSettings();
// Add Settings properties
settings
.setTimeout(3000)
.setDefaultDatabaseName("myfullsyncDbName")
.setTrustAllCertificates(true)
.setLogLevelLocal(C8oLogLevel.TRACE);
// Instanciate C8o
let c8o: C8o = new C8o();
// Init C8o instance with a given endpoint and settings
c8o.init("http://c8o-dev.convertigo.net:80/cems/projects/ClientSDKtestig", settings);
With a C8o instance you can call Convertigo Sequence and Transaction or make query to your local FullSync database.
The call method expects the requester string of the following syntax:
The project name is optional, i.e. if not specified, the project specified in the endpoint will be used.
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above, and '.login' is the name of a sequence of your project
let result = await this.c8o.callJson('.login');
Convertigo requestables generally needs key/value parameters encapsuled in a simple javascript object.
The key is always a string and the value can be any object but a string is the standard case.
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above, and '.login' is the name of a sequence of your project
let result = await this.c8o.callJson('.login', {
login: "barnett.christine",
password: "mySuperPassword123"
});
A call can throw an error for many reasons: technical failure, network error and so on.
The standard try/catch should be used to handle this.
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above, and '.login' is the name of a sequence of your project
try{
let result = await this.c8o.callJson('.login', {
login: "barnett.christine",
password: "mySuperPassword123"
});
}
catch(error){
// Do somthing with the error
}
An application developer usually adds log information in his code. This is useful for the code execution tracking, statistics or debugging.
The Convertigo Client SDK offers an API to easily log on the standard device logger, generally in a dedicated console. To see this console, a device must be physically connected on a computer.
Fortunately, the same API also send log to the Convertigo server and they are merged with the server log. You can easily debug your device and server code on the same screen, on the same timeline. Logs from a device contain metadata, such as the device UUID and can help to filter logs on the server.
A log level must be specified:
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above
this.c8o.log.fatal("hello logs ! (level fatal)");
this.c8o.log.error("hello logs ! (level error)");
this.c8o.log.warn("hello logs ! (level warn)");
this.c8o.log.info("hello logs ! (level info)");
this.c8o.log.debug("hello logs ! (level debug)");
this.c8o.log.trace("hello logs ! (level trace)");
Full Sync enables mobile apps to handle fully disconnected scenarios, still having data handled and controlled by back end business logic. See the presentation of the Full Sync architecture for more details.
Convertigo Client SDK provides a high level access to local data following the standard Convertigo Sequence paradigm. They differ from standard sequences by a fs:// prefix. Calling these local Full Sync requestable will enable the app to read, write, query and delete data from the local database:
Where fs:// is the name of a specific FullSync Connector in the project specified in the endpoint. The fs:// name is optional only if the default database name is specified with the method setDefaultDatabaseName on the C8oSetting.
An application can have many databases. On mobile (Android, iOS and Xamarin based) they are stored in the secure storage of the application. On Windows desktop application, they are stored in the user AppData/Local folder, without application isolation.
All platforms can specify a local database prefix that allows many local database copies of the same remote database. Use the method setFullSyncLocalSuffix on the C8oSetting.
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above.
// clear or create the "base" database
// resultReset mustbe equal to { "ok" : true }
let resultReset = await this.c8o.callJson('fs://base.reset');
// creates a new document on "base", with 2 key/value pairs
// resultPost mustbe equal to { "ok": true, "id": "6f1b52df","rev": "1-b0620371" }
let resultPost = await this.c8o.callJson('fs://base.post', {
firstname: "Jhonn",
lastname: "Doe"
});
// retrieves the complet document from its "docid"
// resultGet mustbe equal to { "lastname": "Doe", "rev": "1-b0620371", "firstname": "John", "_id": "6f1b52df" }
let resultGet = await this.c8o.callJson('fs://base.get', {
docid: resultPost['id']
});
FullSync has the ability to replicate mobile and Convertigo server databases over unreliable connections still preserving integrity. Data can be replicated in upload or download or both directions. The replication can also be continuous: a new document is instantaneously replicated to the other side.
The client SDK offers the progress event to monitor the replication progression thanks to a C8oProgress instance.
// Using the Native Event Emitter to fetch progress events
this.c8o.progress.notifications((progress)=>{
// Do stuff with the progress notifications
});
// Assuming c8o is a C8o instance properly instanciated and initiated as describe above.
let result = await this.c8o.callJson('fs://base.replication_pull');
FAQs
Use Convertigo MBaaS from React native apps
We found that react-native-c8osdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.