-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: Continued development 1. Improved the completeness of the crypto module (node) 2. Implemented the path module (node) 3. Implemented the multer module (node) 4. Refactor error classes # Conflicts: # README.md
- Loading branch information
Showing
63 changed files
with
1,174 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* MD5 Example | ||
* @author [email protected] | ||
*/ | ||
(function () { | ||
|
||
const filename = process.argv[2]; | ||
const crypto = require("crypto"); | ||
const fs = require("fs"); | ||
|
||
const md5sum = crypto.createHash("md5"); | ||
|
||
const stream = fs.ReadStream(filename); | ||
stream.on("data", function (d) { | ||
md5sum.update(d); | ||
}); | ||
|
||
stream.on("end", function () { | ||
var md5 = md5sum.digest("hex"); | ||
console.log(md5 + " " + filename); | ||
}); | ||
|
||
})(); |
13 changes: 13 additions & 0 deletions
13
examples/src/main/javascript/nodejs/codecs/StreamingHashExample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Streaming Hash Example | ||
*/ | ||
(function () { | ||
|
||
const crypto = require("crypto"); | ||
const fs = require("fs"); | ||
const hash = crypto.createHash("sha256"); | ||
|
||
const input = fs.createReadStream("test.js"); | ||
input.pipe(hash).pipe(process.stdout); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ package examples.nodejs.azure | |
import com.github.ldaniels528.meansjs.nodejs.adal.{AdalNode, AuthenticationResponse} | ||
import com.github.ldaniels528.meansjs.nodejs.azure.arm.keyvault.AzureArmKeyVault | ||
import com.github.ldaniels528.meansjs.nodejs.azure.common.{AzureCommon, KeyVaultParameters, TokenCloudCredentialOptions} | ||
import com.github.ldaniels528.meansjs.nodejs.errors.ErrorClass | ||
import com.github.ldaniels528.meansjs.nodejs.{Bootstrap, console, process} | ||
import com.github.ldaniels528.meansjs.nodejs.{Bootstrap, console, errors, process} | ||
import com.github.ldaniels528.meansjs.util.ScalaJsHelper._ | ||
|
||
import scala.scalajs.js | ||
|
@@ -14,6 +13,7 @@ import scala.scalajs.js | |
* @author [email protected] | ||
*/ | ||
class KeyVaultExample(bootstrap: Bootstrap) { | ||
|
||
import bootstrap._ | ||
|
||
val AzureCommon = require[AzureCommon]("azure-common") | ||
|
@@ -28,9 +28,9 @@ class KeyVaultExample(bootstrap: Bootstrap) { | |
val resourceId = process.argv.drop(3).headOption getOrElse "" | ||
|
||
val context = AdalNode.AuthenticationContext("https://login.windows.net/myorg.com") | ||
context.acquireTokenWithUsernamePassword(resourceId, userName, password, clientId, (err: ErrorClass, response: AuthenticationResponse) => { | ||
context.acquireTokenWithUsernamePassword(resourceId, userName, password, clientId, (err: errors.Error, response: AuthenticationResponse) => { | ||
if (isDefined(err)) { | ||
throw new Error("Unable to authenticate: " + err.stack) | ||
throw new RuntimeException("Unable to authenticate: " + err.stack) | ||
} | ||
|
||
val credentials = AzureCommon.TokenCloudCredentials(TokenCloudCredentialOptions( | ||
|
@@ -58,7 +58,7 @@ class KeyVaultExample(bootstrap: Bootstrap) { | |
) | ||
|
||
console.info("Creating vault...") | ||
client.vaults.createOrUpdate(resourceGroup, vaultName, parameters, (err: js.Error, result: js.Any) => { | ||
client.vaults.createOrUpdate(resourceGroup, vaultName, parameters, (err: errors.Error, result: js.Any) => { | ||
if (isDefined(err)) throw new IllegalStateException(err.message) | ||
console.info("Vault created: %j", result) | ||
}) | ||
|
32 changes: 32 additions & 0 deletions
32
examples/src/main/scala/examples/nodejs/codecs/MD5Example.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package examples.nodejs.codecs | ||
|
||
import com.github.ldaniels528.meansjs.nodejs.buffer.Buffer | ||
import com.github.ldaniels528.meansjs.nodejs.crypto.Crypto | ||
import com.github.ldaniels528.meansjs.nodejs.fs.Fs | ||
import com.github.ldaniels528.meansjs.nodejs.{Bootstrap, _} | ||
|
||
/** | ||
* MD5 Example | ||
* @author [email protected] | ||
*/ | ||
class MD5Example(bootstrap: Bootstrap) { | ||
import bootstrap._ | ||
|
||
val crypto = require[Crypto]("crypto") | ||
val fs = require[Fs]("fs") | ||
|
||
process.argv.drop(3).headOption match { | ||
case Some(filename) => | ||
val md5sum = crypto.createHash("md5") | ||
val stream = fs.ReadStream(filename) | ||
stream.onData((d: Buffer) => md5sum.update(d)) | ||
stream.onEnd(() => { | ||
val md5 = md5sum.digest("hex") | ||
console.log(md5 + " " + filename) | ||
}) | ||
case None => | ||
console.warn("No input file was specified") | ||
console.log("Usage: MD5Example <filename>") | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
examples/src/main/scala/examples/nodejs/codecs/StreamingHashExample.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package examples.nodejs.codecs | ||
|
||
import com.github.ldaniels528.meansjs.nodejs.{Bootstrap, _} | ||
import com.github.ldaniels528.meansjs.nodejs.crypto.Crypto | ||
import com.github.ldaniels528.meansjs.nodejs.fs.Fs | ||
|
||
/** | ||
* Streaming Hash Example | ||
* @author [email protected] | ||
*/ | ||
class StreamingHashExample(bootstrap: Bootstrap) { | ||
import bootstrap._ | ||
|
||
val crypto = require[Crypto]("crypto") | ||
val fs = require[Fs]("fs") | ||
val hash = crypto.createHash("sha256") | ||
|
||
val input = fs.createReadStream("test.js") | ||
input.pipe(hash).pipe(process.stdout) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.