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

Convert this project to TypeScript #325

Merged
merged 7 commits into from
Jul 18, 2023
Merged

Conversation

cjbarth
Copy link
Contributor

@cjbarth cjbarth commented Jun 28, 2023

Please, @LoneRifle and @shunkica, feel free to push to this branch, or create a PR against it if you can't push, as often as you'd like to help get this done more quickly.

@cjbarth
Copy link
Contributor Author

cjbarth commented Jul 6, 2023

This PR is blocked on goto100/xpath#116.

@shunkica
Copy link
Contributor

shunkica commented Jul 7, 2023

This PR is blocked on goto100/xpath#116.

You dont need to wait for them to update xpath. Just add your own typings
https://github.com/cjbarth/xml-crypto/blob/e2f99b2dc06aac6fdfc368573de851f2cb55444a/typings/xpath.d.ts

@cjbarth
Copy link
Contributor Author

cjbarth commented Jul 7, 2023

Just add your own typings

I suppose I could... then remove them later...

@LoneRifle
Copy link
Collaborator

Maybe we should wait after all. @cjbarth has been working on this full on for a while, and might need a breather

@codecov
Copy link

codecov bot commented Jul 8, 2023

Codecov Report

Merging #325 (c880789) into master (6f5280e) will decrease coverage by 10.45%.
The diff coverage is 74.03%.

@@             Coverage Diff             @@
##           master     #325       +/-   ##
===========================================
- Coverage   82.88%   72.44%   -10.45%     
===========================================
  Files           7        9        +2     
  Lines         777      860       +83     
  Branches        0      228      +228     
===========================================
- Hits          644      623       -21     
- Misses        133      136        +3     
- Partials        0      101      +101     
Impacted Files Coverage Δ
src/types.ts 50.00% <50.00%> (ø)
src/c14n-canonicalization.ts 51.72% <61.11%> (ø)
src/hash-algorithms.ts 68.00% <68.00%> (ø)
src/signature-algorithms.ts 68.51% <68.51%> (ø)
src/exclusive-canonicalization.ts 78.40% <72.72%> (ø)
src/signed-xml.ts 74.56% <74.56%> (ø)
src/enveloped-signature.ts 81.81% <81.81%> (ø)
src/utils.ts 83.00% <86.84%> (ø)
src/index.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@LoneRifle LoneRifle force-pushed the ts-convert branch 3 times, most recently from 191c6e9 to d316253 Compare July 8, 2023 13:30
@cjbarth cjbarth marked this pull request as ready for review July 14, 2023 09:45
@cjbarth
Copy link
Contributor Author

cjbarth commented Jul 14, 2023

This PR has taken quite a bit more than anticipated to get right. I would appreciate feedback at this time. I hope to get this landed and then have follow-on PRs to address better typing and refactoring. This should get us in a good direction though.

@LoneRifle
Copy link
Collaborator

LoneRifle commented Jul 14, 2023

Is it fair to say that SignedXml has most of the changes?

@cjbarth
Copy link
Contributor Author

cjbarth commented Jul 14, 2023

Is it fair to say that SignedXml has most of the changes?

Yes. Would it make it easier if I did a rename-only PR ahead of this, even though it would break the build, just so that this PR's diff is easier to read (and which would then fix the build)?

@cjbarth
Copy link
Contributor Author

cjbarth commented Jul 14, 2023

rename-only PR

I merged in a rename-only PR so that this one has much better diffs. LMK how else I can help the review go better on this.

Copy link
Collaborator

@LoneRifle LoneRifle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise. thanks for tirelessly undertaking this task to improve code hygiene here!

I think there are a few minor issues and nits to polish through, and then we should be good to go.

src/c14n-canonicalization.ts Show resolved Hide resolved
src/exclusive-canonicalization.ts Show resolved Hide resolved
src/index.ts Outdated
Comment on lines 2 to 3
export {} from "./utils";
export {} from "./types";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? any reason why these lines are explicitly defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that a consumer of this package shouldn't have to know the innards of this library to use the things from those files. They will all appears as members of xml-crypto in their include or requires statement.

src/utils.ts Outdated
Comment on lines 277 to 278
buffer = Buffer.from(digest, "base64");
expectedBuffer = Buffer.from(expectedDigest, "base64");
Copy link
Collaborator

@LoneRifle LoneRifle Jul 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.from was only introduced in Node 5.10 though. We should decide whether we want to keep these since we now only support much later versions of Node.

I'm personally in favour of dropping these especially given that we've moved to TypeScript, and if someone really wants to, they can figure a way to get from TypeScript to transpiled JavaScript.

This also allows us to remove the need to check the major version of Node at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're saying here. I think I made this change (probably out of scope) to remove a deprecation warning. Are you proposing that we revert this or keep this?

Copy link
Collaborator

@LoneRifle LoneRifle Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm proposing to revert this or to remove it altogether.

If we were to keep this, it would trigger a runtime error, if running on Node 5. That is why there is a check for Node major version earlier in the code path; to determine if Buffer.from is present. As it is, both branches of the conditional are largely the same.

I'm leaning towards removing this if block altogether and simply replacing with Buffer.from lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the change, but I'm also wondering the history of the lines below this with the comment "Compatibility with Node < 0.11.13" Does that need to be removed? Honestly, it looks like a reasonable check to me no matter the version of Node.

src/utils.ts Outdated Show resolved Hide resolved
src/c14n-canonicalization.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@LoneRifle LoneRifle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - thanks! I look forward to a fresh start with this package!

@cjbarth cjbarth added the chore label Jul 18, 2023
@cjbarth cjbarth merged commit 5ba1d04 into node-saml:master Jul 18, 2023
@cjbarth cjbarth deleted the ts-convert branch July 18, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants