allostasis-js-sdk
v1.3.21
Published
Allostasis data management
Readme
Allostasis JS SDK
This SDK is for Allostasis community profile management.
Usage
Initialize
First step is to create an instance of the SDK.
import Allostasis from 'allostasis-js-sdk';
const allostasis = new Allostasis(community, options)ConstructionOptions = {
nodeURL: URL of the node,
provider?: Like MetaMask,
chain?: {
name: Name of the chain,
id: ID of the chain
},
infura: {
url: infura URL,
projectId: infura project ID,
apiKey: Infura API key
}
}Connect to Ceramic and Lit
Using the connect method of the SDK, you can connect the user to specified network.
allostasis.connect().then({ did, address } => {
// connected successfully
}).catch(error => {
// error happened
})Check Connection
Use isConnected to check the status of connection to ceramic.
allostasis.isConnected().then({ did, address } => {
// is connected
}).catch(error => {
// is not connected or error happened
})Disconnect
To log the user out of the network, use disconnect method.
allostasis.disconnect().then(response => {
// disconnected
}).catch(error => {
// error happened
})Create / Update Profile
To update existing user profile or create new one, use as below:
allostasis.createOrUpdateProfile(RequestParams).then(response => {
// created or updated
}).catch(error => {
// error happened
})RequestParams is an object:
Get Profile
To get user's profile, use getProfile method.
allostasis.getProfile().then(response => {
// profile data
}).catch(error => {
// error happened
})Get Specific User's Profile
To get user's profile by ID, use getUserProfile method.
allostasis.getUserProfile(profileID).then(response => {
// profile data
}).catch(error => {
// error happened
})Get Specific User's Community Profile
To get user's community profile by ID, use getCommunityUserProfile method.
allostasis.getCommunityUserProfile(communityProfileID).then(response => {
// community profile data
}).catch(error => {
// error happened
})Development
This is an NPM package, after each commit, change the version number inside package.json and then run the following commands:
npm run buildnpm publish
Note: You need to be logged in to your NPM account using npm cli.
