Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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.
sudo gem install cocoapods
pod init
Podfile
, add the following lines:
use_frameworks!
pod 'Blockstack'
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # Needed for debugging
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
# Third party deps podspec link
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'
pod install
[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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.