pilcrowOnPaper/oslo

Create key from string

Closed this issue · 4 comments

Is there a way to create a key from a random string for signing and verifying jwts using oslo?
If not, how to do it?

My goal is to be able to specify a secret as an env variable that is used for handling jwts.

It was too early in the morning...

@david-plugge did you solve this? how did you that?

Simply use TextEncoder

const JWT_KEY = new TextEncoder().encode(env.MAGIC_LINK_TOKEN_SECRET);

await createJWT(
	algorithm,
	JWT_KEY,
	{},
	{
		subject: email,
		expiresIn: new TimeSpan(10, 'm')
	}
);

Yes silly me, thanks :)