Last encoding failure #728
Unanswered
brycefernandes
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Are you trying to implement a call out? |
Beta Was this translation helpful? Give feedback.
1 reply
-
As for your description above, it would be very helpful to explain what you are trying to do and the exact error you are getting. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi , I'm stuck at a place. I've tried looking for examples specific to js but no luck
Here is the code.
`const nats = require("nats");
const { encode, decode } = require("nats-jwt");
class AuthService {
constructor(issuerKeyPair, handler) {
this.issuerKeyPair = issuerKeyPair;
this.handler = handler;
}
async handle(request) {
try {
console.log("AuthService: Handling request", request.data.toString());
const rc = decode(request.data.toString());
if (!rc) {
throw new Error("Invalid authorization request");
}
console.log("AuthService: Decoded request:", JSON.stringify(rc, null, 2));
}
respond(request, userNKey, serverId, userJWT) {
console.log("AuthService: Constructing response...");
const rc = {
sub: userNKey,
aud: serverId,
jwt: userJWT,
};
}
async validateAndSign(claims) {
console.log(
"AuthService: Validating and signing claims:",
JSON.stringify(claims, null, 2),
);
return encode(claims, this.issuerKeyPair);
}
}
module.exports = AuthService;
`
I get an error on this line
return encode(claims, this.issuerKeyPair);
What are we supposed to do here? I'm sure there is a method, but I can figure it out.
Regards
Beta Was this translation helpful? Give feedback.
All reactions