MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / create_jwt_module

Function create_jwt_module

aiscript-vm/src/stdlib/auth/jwt.rs:39–60  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

37}
38
39pub fn create_jwt_module(ctx: Context) -> ModuleKind {
40 let name = ctx.intern(b"std.auth.jwt");
41 let exports = [
42 ("encode", Value::NativeFunction(NativeFn(jwt_encode))),
43 ("decode", Value::NativeFunction(NativeFn(jwt_decode))),
44 (
45 "create_access_token",
46 Value::NativeFunction(NativeFn(create_access_token)),
47 ),
48 ("HS256", Value::String(ctx.intern(b"HS256"))),
49 ("HS384", Value::String(ctx.intern(b"HS384"))),
50 ("HS512", Value::String(ctx.intern(b"HS512"))),
51 ("RS256", Value::String(ctx.intern(b"RS256"))),
52 ("RS384", Value::String(ctx.intern(b"RS384"))),
53 ("RS512", Value::String(ctx.intern(b"RS512"))),
54 ]
55 .into_iter()
56 .map(|(name, f)| (ctx.intern_static(name), f))
57 .collect();
58
59 ModuleKind::Native { name, exports }
60}
61
62fn parse_algorithm(alg: &str) -> Result<Algorithm, VmError> {
63 match alg {

Callers 1

init_stdlibMethod · 0.85

Calls 3

NativeFnClass · 0.85
internMethod · 0.45
intern_staticMethod · 0.45

Tested by

no test coverage detected