cobo-api
v1.0.2
Published
A library for interacting with the Cobo API with Ed25519 signing
Maintainers
Readme
Cobo API Library
Biblioteca TypeScript para interagir com a API da Cobo, permitindo criar wallets, gerar endereços e realizar requisições seguras com assinatura Ed25519.
Instalação
npm install cobo-apiNota: O
api_secretdeve ser uma chave privada Ed25519 de 32 bytes (64 caracteres hexadecimais). Acesse a documentação da Cobo para maiores informações.
Uso
import CoboAPI from 'cobo-api';
import { CoboEnvironment, CoboWalletType, CoboWalletSubtype } from 'cobo-api/types';
const coboApi = new CoboAPI({
apiKey: 'sua_api_key',
apiSecret: 'sua_chave_privada_ed25519',
environment: CoboEnvironment.DEV // ou SANDBOX, PROD
});Criar uma Wallet
const wallet = await coboApi.createWallet({
name: 'Minha Wallet',
wallet_type: CoboWalletType.MPC,
wallet_subtype: CoboWalletSubtype.ORG_CONTROLLED,
vault_id: 'seu_vault_id'
});
console.log(wallet);Criar um Endereço
const addresses = await coboApi.createAddress(wallet.wallet_id, 'ETH', 1);
console.log(addresses);Ambientes Disponíveis
| Ambiente | URL Base |
|----------|----------|
| CoboEnvironment.DEV | https://api.dev.cobo.com/v2 |
| CoboEnvironment.SANDBOX | https://api.sandbox.cobo.com/v2 |
| CoboEnvironment.PROD | https://api.cobo.com/v2 |
Tipos de Wallet
CoboWalletType
| Tipo | Valor | Descrição |
|------|-------|-----------|
| CUSTODIAL | "Custodial" | Custodial Wallets |
| MPC | "MPC" | MPC Wallets |
| SMART_CONTRACT | "SmartContract" | Smart Contract Wallets |
| EXCHANGE | "Exchange" | Exchange Wallets |
CoboWalletSubtype
| Subtipo | Valor | Descrição |
|---------|-------|-----------|
| ASSET | "Asset" | Custodial Wallets (Asset Wallets) |
| WEB3 | "Web3" | Custodial Wallets (Web3 Wallets) |
| ORG_CONTROLLED | "Org-Controlled" | MPC Wallets (Organization-Controlled) |
| USER_CONTROLLED | "User-Controlled" | MPC Wallets (User-Controlled) |
| SAFE_WALLET | "Safe{Wallet}" | Smart Contract Wallets (Safe) |
| MAIN | "Main" | Exchange Wallets (Main Account) |
| SUB | "Sub" | Exchange Wallets (Sub Account) |
Métodos da API
| Método | Descrição |
|--------|-----------|
| createWallet(params: CreateWalletRequest) | Cria uma nova wallet com os parâmetros especificados |
| createAddress(walletId: string, chainId: string, count?: number) | Cria endereços para a wallet especificada |
Configuração
interface CoboAPIConfig {
apiKey: string; // Chave de API para autenticação
apiSecret: string; // Chave privada Ed25519 (seed de 32 bytes em hex)
environment: CoboEnvironment; // Ambiente da API
}Autenticação
Todas as requisições são automaticamente assinadas usando Ed25519. A biblioteca:
- Constrói a string de assinatura no formato:
method|path|nonce|queryString|body - Aplica duplo SHA256 hash
- Assina com a chave privada Ed25519
- Adiciona os headers
Biz-Api-Key,Biz-Api-NonceeBiz-Api-Signature
Licença
MIT License
Contribuições
Contribuições são bem-vindas! Abra uma issue ou envie um pull request.
