aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-07-11 13:43:01 +0100
committerMatthew Wild <mwild1@gmail.com>2022-07-11 13:43:01 +0100
commitff54cc5bcfd5fc9ec23f8d974f0c46363f9bb35a (patch)
tree6870fd61ef40dfeca793119421b21719a09be147 /util
parentd2ede10c5d4ed029731f2b431aea3b35da2dd999 (diff)
downloadprosody-ff54cc5bcfd5fc9ec23f8d974f0c46363f9bb35a.tar.gz
prosody-ff54cc5bcfd5fc9ec23f8d974f0c46363f9bb35a.zip
util.jwt: Add new init() convenience method to obtain both signer and verifier
Diffstat (limited to 'util')
-rw-r--r--util/jwt.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/util/jwt.lua b/util/jwt.lua
index 53825236..5c74850a 100644
--- a/util/jwt.lua
+++ b/util/jwt.lua
@@ -197,9 +197,15 @@ local function new_verifier(algorithm, key_input, options)
end
end
+local function init(algorithm, private_key, public_key, options)
+ return new_signer(algorithm, private_key, options), new_verifier(algorithm, public_key or private_key, options);
+end
+
return {
+ init = init;
new_signer = new_signer;
new_verifier = new_verifier;
+ -- Exported mainly for tests
_algorithms = algorithms;
-- Deprecated
sign = algorithms.HS256.sign;