php-jwt icon indicating copy to clipboard operation
php-jwt copied to clipboard

feat: Allows Key instance to be used for encoding

Open Oinkling opened this issue 1 year ago • 0 comments

Allows an instance of Key to be passed as the second argument to JWT::encode and JWT::sign, making $alg optional.

This is more in line with how decoding works and as such it makes sense to streamline it.

This also generally makes the process easier in the use case where you get an instance of Key injected so you can just encode using JWT::encode($payload, $key) rather than JWT::encode($payload, $key->getKeyMaterial(), $key->getAlgorithm())

Oinkling avatar Aug 08 '24 09:08 Oinkling