forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: deno_crypto op crate (denoland#7956)
This commit factors out "deno_crypto" op crate. "rand" crate dependency was consequently moved to "deno_crypto" crate and reexported.
- Loading branch information
1 parent
2c8439b
commit d5661f6
Showing
13 changed files
with
79 additions
and
21 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,14 @@ | ||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
use deno_crypto::op_get_random_values; | ||
use deno_crypto::rand::rngs::StdRng; | ||
use deno_crypto::rand::SeedableRng; | ||
|
||
pub fn init(rt: &mut deno_core::JsRuntime, maybe_seed: Option<u64>) { | ||
if let Some(seed) = maybe_seed { | ||
let rng = StdRng::seed_from_u64(seed); | ||
let op_state = rt.op_state(); | ||
let mut state = op_state.borrow_mut(); | ||
state.put::<StdRng>(rng); | ||
} | ||
super::reg_json_sync(rt, "op_get_random_values", op_get_random_values); | ||
} |
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
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,19 @@ | ||
# Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
|
||
[package] | ||
name = "deno_crypto" | ||
version = "0.1.1" | ||
edition = "2018" | ||
description = "Collection of WebCrypto APIs" | ||
authors = ["the Deno authors"] | ||
license = "MIT" | ||
readme = "README.md" | ||
repository = "https://github.com/denoland/deno" | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
deno_core = { version = "0.67.0", path = "../../core" } | ||
rand = "0.7.3" | ||
|
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,3 @@ | ||
# deno crypto | ||
|
||
Op crate that implements crypto functions. |
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