Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,17 @@ _Also available globally_

# LLRT API

## llrt:hex
## llrt:codec

```typescript
export function encode(
export function decodeFromBase64(value: string): Uint8Array;
export function encodeToBase64(
value: string | Array | ArrayBuffer | Uint8Array
): string;
export function decodeFromHex(value: string): Uint8Array;
export function encodeToHex(
value: string | Array | ArrayBuffer | Uint8Array
): string;
export function decode(value: string): Uint8Array;
```

## llrt:timezone
Expand Down Expand Up @@ -760,7 +764,6 @@ export class XMLParser(options?: XmlParserOptions){
}
```


## llrt:util

```typescript
Expand All @@ -769,7 +772,6 @@ export function load(path: string): any;
export function print(value: any): void;
```


# Web Platform API

## CONSOLE
Expand Down
25 changes: 14 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ The test runner also has support for filters. Using filters is as simple as addi

| [LLRT API](https://github.com/awslabs/llrt/blob/main/API.md) | Node.js | LLRT |
| ------------------------------------------------------------ | ------- | ---- |
| llrt:hex | ✘ | ✔︎ |
| llrt:codec | ✘ | ✔︎ |
| llrt:qjs | ✘ | ✔︎ |
| llrt:util | ✘ | ✔︎ |
| llrt:xml | ✘ | ✔︎ |
Expand Down
4 changes: 2 additions & 2 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ const ES_BUILD_OPTIONS = {
"node:util",
"zlib",
"node:zlib",
"llrt:hex",
"llrt:codec",
"llrt:timezone",
"llrt:util",
"llrt:qjs",
"llrt:util",
"llrt:xml",
"@aws-crypto",
],
Expand Down
10 changes: 5 additions & 5 deletions example/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
"build": "node build.mjs"
},
"dependencies": {
"@aws-sdk/client-dynamodb": "3.1031.0",
"@aws-sdk/client-ec2": "3.1031.0",
"@aws-sdk/client-s3": "3.1031.0",
"@aws-sdk/client-dynamodb": "3.1057.0",
"@aws-sdk/client-ec2": "3.1057.0",
"@aws-sdk/client-s3": "3.1057.0",
"aws-sdk": "2.1693.0",
"esbuild-css-modules-plugin": "3.1.5",
"react": "19.2.5",
"react": "19.2.6",
"react-dom": "19.2.5"
},
"devDependencies": {
"@types/react": "19.2.14",
"@types/react": "19.2.15",
"@types/react-dom": "19.2.3",
"esbuild": "0.28.0"
}
Expand Down
6 changes: 3 additions & 3 deletions example/infrastructure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"hotswap": "cdk deploy --hotswap"
},
"devDependencies": {
"@types/node": "25.6.0",
"aws-cdk": "2.1120.0",
"aws-cdk-lib": "2.252.0",
"@types/node": "25.9.1",
"aws-cdk": "2.1125.0",
"aws-cdk-lib": "2.257.0",
"constructs": "10.6.0",
"esbuild": "0.28.0",
"ts-node": "10.9.2",
Expand Down
23 changes: 23 additions & 0 deletions libs/llrt_encoding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ pub fn bytes_from_b64<'a, T: Into<Cow<'a, [u8]>>>(base64_bytes: T) -> Result<Vec
base64_simd::forgiving_decode_to_vec(&bytes).map_err(|e| e.to_string())
}

/// Strict standard-base64 decode (single SIMD pass): rejects url-safe chars,
/// whitespace and bad padding, matching @smithy/util-base64 semantics.
pub fn bytes_from_b64_strict(bytes: &[u8]) -> Result<Vec<u8>, String> {
base64_simd::STANDARD
.decode_to_vec(bytes)
.map_err(|e| e.to_string())
}

pub fn bytes_to_b64_string(bytes: &[u8]) -> String {
base64_simd::STANDARD.encode_to_string(bytes)
}
Expand Down Expand Up @@ -240,3 +248,18 @@ pub fn bytes_to_utf16_string(bytes: &[u8], endian: Endian, lossy: bool) -> Resul

Ok(result)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn b64_strict_matches_smithy_semantics() {
// canonical decodes
assert_eq!(bytes_from_b64_strict(b"SGVsbG8=").unwrap(), b"Hello");
// url-safe, whitespace, bad-padding are rejected (like @smithy/util-base64)
assert!(bytes_from_b64_strict(b"-_8=").is_err());
assert!(bytes_from_b64_strict(b"SGVs bG8=").is_err());
assert!(bytes_from_b64_strict(b"SGVsbG8").is_err());
}
}
6 changes: 6 additions & 0 deletions libs/llrt_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ fs = ["tokio/fs"]
bytearray-buffer = ["tokio/sync"]

[dependencies]
memchr = { version = "2", default-features = false, features = ["std"] }
rquickjs = { version = "0.11", git = "https://github.com/DelSkayn/rquickjs", features = ["macro"], default-features = false }
simdutf8 = { version = "0.1", default-features = false, features = ["std", "aarch64_neon"] }
tokio = { version = "1", features = ["sync"], default-features = false }
tracing = { version = "0.1", default-features = false }

Expand All @@ -33,3 +35,7 @@ tokio = { version = "1", features = ["full"] }

[build-dependencies]
llrt_build = { version = "0.8.1-beta", path = "../llrt_build" }

[[bench]]
name = "lossy_string"
harness = false
Loading
Loading