@byzantine/integrator-sdk
v1.0.1
Published
The Byzantine Integrator SDK is a library for building applications on Byzantine Finance
Readme
Byzantine Integrator SDK
The Byzantine Integrator SDK is a TypeScript library for interacting with the Byzantine Finance API.
Installation
npm install @byzantine/integrator-sdkQuick Start
Setup
Create a .env file in your project root with the following variables:
INTEGRATOR_PRIVATE_KEY=<your-integrator-private-key>Initialize the Client
import { ByzantineClient } from '@byzantine/integrator-sdk';
import dotenv from "dotenv";
dotenv.config();
const client = new ByzantineClient({
// Optional: only required for API key authentication
integratorPrivateKey: process.env.INTEGRATOR_PRIVATE_KEY,
// Optional: only required for WebAuthn authentication
webauthn: {
rpId: 'example.com', // or 'localhost' for local development
rpName: 'Example Corp',
}
});Usage
Using webAuthn Authentication for user's transaction signing
Generate the WebAuthn Stamper to authenticate users with passkeys:
const payload = {
// Your request payload
};
// Generate the WebAuthn stamp for the payload
const stamp = await client.webauthn.getStamp(payload);
// Use it to call the sendTransactionPasskey method
const response = await client.api.sendTransactionPasskey(chainId, {
signedBody: payload,
transactionId: 'transaction-id',
webAuthnStamp: stamp.stampHeaderValue,
});Using Integrator API Key Authentication
const body = {
// Your request payload
};
// Generate authentication stamp for this specific request
const stamp = await client.apiKey.getStamp(
'POST',
'/v1/submit/create-user',
JSON.stringify(body)
);
// Set the integrator authentication headers
client.api.setIntegratorAuth(
stamp['X-Pubkey'],
stamp['X-Timestamp'],
stamp['X-Signature']
);
const response = await client.api.createUser(body);Browser Support
- API Key Stamper: Works in Node.js and modern browsers
- WebAuthn Stamper: Requires browser support for WebAuthn API
License
Apache-2.0
