Production-grade TypeScript SDK for the PIPELINK Solana infrastructure protocol.
✨ Fully Typed - Complete TypeScript support with strict type checking 🔐 Secure - Client-side message signing with wallet adapter support ⚡ Fast - Optimized HTTP client with built-in timeout handling 🧪 Well Tested - Comprehensive test coverage with Vitest 🌍 Isomorphic - Works in Node.js and browsers 📦 Tree-Shakable - ESM-only for optimal bundling 🔧 Production Ready - Enterprise-grade error handling and validation
npm install @pipelink/sdkimport { PipelinkClient } from '@pipelink/sdk';
const client = new PipelinkClient({
baseUrl: 'https://api.pipelink.xyz',
network: 'mainnet-beta',
timeout: 30000, // Optional, defaults to 30s
});import { signMessage } from '@pipelink/sdk';
// Using wallet adapter (e.g., Phantom, Solflare)
const signResult = await signMessage(walletAdapter, 'Hello, Solana!');
console.log({
address: signResult.address, // Wallet public key (base58)
message: signResult.message, // Original message
signature: signResult.signature, // Uint8Array signature
});// After getting signature from client, send to backend
const verified = await client.auth.verifySignature({
wallet: signResult.address,
message: signResult.message,
signature: Array.from(signResult.signature), // Convert to number[]
});
console.log(verified.verified); // true/falseconst balance = await client.wallet.getBalance('So1111111111111111111111111111111111111112');
console.log({
balance: balance.balance, // 10.5
unit: balance.unit, // "SOL"
});const pipeline = await client.pipeline.create({
name: 'My Pipeline',
description: 'Optional description',
// Additional custom fields supported
});
console.log({
pipelineId: pipeline.pipelineId, // "pipe_abc123"
status: pipeline.status, // "active"
});Main SDK client class.
new PipelinkClient(config: Partial<PipelinkConfig>)Config Properties:
baseUrl(required) - Backend API base URLnetwork(required) - Network type, currently only"mainnet-beta"timeout(optional) - Request timeout in ms, defaults to 30000fetch(optional) - Custom fetch implementation for testing
client.auth.signMessage(adapter, message)- Client-side message signingclient.auth.verifySignature(payload)- Backend signature verificationclient.wallet.getBalance(address)- Fetch wallet balanceclient.pipeline.create(config)- Create a new pipeline
The SDK provides structured error classes for better error handling:
import {
SDKError,
HTTPError,
NetworkError,
ValidationError,
TimeoutError,
} from '@pipelink/sdk';
try {
await client.wallet.getBalance(address);
} catch (error) {
if (error instanceof HTTPError) {
console.error(`HTTP ${error.status}: ${error.statusText}`);
console.error('Response data:', error.data);
} else if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof ValidationError) {
console.error('Invalid input:', error.message);
} else if (error instanceof TimeoutError) {
console.error(`Timeout after ${error.timeout}ms`);
}
}The SDK is fully testable by injecting a custom fetch implementation:
import { vi } from 'vitest';
import { PipelinkClient } from '@pipelink/sdk';
const mockFetch = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ balance: 10, unit: 'SOL' }), {
status: 200,
headers: { 'content-type': 'application/json' },
})
);
const client = new PipelinkClient({
baseUrl: 'https://api.test.com',
network: 'mainnet-beta',
fetch: mockFetch,
});
await client.wallet.getBalance('wallet123');
expect(mockFetch).toHaveBeenCalledWith(
'https://api.test.com/api/wallet/balance?address=wallet123',
expect.any(Object)
);All types are exported for use in your applications:
import {
PipelinkConfig,
WalletAdapter,
SignResult,
AuthPayload,
AuthResponse,
BalanceResponse,
CreatePipelineConfig,
PipelineResponse,
} from '@pipelink/sdk';The SDK expects the following backend endpoints:
Verifies a signed message.
Request:
{
"wallet": "11111111111111111111111111111111",
"message": "Hello, Solana!",
"signature": [1, 2, 3, ...]
}Response:
{
"verified": true
}Fetches wallet balance.
Response:
{
"balance": 10.5,
"unit": "SOL"
}Creates a new pipeline.
Request:
{
"name": "My Pipeline",
"description": "Optional",
...additional fields
}Response:
{
"pipelineId": "pipe_123",
"status": "active",
...additional fields
}Run the full test suite:
npm testWatch mode:
npm run devWith UI:
npm run test:uiCoverage report:
npm run test:coverageCompile TypeScript to JavaScript:
npm run buildThe compiled output will be in the dist/ directory with TypeScript declaration files.
npm version patch # or minor, major
npm run build
npm publishpipelink-sdk/
├── src/
│ ├── index.ts # Public API exports
│ ├── client.ts # Main SDK client
│ ├── config.ts # Configuration management
│ ├── auth/
│ │ ├── signer.ts # Client-side message signing
│ │ └── verify.ts # Backend signature verification
│ ├── wallet/
│ │ └── balance.ts # Wallet balance fetching
│ ├── pipeline/
│ │ └── create.ts # Pipeline creation
│ ├── types/
│ │ └── index.ts # TypeScript type definitions
│ ├── utils/
│ │ ├── http.ts # HTTP client with error handling
│ │ └── timeout.ts # Timeout utilities
│ └── errors/
│ └── sdk-error.ts # Error class hierarchy
├── tests/
│ ├── auth.test.ts
│ ├── wallet.test.ts
│ ├── pipeline.test.ts
│ ├── http.test.ts
│ └── client.test.ts
├── package.json
├── tsconfig.json
├── vitest.config.ts
└── README.md
MIT - See LICENSE file for details
For issues, questions, or contributions, please visit the PIPELINK GitHub repository.