oci-js-sdk v1.6.4
OCI JS SDK
OCI JS SDK is a JavaScript/TypeScript SDK designed for seamless interaction with the OCI platform. It enables developers to manage attestations, permissions, and encrypted on-chain data efficiently, facilitating integration with various blockchain protocols and services.
Features
- Retrieve user attestations by wallet address
- Manage attestations with custom permissions
- Connect to on-chain services for verification and decryption
- Support for multiple providers (e.g., Discord, Google)
Installation
Install the OCI JS SDK using your preferred package manager:
# Using pnpm
pnpm add oci-js-sdk
# Using npm
npm install oci-js-sdk
# Using yarn
yarn add oci-js-sdk
Usage
Initialization
Begin by importing and configuring the OciClient
with your network details, including chainId
, appPrivateKey
, and an optional rpcUrl
:
import OciClient from "oci-js-sdk";
const ociClient = new OciClient({
chainId: 11155111, // Replace with your chain ID
appPrivateKey: "0xYOUR_PRIVATE_KEY", // Optional
rpcUrl: "https://your-rpc-url", // Optional
});
Fetch User Profiles
To fetch user profiles, provide a provider type (e.g., discord
, google
, address
) and the corresponding account ID. This method retrieves decrypted data for each attestation where permissions allow:
async function fetchUserProfiles() {
try {
const userProfiles = await ociClient.getUserProfiles(
"discord",
"your-discord-id"
);
} catch (error) {
console.error("Error fetching user profiles:", error);
}
}
fetchUserProfiles();
Fetch Attestations by Wallet Address
Retrieve attestations for a given wallet address without decrypting the data. This method returns the attestation ID and provider:
async function fetchAttestations() {
try {
const attestations = await ociClient.getUserProfileWithAppPermissions(
"0xYourWalletAddress",
"0xDeveloperPublicAddress"
);
} catch (error) {
console.error("Error fetching attestations:", error);
}
}
fetchAttestations();
API Documentation
Generate full API documentation using typedoc
:
pnpm run doc
The documentation will be generated in the docs
folder.
Scripts
- build: Compiles the TypeScript code into JavaScript.
- start: Runs the compiled SDK.
- dev: Runs the SDK in development mode with live reload.
- test: Executes tests using Jest.
- doc: Generates API documentation with Typedoc.
- lint: Runs Biome (ESLint alternative) checks.
- lint:fix: Automatically fixes lint issues.
- format: Formats the code using Biome.
- prepare: Sets up Git hooks using Husky.
Testing
To run tests, use the following command:
pnpm run test
Contributing
Contributions are welcome! To get started:
- Fork the repository.
- Clone your forked repository.
- Make your changes.
- Submit a pull request.
License
This project is licensed under the GNU Affero General Public License (AGPL) v3. See the LICENSE file for more details.
8 months ago
6 months ago
7 months ago
8 months ago
6 months ago
7 months ago
7 months ago
8 months ago
6 months ago
7 months ago
7 months ago
8 months ago
6 months ago
7 months ago
8 months ago
8 months ago
7 months ago
7 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago