Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bandada/api-sdk

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bandada/api-sdk

A Typescript SDK for the Bandada API.

  • 2.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by9.09%
Maintainers
0
Weekly downloads
 
Created
Source

Bandada API SDK

A Typescript SDK for the Bandada API.

Github license NPM version Downloads Linter eslint Code style prettier

👥 Contributing   |   🤝 Code of conduct   |   🔎 Issues   |   🗣️ Chat & Support
This package provides a list of functions to make it easier to work with the Bandada API.

🛠 Install

npm or yarn

Install the @bandada/api-sdk package with npm:

npm i @bandada/api-sdk

or yarn:

yarn add @bandada/api-sdk

📜 Usage

Create a new instance

# new ApiSdk(url: SupportedUrl | string, config?: object): ApiSdk

Creates a new instance of ApiSdk using the API URL and the config.

  • Create a new instance using the Bandada API URL and the default config.

This is what you need if you are using the production Bandada API.

import { ApiSdk } from "@bandada/api-sdk"

const apiSdk = new ApiSdk()

This is useful when working with the development environment.

import { ApiSdk, SupportedUrl } from "@bandada/api-sdk"

const apiSdk = new ApiSdk(SupportedUrl.DEV)
  • Create a new instance using a custom API URL.
import { ApiSdk } from "@bandada/api-sdk"

const apiSdk = new ApiSdk("https://example.com/api")
  • Create a new instance using a custom API URL and config.
import { ApiSdk } from "@bandada/api-sdk"

const url = "https://example.com/api"
const config = {
    headers: {
        "Content-Type": "text/html"
    }
}
const apiSdk = new ApiSdk(url, config)

Create group

# createGroup(): Promise<Group>

Creates a Bandada group.

const groupCreateDetails = {
    name: "Group 1",
    description: "This is Group 1.",
    treeDepth: 16,
    fingerprintDuration: 3600
}
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const group = await apiSdk.createGroup(groupCreateDetails, apiKey)

Create a credential group

# createGroup(): Promise<Group>

Creates a Bandada credential group.

const credentials = {
    id: "BLOCKCHAIN_BALANCE",
    criteria: {
        minBalance: "10",
        network: "Sepolia"
    }
}

const groupCreateDetails = {
    name: "Group 1",
    description: "This is Group 1.",
    treeDepth: 16,
    fingerprintDuration: 3600,
    credentials
}
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const group = await apiSdk.createGroup(groupCreateDetails, apiKey)

Create a multiple credentials group

# createGroup(): Promise<Group>

Creates a Bandada multiple credential group.

const credentials = {
    credentials: [
        {
            id: "BLOCKCHAIN_TRANSACTIONS",
            criteria: {
                minTransactions: 10,
                network: "Sepolia"
            }
        },
        {
            id: "BLOCKCHAIN_BALANCE",
            criteria: {
                minBalance: "5",
                network: "Sepolia"
            }
        }
    ],
    expression: ["", "and", ""]
}

const groupCreateDetails = {
    name: "Group 1",
    description: "This is Group 1.",
    treeDepth: 16,
    fingerprintDuration: 3600,
    credentials
}
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const group = await apiSdk.createGroup(groupCreateDetails, apiKey)

Create groups

# createGroups(): Promise<Group[]>

Creates one or many Bandada groups.

const groupsCreateDetails = [
    {
        name: "Group 1",
        description: "This is Group 1.",
        treeDepth: 16,
        fingerprintDuration: 3600
    },
    {
        name: "Group 2",
        description: "This is Group 2.",
        treeDepth: 16,
        fingerprintDuration: 3600
    }
]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const groups = await apiSdk.createGroups(groupsCreateDetails, apiKey)

Remove group

# removeGroup(): Promise<void>

Removes a specific Bandada group.

const groupId = "10402173435763029700781503965100"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeGroup(groupId, apiKey)

Remove groups

# removeGroups(): Promise<void>

Removes one or many Bandada groups.

const groupIds = [
    "10402173435763029700781503965100",
    "20402173435763029700781503965200"
]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeGroups(groupIds, apiKey)

Update group

# updateGroup(): Promise<Group>

Updates a specific Bandada group.

const groupId = "10402173435763029700781503965100"
const groupUpdateDetails = {
    description: "This is a new group.",
    treeDepth: 20,
    fingerprintDuration: 4000
}
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.updateGroup(groupId, groupUpdateDetails, apiKey)

Update groups

# updateGroups(): Promise<Group[]>

Updates one or many Bandada groups.

const groupIds = [
    "10402173435763029700781503965100",
    "20402173435763029700781503965200"
]
const updatedGroups: Array<GroupUpdateDetails> = [
    {
        description: "This is a new group1.",
        treeDepth: 32,
        fingerprintDuration: 7200
    },
    {
        description: "This is a new group2.",
        treeDepth: 32,
        fingerprintDuration: 7200
    }
]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.updateGroups(groupId, groupUpdateDetails, apiKey)

Get group

# getGroup(): Promise<Group>

Returns a specific group.

const groupId = "10402173435763029700781503965100"

const group = await apiSdk.getGroup(groupId)

Get groups

# getGroups(): Promise<Group[]>

Returns the list of groups.

const groups = await apiSdk.getGroups()

Get groups by admin id

# getGroupsByAdminId(): Promise<Group[]>

Returns the list of groups by admin id.

const adminId =
    "0xdf558148e66850ac48dbe2c8119b0eefa7d08bfd19c997c90a142eb97916b847"
const groups = await apiSdk.getGroupsByAdminId(adminId)

Get groups by member id

# getGroupsByMemberId(): Promise<Group[]>

Returns the list of groups by member id.

const memberId = "1"
const groups = await apiSdk.getGroupsByMemberId(memberId)

Is group member

# isGroupMember(): Promise<boolean>

Returns true if the member is in the group and false otherwise.

const groupId = "10402173435763029700781503965100"
const memberId = "1"

const isMember = await apiSdk.isGroupMember(groupId, memberId)

Generate merkle proof

# generateMerkleProof(): Promise<string>

Returns the Merkle Proof for a member in a group.

const groupId = "10402173435763029700781503965100"
const memberId = "1"

const proof = await apiSdk.generateMerkleProof(groupId, memberId)

Add member using an API Key

# addMemberByApiKey(): Promise<void>

Adds a member to a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.addMemberByApiKey(groupId, memberId, apiKey)

Add members using an API Key

# addMembersByApiKey(): Promise<void>

Adds multiple members to a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberIds = ["1", "2", "3"]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.addMembersByApiKey(groupId, memberIds, apiKey)

Add member using an invite code

# addMemberByInviteCode(): Promise<void>

Adds a member to a group using an Invite Code.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const inviteCode = "MQYS4UR5"

await apiSdk.addMemberByInviteCode(groupId, memberId, inviteCode)

Remove member using an API Key

# removeMemberByApiKey(): Promise<void>

Removes a member from a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberId = "1"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeMemberByApiKey(groupId, memberId, apiKey)

Remove members using an API Key

# removeMembersByApiKey(): Promise<void>

Removes multiple members from a group using an API Key.

const groupId = "10402173435763029700781503965100"
const memberIds = ["1", "2", "3"]
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

await apiSdk.removeMembersByApiKey(groupId, memberIds, apiKey)

Create invite

# createInvite(): Promise<Invite>

Creates a new group invite.

const groupId = "10402173435763029700781503965100"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const invite = await apiSdk.createInvite(groupId, apiKey)

Get invite

# getInvite(): Promise<Invite>

Returns a specific invite.

const inviteCode = "C5VAG4HD"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const invite = await apiSdk.getInvite(inviteCode)

Redeem invite

# redeemInvite(): Promise<Invite>

Redeems a specific invite.

const groupId = "10402173435763029700781503965100"
const inviteCode = "C5VAG4HD"
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc"

const invite = await apiSdk.redeemInvite(inviteCode, groupId, apiKey)

Get credential group join URL

# getCredentialGroupJoinUrl(): string

Returns a custom URL string for joining a credential group.

import { DashboardUrl } from "@bandada/api-sdk"

const dashboardUrl = DashboardUrl.DEV
const groupId = "10402173435763029700781503965100"
const commitment = "1"
const providerName = "github"
const redirectUri = "http://localhost:3003"

const url = apiSdk.getCredentialGroupJoinUrl(
    dashboardUrl,
    groupId,
    commitment,
    providerName,
    redirectUri
)

Get multiple credentials group join URL

# getMultipleCredentialGroupJoinUrl(): string

Returns a custom URL string for joining a multiple credentials group.

import { DashboardUrl } from "@bandada/api-sdk"

const dashboardUrl = DashboardUrl.DEV
const groupId = "10402173435763029700781503965100"
const commitment = "1"

const url = apiSdk.getMultipleCredentialsGroupJoinUrl(
    dashboardUrl,
    groupId,
    commitment
)

FAQs

Package last updated on 05 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc