Annotate

teal-src/util/jwt.d.tl @ 12943:297b4cfcc3d9

util.jsonschema: Ignore some new tests in test suite These seem to be using absolute URI references, Not Yet Implemented
author Kim Alvefur <zash@zash.se>
date Sat, 11 Mar 2023 12:01:17 +0100
parent 12929:245ffbb06f55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12929
245ffbb06f55 util.jwt: Import definition of key from util.crypto
Kim Alvefur <zash@zash.se>
parents: 12928
diff changeset
1 local crypto = require "util.crypto"
12926
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local record jwtlib
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 enum algorithm
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 "HS256"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 "HS384"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 "HS512"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 "ES256"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 "ES512"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 "RS256"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 "RS384"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 "RS512"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 "PS256"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 "PS384"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 "PS512"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 end
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 type payload = { string : any }
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 type signer_t = function (payload : payload) : string
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 type verifier_t = function (token : string) : payload
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 enum key_type
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 "rsaEncryption"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 "id-ecPublicKey"
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 record algorithm_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 sign : signer_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 verify : verifier_t
12929
245ffbb06f55 util.jwt: Import definition of key from util.crypto
Kim Alvefur <zash@zash.se>
parents: 12928
diff changeset
26 load_key : function (key : string) : crypto.key
12926
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 end
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 init : function (algorithm, private_key : string, public_key : string, table) : signer_t, verifier_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 new_signer : function (algorithm, string, table) : signer_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 new_verifier : function (algorithm, string, table) : verifier_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 _algorithms : {
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 algorithm : algorithm_t
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 }
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 -- Deprecated
12928
916af6fcef1e util.jwt: Fixup argument and type order
Kim Alvefur <zash@zash.se>
parents: 12926
diff changeset
35 sign : function (private_key : string, payload) : string
12926
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 verify : function (string) : payload
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 end
f9e474cb86ac util.jwt: Document interface as Teal definition file
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 return jwtlib