Skip to content

encrypt-node initial commit #12

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

Merged
merged 15 commits into from
Apr 9, 2019
Merged

encrypt-node initial commit #12

merged 15 commits into from
Apr 9, 2019

Conversation

seebees
Copy link
Contributor

@seebees seebees commented Mar 15, 2019

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@seebees seebees requested a review from a team March 15, 2019 20:48
Copy link
Contributor

@jpeddicord jpeddicord left a comment

Choose a reason for hiding this comment

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

This is a fairly shallow review as I'm not a domain expert in crypto. But things in general here look sane; the code looks to be well-documented, readable, and of high quality. I've left a few comments below of some odd smells, but in general I think this is good. Part of the fun of open sourcing is letting your community help you identify issues as well, so if you're worried about some code style or organizational stuff don't fret too much.


import {
serializeFactory, aadFactory,
MessageHeader // eslint-disable-line no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

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

Disabling no-unused-vars for specific imports seems strange. Why not remove the import? Are there side-effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These imports are for TypeScript and are not used from the eslint perspective...
You make a comment below about linters... More there

} from '@aws-crypto/serialize'
// @ts-ignore
import { Transform as PortableTransform } from 'readable-stream'
import { Cipher } from 'crypto' // eslint-disable-line no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra commentary: Use of eslint with TypeScript is interesting. tslint may be a better fit here and you can configure it to not overlap with your code formatter (e.g. tslint-config-standard).

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 as sure https://eslint.org/blog/2019/01/future-typescript-eslint . TypeScript has adopted ESLint as it's standard.

But I do not really care for the unused var comments. The reason I flatten the imports is so that I can add this comment to specific type only imports. I've had a few fat finger moments if I just comment out the whole import ;)


export function getFramedEncryptStream (getCipher: GetCipher, messageHeader: MessageHeader, dispose: Function) {
let accumulatingFrame: AccumulatingFrame = { contentLength: 0, content: [], sequenceNumber: 1 }
let pathologicalDrain: Function|false = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this type be Function | null or Function | undefined may be more semantically correct, based on how this is used. But false does work fine.

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 go back and forth on this. I agree that undefined is a little more idiomatic. I even do it that way in several places. But this value is going to be swapped back and forth. So I would prefer to not have

pathologicalDrain = undefined floating around.

Especially since undefined = () => {badStuff} is valid JS. :) . Who ever thought that was a good idea... sigh

Copy link

Choose a reason for hiding this comment

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

Peanut gallery/IANAJSDev: I like the more explicit/unambiguous Function|false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Np, I copied over what I have from decrypt. And turn this into a function that does work or a noop...

seebees added 2 commits March 21, 2019 21:27
comments, and a little clean up
// @ts-ignore
import { pipeline } from 'readable-stream'

const fromUtf8 = (input: string) => Buffer.from(input)

Choose a reason for hiding this comment

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

On one hand the default encoding is utf8, the default is unlikey to change because that is a breaking change. On the other hand Buffer.from(input, 'utf8') is more explicit. I lean explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good point. Changing it everywhere.

everett1992
everett1992 previously approved these changes Mar 26, 2019
lizroth
lizroth previously approved these changes Apr 9, 2019
Copy link

@lizroth lizroth left a comment

Choose a reason for hiding this comment

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

This looks like it has been basically blessed by your JS reviewers and looks sane to me from an SDK perspective, so I am going to go ahead and approve.

There's a couple of open discussions but they look conversational rather than blocking. I gave my 2 cents where I had it, for what it's worth.


export function getFramedEncryptStream (getCipher: GetCipher, messageHeader: MessageHeader, dispose: Function) {
let accumulatingFrame: AccumulatingFrame = { contentLength: 0, content: [], sequenceNumber: 1 }
let pathologicalDrain: Function|false = false
Copy link

Choose a reason for hiding this comment

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

Peanut gallery/IANAJSDev: I like the more explicit/unambiguous Function|false

@seebees seebees merged commit 8c2607b into aws:master Apr 9, 2019
@seebees seebees deleted the add-encrypt-node branch April 9, 2019 01:58
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

Successfully merging this pull request may close these issues.

4 participants