opt, err := nats.NkeyOptionFromSeed("seed.txt")
if err != nil {
log.Fatal(err)
}
nc, err := nats.Connect("localhost", opt)
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connection
NKey theNKey = NKey.createUser(null); // really should load from somewhere
Options options = new Options.Builder().
server("nats://localhost:4222").
authHandler(new AuthHandler(){
public char[] getID() {
try {
return theNKey.getPublicKey();
} catch (GeneralSecurityException|IOException|NullPointerException ex) {
return null;
}
}
public byte[] sign(byte[] nonce) {
try {
return theNKey.sign(nonce);
} catch (GeneralSecurityException|IOException|NullPointerException ex) {
return null;
}
}
public char[] getJWT() {
return null;
}
}).
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();
let nc = NATS.connect({
url: server.nats,
nkey: uPub,
sigCB: function (nonce) {
const sk = nkeys.fromSeed(Buffer.from(uSeed));
return sk.sign(nonce);
}
});
let nc = await connect({
url: server.nats,
nkey: uPub,
nonceSigner: function (nonce) {
const sk = fromSeed(Buffer.from(uSeed));
return sk.sign(Buffer.from(nonce));
}
});