Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadableStream support for BufferSource? #86

Open
Manouchehri opened this issue Dec 29, 2022 · 0 comments
Open

ReadableStream support for BufferSource? #86

Manouchehri opened this issue Dec 29, 2022 · 0 comments

Comments

@Manouchehri
Copy link

Would it be possible to have things like AsnParser.parse(...) support ReadableStream as the data BufferSource?

e.g.

import { AsnParser } from "@peculiar/asn1-schema";
import { Certificate } from "@peculiar/asn1-x509";

fetch("https://raw.githubusercontent.com/google/clusterfuzz/master/docs/setting-up-fuzzing/heartbleed/server.pem").then(async current_response => {
    const cert = AsnParser.parse(current_response.body, Certificate);
    console.log(cert);
})

instead of:

import { AsnParser } from "@peculiar/asn1-schema";
import { Certificate } from "@peculiar/asn1-x509";

fetch("https://raw.githubusercontent.com/google/clusterfuzz/master/docs/setting-up-fuzzing/heartbleed/server.pem").then(async current_response => {
    const cert = AsnParser.parse(await current_response.arrayBuffer(), Certificate);
    console.log(cert);
})

While this simplified example only has a tiny certificate, I think ReadableStream would help reduce memory and decoding times for very large BER buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant