(ctx: Context)
| 37 | } |
| 38 | |
| 39 | pub 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 | |
| 62 | fn parse_algorithm(alg: &str) -> Result<Algorithm, VmError> { |
| 63 | match alg { |
no test coverage detected