Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Streams2 - base classes, zlib, crypto, fs #4348

Merged
merged 72 commits into from
Dec 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
314c6b3
Don't allow invalid encodings in StringDecoder class
isaacs Oct 5, 2012
372cb32
module: Support cycles in native module requires
isaacs Oct 2, 2012
17834ed
Add 'stream' as a native module in repl
isaacs Oct 2, 2012
420e07c
streams2: The new stream base classes
isaacs Oct 2, 2012
639fbe2
streams2: Convert strings to buffers before passing to _write()
isaacs Oct 2, 2012
51a52c4
streams2: Set flowing=true when flowing
isaacs Oct 4, 2012
9b5abe5
streams2: setEncoding and abstract out endReadable
isaacs Oct 3, 2012
3b59fd7
streams2: Make Transform streams pull-style
isaacs Oct 4, 2012
caa853b
transform: Automatically read() on _write when read buffer is empty
isaacs Oct 4, 2012
02f017d
streams2: Allow 0 as a lowWaterMark value
isaacs Oct 5, 2012
06e321d
streams2: Correct drain/return logic
isaacs Oct 5, 2012
8acb416
streams2: Handle immediate synthetic transforms properly
isaacs Oct 7, 2012
9b1b854
streams2: Tests of new interfaces
isaacs Oct 7, 2012
545f512
streams2: ctor guards on Stream classes
isaacs Oct 8, 2012
0678480
streams2: Allow Writables to opt out of pre-buffer-izing
isaacs Oct 9, 2012
71e2b61
streams2: Support write(chunk,[encoding],[callback])
isaacs Oct 10, 2012
f3e71eb
test: Writable bufferizing, non-bufferizing, and callbacks
isaacs Oct 10, 2012
e82d06b
streams2: Fix regression from Duplex ctor assignment
isaacs Oct 10, 2012
acfb0ef
test: fixture for streams2 testing
isaacs Oct 10, 2012
cf0b4ba
streams2: flow() is not always bound to src
isaacs Oct 12, 2012
f624ccb
streams2: Use StringDecoder.end
isaacs Oct 12, 2012
286aa04
streams2: Abstract out onread function
isaacs Oct 31, 2012
5856823
streams2: Fix duplex no-half-open logic
isaacs Nov 13, 2012
63ac07b
streams2: Export Readable/Writable State classes
isaacs Nov 13, 2012
f20fd22
streams2: Add high water mark for Readable
isaacs Nov 13, 2012
62dd040
streams2: Set Readable lwm to 0 by default
isaacs Nov 13, 2012
286c544
streams2: Only emit 'readable' when needed
isaacs Nov 13, 2012
0118584
streams2: Writable organization, add 'finishing' flag
isaacs Nov 13, 2012
c2f62d4
test: Update stream2 transform for corrected behavior
isaacs Nov 13, 2012
2ff499c
streams2: Do multipipe without always using forEach
isaacs Nov 17, 2012
b15e19a
streams2: Remove function.bind() usage
isaacs Nov 17, 2012
38e2b00
streams2: Get rid of .once() usage in Readable.pipe
isaacs Nov 28, 2012
4b4ff2d
streams2: Refactor out .once() usage from Readable.pipe()
isaacs Nov 28, 2012
53fa66d
streams2: Set 'readable' flag on Readable streams
isaacs Nov 28, 2012
ac5a185
streams2: Handle pipeChunkSize properly
isaacs Nov 28, 2012
49ea653
streams2: Remove pipe if the dest emits error
isaacs Nov 29, 2012
d58f265
streams2: Unpipe on dest.emit('close')
isaacs Nov 29, 2012
44b308b
fs: streams2
isaacs Oct 5, 2012
0e01d63
zlib: streams2
isaacs Oct 2, 2012
79fd962
test: Fix test-repl-autolibs inspect call
isaacs Oct 2, 2012
70461c3
test: simple/test-file-write-stream needs to use 0 lowWaterMark
isaacs Oct 5, 2012
3d3a0b3
test: Writable stream end() method doesn't take a callback
isaacs Oct 5, 2012
90de2dd
crypto: Streaming interface for Hash
isaacs Oct 29, 2012
175f78c
crypto: Streaming api for Hmac
isaacs Oct 29, 2012
e336134
crypto: Streaming interface for cipher/decipher/iv
isaacs Oct 29, 2012
dd3ebb8
crypto: Streaming interface for Sign and Verify
isaacs Oct 30, 2012
e0c600e
test: Tests for streaming crypto interfaces
isaacs Oct 30, 2012
4a32d53
doc: Crypto streaming interface
isaacs Oct 30, 2012
83704f1
streams2: Set readable=false on end
isaacs Dec 5, 2012
42981e2
streams2: Switch to old-mode immediately, not nextTick
isaacs Dec 5, 2012
99021b7
streams2: pause() should be immediate
isaacs Dec 5, 2012
dbcacc5
streams2: NextTick the emit('readable') in resume()
isaacs Dec 5, 2012
f8bb031
test: Sync writables may emit finish before callbacks
isaacs Dec 6, 2012
fc7d8d5
lint
isaacs Dec 6, 2012
8f428f3
streams2: Call read(0) on resume()
isaacs Dec 10, 2012
5760244
streams2: Writable only emit 'finish' once
isaacs Dec 12, 2012
8fe7b0c
streams2: Support a Readable hwm of 0
isaacs Dec 13, 2012
04541cf
streams2: Emit pause/resume events
isaacs Dec 13, 2012
20a88fe
docs: streams2
isaacs Dec 13, 2012
854171d
streams2: Remove extraneous bufferSize setting
isaacs Dec 13, 2012
7742257
benchmark: Add once() function to net-pipe benchmark fixture
isaacs Dec 9, 2012
8a3befa
net: Refactor to use streams2
isaacs Dec 13, 2012
695abba
test: Fix many tests for streams2 net refactor
isaacs Dec 13, 2012
bb56dcc
tty/stdin: Refactor for streams2
isaacs Dec 13, 2012
b4df1e6
test updates
isaacs Dec 13, 2012
81e3562
child_process: Remove stream.pause/resume calls
isaacs Nov 8, 2012
1d36931
http: Refactor for streams2
isaacs Dec 13, 2012
0977638
test: Fix many tests for http streams2 refactor
isaacs Dec 13, 2012
19ecc3a
test updates for streams2
isaacs Dec 13, 2012
3751c0f
streams2: Still emit error if there was a write() cb
isaacs Dec 14, 2012
abbd47e
test: Update simple/test-fs-{write,read}-stream-err for streams2
isaacs Dec 14, 2012
cd51fa8
test: Update message tests for streams2
isaacs Dec 15, 2012
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
2 changes: 1 addition & 1 deletion benchmark/net-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Writer.prototype.write = function(chunk, encoding, cb) {

// doesn't matter, never emits anything.
Writer.prototype.on = function() {};

Writer.prototype.once = function() {};
Writer.prototype.emit = function() {};

var statCounter = 0;
Expand Down
51 changes: 42 additions & 9 deletions doc/api/crypto.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Example: this program that takes the sha1 sum of a file

The class for creating hash digests of data.

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hash. Once the writable side of
the stream is ended, use the `read()` method to get the computed hash
digest. The legacy `update` and `digest` methods are also supported.

Returned by `crypto.createHash`.

### hash.update(data, [input_encoding])
Expand All @@ -114,6 +119,11 @@ called.
Creates and returns a hmac object, a cryptographic hmac with the given
algorithm and key.

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hmac. Once the writable side of
the stream is ended, use the `read()` method to get the computed
digest. The legacy `update` and `digest` methods are also supported.

`algorithm` is dependent on the available algorithms supported by
OpenSSL - see createHash above. `key` is the hmac key to be used.

Expand Down Expand Up @@ -148,6 +158,11 @@ recent releases, `openssl list-cipher-algorithms` will display the
available cipher algorithms. `password` is used to derive key and IV,
which must be a `'binary'` encoded string or a [buffer](buffer.html).

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hash. Once the writable side of
the stream is ended, use the `read()` method to get the computed hash
digest. The legacy `update` and `digest` methods are also supported.

## crypto.createCipheriv(algorithm, key, iv)

Creates and returns a cipher object, with the given algorithm, key and
Expand All @@ -166,6 +181,11 @@ Class for encrypting data.

Returned by `crypto.createCipher` and `crypto.createCipheriv`.

Cipher objects are [streams](stream.html) that are both readable and
writable. The written plain text data is used to produce the
encrypted data on the the readable side. The legacy `update` and
`final` methods are also supported.

### cipher.update(data, [input_encoding], [output_encoding])

Updates the cipher with `data`, the encoding of which is given in
Expand Down Expand Up @@ -213,6 +233,11 @@ Class for decrypting data.

Returned by `crypto.createDecipher` and `crypto.createDecipheriv`.

Decipher objects are [streams](stream.html) that are both readable and
writable. The written enciphered data is used to produce the
plain-text data on the the readable side. The legacy `update` and
`final` methods are also supported.

### decipher.update(data, [input_encoding], [output_encoding])

Updates the decipher with `data`, which is encoded in `'binary'`,
Expand Down Expand Up @@ -246,28 +271,33 @@ Creates and returns a signing object, with the given algorithm. On
recent OpenSSL releases, `openssl list-public-key-algorithms` will
display the available signing algorithms. Examples are `'RSA-SHA256'`.

## Class: Signer
## Class: Sign

Class for generating signatures.

Returned by `crypto.createSign`.

### signer.update(data)
Sign objects are writable [streams](stream.html). The written data is
used to generate the signature. Once all of the data has been
written, the `sign` method will return the signature. The legacy
`update` method is also supported.

### sign.update(data)

Updates the signer object with data. This can be called many times
Updates the sign object with data. This can be called many times
with new data as it is streamed.

### signer.sign(private_key, [output_format])
### sign.sign(private_key, [output_format])

Calculates the signature on all the updated data passed through the
signer. `private_key` is a string containing the PEM encoded private
sign. `private_key` is a string containing the PEM encoded private
key for signing.

Returns the signature in `output_format` which can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
returned.

Note: `signer` object can not be used after `sign()` method been
Note: `sign` object can not be used after `sign()` method been
called.

## crypto.createVerify(algorithm)
Expand All @@ -281,6 +311,12 @@ Class for verifying signatures.

Returned by `crypto.createVerify`.

Verify objects are writable [streams](stream.html). The written data
is used to validate against the supplied signature. Once all of the
data has been written, the `verify` method will return true if the
supplied signature is valid. The legacy `update` method is also
supported.

### verifier.update(data)

Updates the verifier object with data. This can be called many times
Expand Down Expand Up @@ -469,9 +505,6 @@ default, set the `crypto.DEFAULT_ENCODING` field to 'binary'. Note
that new programs will probably expect buffers, so only use this as a
temporary measure.

Also, a Streaming API will be provided, but this will be done in such
a way as to preserve the legacy API surface.


[createCipher()]: #crypto_crypto_createcipher_algorithm_password
[createCipheriv()]: #crypto_crypto_createcipheriv_algorithm_key_iv
Expand Down
Loading