Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
react-native-blockstack
Advanced tools
Decentralized identity and storage with Blockstack in React Native
Welcome to the React Native bridge of the Blockstack SDK. This bridge exists to help you get started quickly developing react native apps, but not all functionality available in the official native Blockstack SDK has been bridged over. As this is a community maintained repo, feel free to fill in the gaps and submit a pull request. For questions, concerns, ideas, or requests, open an issue, join the Blockstack Community Slack (https://community.blockstack.org/slack), or reach out in the forums (https://forum.blockstack.org). Happy hacking!
$ npm install react-native-blockstack --save
$ react-native link react-native-blockstack
If you do not already have a react native project set up, create one via the React Native CLI. Follow Facebook's official getting started guide here: https://facebook.github.io/react-native/docs/getting-started.html.
Once this is set up, move on to the next section to integrate the Blockstack SDK.
Install cocoapods, sudo gem install cocoapods
In the terminal, navigate to your project root and use command pod init
In the created Podfile
, add the following lines under your target:
use_frameworks!
pod 'Blockstack'
# React Native pods
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
From the terminal, enter pod install
Open the newly created [your project's name].xcworkspace
project. Note: Always use this file and not the .xcodeproj file when opening your project.
In XCode, in the project navigator, right click your project and select Add Files to [your project's name]
Go to node_modules
➜ react-native-blockstack
➜ ios
and add the RNBlockstackSdk
folder
Run your project (Cmd+R
)
In your React Native project's App.js file, add the following line:
import RNBlockstackSdk from "react-native-blockstack";
Utilize relevant methods as defined in RNBlockstackSdk.swift
(i.e. RNBlockstackSdk.isUserSignedIn()
)
android/app/src/main/java/[...]/MainActivity.java
import com.reactlibrary.RNBlockstackSdkPackage;
to the imports at the top of the filenew RNBlockstackSdkPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-blockstack'
project(':react-native-blockstack').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-blockstack/android')
android/app/build.gradle
:
compile project(':react-native-blockstack')
RNBlockstackSdk.sln
in node_modules/react-native-blockstack/windows/RNBlockstackSdk.sln
folder to their solution, reference from their app.MainPage.cs
appusing Blockstack.Sdk.RNBlockstackSdk;
to the usings at the top of the filenew RNBlockstackSdkPackage()
to the List<IReactPackage>
returned by the Packages
methodimport RNBlockstackSdk from 'react-native-blockstack';
// check whether a blockstack session is running
result = await RNBlockstackSdk.hasSession()
hasSession = result["hasSession"]
// create a new session (replace with your app domain)
config = {
appDomain:"https://example.com",
scopes:["store_write"]
}
session = await RNBlockstackSdk.createSession(config)
// sign user in (starts redirect to blockstack browser)
await RNBlockstackSdk.signIn()
// handle auth response, e.g. from a prop
result = await RNBlockstackSdk.handleAuthResponse(this.props.authResponse)
did = result["decentralizedID"]
// sign user out
result = await RNBlockstackSdk.signUserOut()
success = result["signedOut"]
// check whether a user is signed in
result = await RNBlockstackSdk.isUserSignedIn()
signedIn["signedIn"]
// read profile data of signed in user
result = await RNBlockstackSdk.loadUserData()
did = result["decentralizedID"]
// put file, e.g. store unencrypted text in "text.txt"
content = "Hello React Native"
options = {encrypt: false}
result = await RNBlockstackSdk.putFile("text.txt", content, options)
fileUrl = result["fileUrl"]
// get file, e.g. read unencrypted text from "text.txt"
options = {decrypt:false}
result = await RNBlockstackSdk.getFile("text.txt", options)
fileContents = result["fileContents"]
FAQs
Blockstack SDK for use with React Native apps
We found that react-native-blockstack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.