MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / is_valid_code

Function is_valid_code

crates/openshell-server/src/auth/http.rs:35–45  ·  view source on GitHub ↗

Validate that a confirmation code matches the CLI-generated format. Codes are 3 alphanumeric characters, a dash, then 4 alphanumeric characters (e.g., "AB7-X9KM"). The CLI generates these from the charset `[A-Z2-9]`.

(code: &str)

Source from the content-addressed store, hash-verified

33/// Codes are 3 alphanumeric characters, a dash, then 4 alphanumeric characters
34/// (e.g., "AB7-X9KM"). The CLI generates these from the charset `[A-Z2-9]`.
35fn is_valid_code(code: &str) -> bool {
36 let bytes = code.as_bytes();
37 bytes.len() == 8
38 && bytes[3] == b'-'
39 && bytes[..3]
40 .iter()
41 .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit())
42 && bytes[4..]
43 .iter()
44 .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit())
45}
46
47#[derive(Deserialize)]
48struct ConnectParams {

Callers 1

auth_connectFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected