equal
deleted
inserted
replaced
|
1 local crypto = require "prosody.util.crypto" |
|
2 local record jwtlib |
|
3 enum algorithm |
|
4 "HS256" |
|
5 "HS384" |
|
6 "HS512" |
|
7 "ES256" |
|
8 "ES512" |
|
9 "RS256" |
|
10 "RS384" |
|
11 "RS512" |
|
12 "PS256" |
|
13 "PS384" |
|
14 "PS512" |
|
15 end |
|
16 type payload = { string : any } |
|
17 type signer_t = function (payload : payload) : string |
|
18 type verifier_t = function (token : string) : payload |
|
19 enum key_type |
|
20 "rsaEncryption" |
|
21 "id-ecPublicKey" |
|
22 end |
|
23 record algorithm_t |
|
24 sign : signer_t |
|
25 verify : verifier_t |
|
26 load_key : function (key : string) : crypto.key |
|
27 end |
|
28 init : function (algorithm, private_key : string, public_key : string, table) : signer_t, verifier_t |
|
29 new_signer : function (algorithm, string, table) : signer_t |
|
30 new_verifier : function (algorithm, string, table) : verifier_t |
|
31 _algorithms : { |
|
32 algorithm : algorithm_t |
|
33 } |
|
34 -- Deprecated |
|
35 sign : function (private_key : string, payload) : string |
|
36 verify : function (string) : payload |
|
37 end |
|
38 return jwtlib |