@cyberlab/cyberconnect-rn
v0.0.1
Published
The JavaScript library that allows user to control their decentralized identity(DIDs) and social graph data.
Downloads
22
Readme
CyberConnect
The JavaScript library which implement with react-native provides CyberConnect
class which includes functions to allows users to control their decentralized identity(DIDs) and social graph data. The library encapsulates the complex authentication logic (authenticate to Ceramic Network) into easy-to-use functions.
CyberConnect API.
See also the CyberConnect.
Getting started
Installation
npm install @cyberlab/cyberconnect-rn
or
yarn add @cyberlab/cyberconnect-rn
Preparation
Add window.crypto.subtle
to your React Native application.It does this by communicating with a hidden WebView, which performs the actual computation.
Refer to the react-native-webview-crypto
repo for most of the code and some caveats.
Rendering the PolyfillCrypto will start up a WebView to transparently proxy all the crypto calls to.
import React, { Component } from 'react';
import { View } from 'react-native';
import App from './app';
import { PolyfillCrypto } from '@cyberlab/cyberconnect-rn';
class TopLevelComponent extends Component {
render() {
return (
<View>
<PolyfillCrypto />
<App />
</View>
);
}
}
AppRegistry.registerComponent('WhateverName', () => TopLevelComponent);
Basic usage
Init CyberConnect
import CyberConnect, {
Env,
Blockchain,
} from 'npm install @cyberlab/cyberconnect-rn';
const cyberConnect = new CyberConnect({
namespace: 'CyberConnect',
env: Env.Production,
chain: Blockchain.ETH,
provider: provider,
signingMessageEntity: 'CyberConnect' || your entity,
});
namespace
- Your applciation name.env
- (optional) Env decides the endpoints. Now we havestaging
andproduction
. (The default value isEnv.Production
).chain
- (optional) The blockchain you want to connect with. Now we only supportethereum
.provider
- The corresponding provider of the given chain.signingMessageEntity
- (optional) Use to describe the entity users sign their message with. Users will see it when authorizing in the walletI authorize ${signingMessageEntity} from this device using signing key:
. The default entity isCyberConnect
.
Connect
cyberConnect.connect(targetAddr, alias);
targetAddr
- The target wallet address to connect.alias
- (optional) Alias for the target address.
Disconnect
cyberConnect.disconnect(targetAddr);
targetAddr
- The target wallet address to disconnect.
SetAlias
cyberConnect.setAlias(targetAddr, alias);
targetAddr
- The target wallet address to disconnect.alias
- The alias for the target address.
Contributing
We are happy to accept small and large contributions, feel free to make a suggestion or submit a pull request.