@cyberlab/cyberconnect-rn
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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 have staging and production. (The default value is Env.Production).
  • chain - (optional) The blockchain you want to connect with. Now we only support ethereum.
  • 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 wallet I authorize ${signingMessageEntity} from this device using signing key:. The default entity is CyberConnect.

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.

Package Sidebar

Install

npm i @cyberlab/cyberconnect-rn

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

118 kB

Total Files

57

Last publish

Collaborators

  • akasuv