@avarok/citadel-protocol-types
v0.14.1
Published
TypeScript type definitions for the Citadel Protocol, automatically generated from Rust types
Downloads
2,255
Maintainers
Readme
@avarok/citadel-protocol-types
TypeScript type definitions for the Citadel Protocol, automatically generated from Rust types.
Installation
npm install @avarok/citadel-protocol-typesVersion Functions
Get the protocol and SDK versions programmatically:
import { protocol_version, sdk_version } from '@avarok/citadel-protocol-types';
console.log(`Protocol version: ${protocol_version()}`); // e.g., "0.9.0"
console.log(`SDK version: ${sdk_version()}`); // e.g., "0.14.0"Usage
import {
ConnectMode,
SecurityLevel,
UserIdentifier,
MutualPeer,
CryptoParameters,
ClientConnectionType,
PeerConnectionType,
VirtualConnectionType,
Error as CitadelError
} from '@avarok/citadel-protocol-types';
// Use the types in your TypeScript code
const peer: MutualPeer = {
parent_icid: 12345n,
cid: 67890n,
username: "alice"
};
const securityLevel: SecurityLevel = "High";
// Connection types for C2S and P2P connections
const c2sConnection: ClientConnectionType = {
Server: { session_cid: 12345n }
};
const p2pConnection: PeerConnectionType = {
LocalGroupPeer: { session_cid: 12345n, peer_cid: 67890n }
};Available Types
Version Functions
protocol_version()- Returns the Citadel Protocol versionsdk_version()- Returns the Citadel SDK version
User Types
MutualPeerPeerInfoUserIdentifier
Connection Types
ClientConnectionType- C2S connection variants (Server, Extended)PeerConnectionType- P2P connection variants (LocalGroupPeer, ExternalGroupPeer)VirtualConnectionType- Unified connection type for routing
Protocol Types
ConnectModeVirtualObjectMetadataObjectIdObjectTransferOrientationObjectTransferStatusSessionSecuritySettingsUdpModeMemberStateGroupMemberAlterModeMessageGroupOptionsGroupTypeMessageGroupKeyTransferType
Crypto Types
CryptoParametersEncryptionAlgorithmSecrecyModeKemAlgorithmSigAlgorithmSecurityLevelHeaderObfuscatorSettingsPreSharedKey
Error Types
Error- The main error type for the Citadel Protocol
Regenerating Types
To regenerate the TypeScript types from the Rust source:
cd ../citadel_types
cargo run --bin export_ts --features typescriptThen rebuild the TypeScript library:
npm run buildLinks
License
MIT OR Apache-2.0
