diff --git a/spawnpoint.nats.js b/spawnpoint.nats.js index c49cc48..de6ee7e 100644 --- a/spawnpoint.nats.js +++ b/spawnpoint.nats.js @@ -54,6 +54,17 @@ module.exports = require('spawnpoint').registerPlugin({ config.connection.name += ` node@${process.version}`; } + // Setup an authenticator if available + if(config.connection.auth) { + // We want to read in the creds file given to us + const authCredsFile = path.join(app.cwd, config.connection.auth.creds_file); + delete config.connection.auth.creds_file; + const authCreds = fs.readFileSync(authCredsFile); + // Create a new credsAuthenticator + config.connection.authenticator = nats.credsAuthenticator(authCreds); + delete config.connection.auth; + } + const helpers = { wrapMessageError(error) { if(error?.code === nats.ErrorCode.NoResponders) {