Registry / messaging / ensync-client-sdk

ensync-client-sdk

JSON →
library0.2.2jsnpmunverified

EnSync gRPC Client SDK (v0.2.2) is a high-performance, message-driven communication library for Node.js, enabling server-to-server messaging via HTTP/2 and Protocol Buffers. It features end-to-end encryption (Ed25519/hybrid), JSON validation, message lifecycle management (publish, subscribe, acknowledge, defer, discard, replay), flow control, and auto-reconnection. Developed by EnSync, it targets real-time event-driven architectures and integrates with the EnSync engine. The package is actively maintained and ships TypeScript definitions.

npm install ensync-client-sdk
INSTALL
IMPORT
SIG · ENSYNC-CLIENT-SDK
E
ensync-client-sdk
messagingjavascriptv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EnSyncEngine
import { EnSyncEngine } from 'ensync-client-sdk'
import EnSyncEngine from 'ensync-client-sdk'
Named export only; no default import available. Use destructured import.
EnSyncClient
import { EnSyncClient } from 'ensync-client-sdk'
import { Client } from 'ensync-client-sdk'
EnSyncClient is the return type of createClient. Import as named export.
Message
import { Message } from 'ensync-client-sdk'
import { Event } from 'ensync-client-sdk'
Message is the type for received messages; not 'Event'.

Creates an EnSync client, publishes a message to 'orders/created', subscribes to the same topic, and acknowledges received messages.

const { EnSyncEngine } = require('ensync-client-sdk'); async function main() { const engine = new EnSyncEngine('grpcs://node.gms.ensync.cloud'); const client = await engine.createClient(process.env.APP_KEY ?? '', { appSecretKey: process.env.APP_SECRET ?? '' }); await client.publish( 'orders/created', ['recipient-key'], { orderId: '123', amount: 99.99 }, { persist: true } ); const subscription = await client.subscribe('orders/created'); subscription.on(async (message) => { console.log('Received:', message.payload); await subscription.ack(message.idem, message.block); }); } main().catch(console.error);
Debug
Known issues
breakingConstructor now requires a URL with 'grpcs://' prefix (TLS) or 'grpc://' (plaintext); omitting prefix crashes.
fix
Always include 'grpcs://' or 'grpc://' in the endpoint URL.
affects: >=0.2.0
gotchacreateClient() expects 'appSecretKey' inside an object, not a string; passing a string directly throws.
fix
pass { appSecretKey: '...' } as second argument.
affects: >=0.1.0
gotchasubscribe() returns a subscription object with an 'on' method; not a callback directly.
fix
use await client.subscribe(topic).on(handler);
affects: >=0.1.0
deprecatedThe 'ack' method now requires both 'idem' and 'block' parameters; single-argument ack is deprecated.
fix
call subscription.ack(message.idem, message.block);
affects: >=0.2.0
Errors
Common errors & fixes
TypeError: EnSyncEngine is not a constructor
Trying to instantiate with a default import instead of named import.
fix
Use `const { EnSyncEngine } = require('ensync-client-sdk');`
Error: Invalid app secret key
Second argument to createClient() should be an object with appSecretKey property.
fix
`engine.createClient('app-key', { appSecretKey: 'secret' })`
TypeError: subscription.on is not a function
subscribe() returns a subscription object, not a stream. Use .on() method.
fix
`const sub = await client.subscribe('topic'); sub.on(handler);`
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredgRPC client implementation for HTTP/2 and Protocol Buffers
Agent activity
22 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
ensync-client-sdk — npm install ensync-client-sdk · libregistry