Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@elabox/hive-js-sdk
Advanced tools
Readme
Elastos Hive is an essential service infrastructure as a decentralized network of Hive nodes presenting data storage capabilities to dApps. And the JS SDK provides a group of APIs for Elastos dApps to easily access and store application data to remote Vault services on Hive nodes with the following features:
Elastos Hive will keep the promise that users remain in full control of their own data and committing the practice on it.
To add the Hive JS SDK dependency to your project, run the following command from your source folder:
npm i --save @elastosfoundation/hive-js-sdk
Preparing with the developer tool git, and then run the following commands to clone the source:
git clone https://github.com/elastos/Elastos.NET.Hive.JS.SDK
cd Elastos.NET.Hive.JS.SDK
npm install
npm run types
npm run build
Before running tests, the local user directory must be defined with the following command:
export HIVE_USER_DIR=/path/to/user/dir
Then, modify the "provider" field tests/src/res/custom.json to point to your own local hive node.
From the source folder, build the project, then run the following commands:
cd tests
npm run clean
npm install
npm run test:node
From the source folder, build the project, then run the following commands:
cd tests
npm run clean
npm install
npm run test:browser
The test context is based on the TestData class located in /tests/src/config/testdata.ts
. The creation of this class will create the test context and set the user directory. The class should be created before each test using the following code:
testData = await TestData.getInstance("TEST SUITE NAME", CONFIGURATION, "OPTIONAL USER DIRECTORY");
Example:
testData = await TestData.getInstance("My service tests", ClientConfig.LOCAL);
Note: The optional third parameter of the TestData.getInstance method is the user directory which defaults to the path defined by the HIVE_USER_DIR environment variable (See Test configuration. You may also specify a custom folder, but it's recommended to only use this parameter on a local workstation for validation.
import {
VaultSubscriptionService,
PricingPlan,
} from "@elastosfoundation/hive-js-sdk";
import { ClientConfig } from "../config/clientconfig";
import { TestData } from "../config/testdata";
describe("pricing plans", () => {
let testData: TestData;
let vaultSubscriptionService: VaultSubscriptionService;
beforeEach(async () => {
testData = await TestData.getInstance(
"pricingplans.test",
ClientConfig.TESTNET
);
vaultsubscriptionService = new VaultSubscriptionService(
testData.getAppContext(),
testData.getProviderAddress()
);
});
test("get vault pricing plans", async () => {
let plans: PricingPlan[] =
await vaultsubscriptionService.getPricingPlanList();
expect(plans).not.toBeNull();
expect(plans.length).toBeGreaterThan(0);
});
});
In order to subscribe to a vault (create) a user needs to implement AppContextProvider
export class ApiServiceContextProvider implements AppContextProvider {
getLocalDataDir = () : string => {
...
};
getAppInstanceDocument = async () : Promise<DIDDocument> => {
...
};
getAuthorization = async (authenticationChallengeJWtCode: string): Promise<string> => {
...
}
}
let vaultSubscriptionService : VaultSubscription = new VaultSubscription(appContext, "[hiveNode address]");
let vaultInfo = await vaultSubscriptionService.subscribe();
The same mechanics is used by VaultService, which provides all services to interact with hive vault
let vaultServices = new Vault(appContext, "[hiveNode address]");
let scriptingService = vaultServices.getScriptingService();
let filesService = vaultServices.getFilesService();
let databaseService = vaultServices.getDatabaseService();
...
FAQs
Elastos Hive JS SDK
The npm package @elabox/hive-js-sdk receives a total of 30 weekly downloads. As such, @elabox/hive-js-sdk popularity was classified as not popular.
We found that @elabox/hive-js-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.