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

[ENHANCEMENT]: Export C14nCanonicalization, ExclusiveCanonicalization #331

Closed
angeljqv opened this issue Jul 6, 2023 · 1 comment
Closed

Comments

@angeljqv
Copy link
Contributor

angeljqv commented Jul 6, 2023

Is your feature request related to a problem? Please describe...

I'm trying to use those classes for other processes, I have done it this way

const DOMParser = require("@xmldom/xmldom").DOMParser;

const C14nCanonicalization = require('xml-crypto/lib/c14n-canonicalization').C14nCanonicalization;
const ExclusiveCanonicalization= require('xml-crypto/lib/exclusive-canonicalization').ExclusiveCanonicalization;

let xml_string = '<root><child>123</child></root>';
let documentElement= (new DOMParser()).parseFromString(xml_string).documentElement;

// C14nCanonicalization
console.log( (new C14nCanonicalization()).process(documentElement, {}).toString() );
// ExclusiveCanonicalization
console.log( (new ExclusiveCanonicalization()).process(documentElement, {}).toString() );

Describe teh solution you'd like...

But I would like to make it a little more direct with the require, example:

//const C14nCanonicalization = require('xml-crypto/lib/c14n-canonicalization').C14nCanonicalization;
const C14nCanonicalization = require('xml-crypto').C14nCanonicalization;
//const ExclusiveCanonicalization= require('xml-crypto/lib/exclusive-canonicalization').ExclusiveCanonicalization;
const ExclusiveCanonicalization= require('xml-crypto').ExclusiveCanonicalization

Describe the alternatives you've considered...

I don't know if it is already possible in a similar way, because I did not find it in the documentation

@cjbarth
Copy link
Contributor

cjbarth commented Jul 6, 2023

You're requireing the module, and then you need to reference the object in the module you'd like to work with. The only way to do what you're looking for would be to used a default export, and we aren't doing that. Otherwise you could use an import statement, but that is usually more TypeScript.

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

2 participants