Skip to content

Commit

Permalink
release 1.0.0
Browse files Browse the repository at this point in the history
This should close all the issues in fdionisi/deno-argon2.

Closes fdionisi#7, closes fdionisi#10 and closes fdionisi#11
  • Loading branch information
felix-schindler committed Aug 3, 2023
1 parent 43e2bdb commit 96a520b
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 164 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: "~1.30"
deno-version: "~1.35"

- name: Log versions
run: |
Expand All @@ -35,19 +35,19 @@ jobs:
cargo --version
- name: Cache cargo registry
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: target
key: ${{ matrix.kind }}-${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
Expand All @@ -58,17 +58,21 @@ jobs:

- name: Build
if: matrix.kind == 'test'
run: cargo build --release --locked
run: cargo build --release --locked

- name: Lint TypeScript
if: matrix.kind == 'lint'
run: deno task ok

- name: Test TypeScript
if: matrix.kind == 'test'
run: ./test-with-local-build.sh
run: deno task test

- name: Release
uses: softprops/action-gh-release@v1
if: matrix.kind == 'test' && startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
with:
files: |
target/release/libdeno_argon2.dylib
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"deno.enable": true,
"deno.unstable": true,
"deno.autoFmtOnSave": true
"editor.defaultFormatter": "denoland.vscode-deno"
}
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno-argon2"
version = "0.9.2"
version = "1.0.0"
authors = ["Federico <code@fdionisi.me>"]
edition = "2018"

Expand All @@ -11,5 +11,5 @@ crate-type = ["cdylib"]
[dependencies]
bytes = { version = "1.4.0", features = ["serde"] }
rust-argon2 = "1.0.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
serde = { version = "1.0.118", features = ["derive"] }
serde_json = "1.0.104"
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ hood.
| 0.7.0 | 1.0.5 |
| 0.8.0 | 1.2.3 |
| 0.9.0 | 1.8.3 |
| 1.0.0 | 1.35.0 |

## API

Expand Down Expand Up @@ -73,8 +74,9 @@ After install run `--help` to inspect all possible commands.

## Permissions

The library automatically downloads the static library and calls the static library's functions
via FFI(Foreign Function Interface) API ([Deno: ffi docs](https://deno.land/manual@v1.30.0/runtime/ffi_api)) and it
The library automatically downloads the static library and calls the static
library's functions via FFI(Foreign Function Interface) API
([Deno: ffi docs](https://deno.land/manual@v1.35.0/runtime/ffi_api)) and it
requires `--allow-read`, `--allow-write`, `--allow-net` and `--allow-ffi`.

<details>
Expand Down
96 changes: 25 additions & 71 deletions benches/deno.bench.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,48 @@
import {
bench,
runBenchmarks,
} from "https://deno.land/std@0.92.0/testing/bench.ts";

import { hash, verify } from "../lib/mod.ts";
import { ThreadMode } from "../lib/common.ts";
import { installPlugin } from "../lib/internal.ts";

let { verify, hash } = await installPlugin("file://target/release", {
buildPlugin: "release",
printLog: false,
checkCache: false,
});

let password =
const password =
"2gnF!WAcyhp#kB@tcYQa2$A%P64jEmXY!@8n2GSH$GggfgGfP*qH!EWwDaB%5mdB6pW2fK!KD@YNjvqwREfRCCAPc54c5@Sk";
let hashed =
const hashed =
"$argon2i$v=19$m=4096,t=3,p=1$i8Pd309cCOP75oN8vz8FHA$qUk1NgsxOmz3nWc54jyuOnr+3hHbZz3k0Sb13id7Ai8";

bench({
Deno.bench({
name: "hash 100 times",
runs: 100,
async func(handler: any) {
handler.start();
async fn() {
await hash(
password,
);
handler.stop();
},
});

bench({
Deno.bench({
name: "hash 100 times with random salt",
runs: 100,
async func(handler: any) {
let salt = crypto.getRandomValues(
async fn() {
const salt = crypto.getRandomValues(
new Uint8Array(Math.max(8, Math.random() * 32)),
);
handler.start();
// handler.start();
await hash(
password,
{ salt },
);
handler.stop();
// handler.stop();
},
});

bench({
Deno.bench({
name: "hash 100 times with random data, secret and salt",
runs: 100,
async func(handler: any) {
let salt = crypto.getRandomValues(
async fn() {
const salt = crypto.getRandomValues(
new Uint8Array(Math.max(8, Math.random() * 32)),
);
let secret = crypto.getRandomValues(
const secret = crypto.getRandomValues(
new Uint8Array(Math.max(8, Math.random() * 32)),
);
let data = {
const data = {
hashedAt: Date.now(),
};
handler.start();
// handler.start();
await hash(
password,
{
Expand All @@ -67,83 +51,53 @@ bench({
data,
},
);
handler.stop();
// handler.stop();
},
});

bench({
Deno.bench({
name: "hash 100 times with memoryCost set at 1024",
runs: 100,
async func(handler: any) {
handler.start();
async fn() {
await hash(
password,
{
memoryCost: 1024,
},
);
handler.stop();
},
});

bench({
Deno.bench({
name: "hash 100 times with timeCost set at 10",
runs: 100,
async func(handler: any) {
handler.start();
async fn() {
await hash(
password,
{
timeCost: 6,
},
);
handler.stop();
},
});

bench({
name: "hash 100 times with 16 lanes on parallel mode",
runs: 100,
async func(handler: any) {
handler.start();
await hash(
password,
{
threadMode: ThreadMode.Parallel,
lanes: 16,
},
);
handler.stop();
},
});

bench({
Deno.bench({
name: "hash 100 times with 16 lanes on sequential mode",
runs: 100,
async func(handler: any) {
handler.start();
async fn() {
await hash(
password,
{
threadMode: ThreadMode.Sequential,
lanes: 16,
},
);
handler.stop();
},
});

bench({
Deno.bench({
name: "verify 100 times",
runs: 100,
async func(handler: any) {
handler.start();
async fn() {
await verify(
hashed,
password,
);
handler.stop();
},
});

runBenchmarks();
8 changes: 5 additions & 3 deletions cli/commands/hash.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { argon2, Command } from "../deps.ts";
import { readStdin } from "../util.ts";

let encoder = new TextEncoder();
const encoder = new TextEncoder();

export let hash = new Command()
export const hash = new Command()
.version(argon2.version())
.description("Hash a new password or verify an already existing one.")
.option("-s, --salt <arg:string>", "")
Expand All @@ -26,6 +26,7 @@ export let hash = new Command()
case "parallel": {
return argon2.ThreadMode.Parallel;
}
// deno-lint-ignore no-empty
case undefined: {}
default: {
throw new Error(
Expand All @@ -44,6 +45,7 @@ export let hash = new Command()
case argon2.Variant.Argon2id: {
return value;
}
// deno-lint-ignore no-empty
case undefined: {}
default: {
throw new Error(
Expand All @@ -67,7 +69,7 @@ export let hash = new Command()
}
})
.action(async (options) => {
let password = await readStdin();
const password = await readStdin();

console.log(
await argon2.hash(password, {
Expand Down
Loading

0 comments on commit 96a520b

Please sign in to comment.