The `salesforce-pubsub-api-client` is a Node.js client library for interacting with the Salesforce Pub/Sub API, a gRPC-based event streaming service. Currently at stable version 5.5.2, it is actively maintained with frequent minor and patch releases, addressing bug fixes, dependency updates, and feature enhancements. The client abstracts the complexities of gRPC communication, offering multiple authentication flows (username/password, JWT bearer, client credentials), schema management for event data, and features like batch publishing and robust subscription management with replay IDs and flow control. A key differentiator in version 5 is its shift from an `EventEmitter`-based event handling model to a synchronous callback system, ensuring ordered event processing, and a simplified configuration approach via constructor options.
npm install salesforce-pubsub-api-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to connect to the Salesforce Pub/Sub API, authenticate using username/password flow, and subscribe to a platform event topic using the v5 synchronous callback model.
Migrate your configuration from `.env` variables to a configuration object passed directly to the `PubSubApiClient` constructor. Use the unified `await client.connect()` method.
Replace `eventEmitter.on('data', ...)` logic with a single `SubscribeCallback` function passed as the second argument to `client.subscribe(topic, subscribeCallback)`.Upgrade to v5.3.0 or newer. If stuck on an older version, ensure your private key file includes the `BEGIN RSA PRIVATE KEY` and `END RSA PRIVATE KEY` headers.
Ensure your Node.js runtime is updated to version 22 or newer for full compatibility. Review your application's certificate management if you had custom `certifi` configurations.
Upgrade to `salesforce-pubsub-api-client@5.5.1` or newer to resolve `nodeNext` module type resolution issues.
Ensure you pass a complete `Configuration` object to the `PubSubApiClient` constructor, including `instanceUrl` and a valid `auth` object with the chosen authentication flow details. Consult the README's 'Configuration' section.
Refactor your event handling code to use the new synchronous callback function, which is passed directly as the second argument to the `client.subscribe()` method.
Verify all authentication credentials (client ID, client secret, username, password) and the `instanceUrl` in your `Configuration` object. Confirm that your Salesforce connected app has the necessary OAuth scopes and permissions.
No dependency data recorded yet.