Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
zigazajc007 committed Feb 6, 2024
1 parent 8494cb9 commit ac9d720
Show file tree
Hide file tree
Showing 29 changed files with 1,010 additions and 1,014 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/node_modules
/target
/Cargo.lock
/pkg
/dist
/pkg
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ repository = "https://github.com/Rabbit-Company/Argon2id-WASM"
crate-type = ["cdylib"]

[dependencies]
argon2 = "0.5"
wasm-bindgen = "0.2"
argon2 = "0.5.3"
wasm-bindgen = "0.2.90"
1 change: 1 addition & 0 deletions browser/argon2id.js

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

Binary file added browser/argon2id_wasm_bg.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions browser/argon2id_worker.js

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

72 changes: 72 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import dts from 'bun-plugin-dts';
import Logger from '@rabbit-company/logger';
import fs from 'fs/promises';

await fs.rm('./browser', {recursive: true, force: true});
await fs.rm('./module', {recursive: true, force: true});
await fs.rm('./dist', {recursive: true, force: true});

Logger.info('Start bulding browser...');
let browserBuild = await Bun.build({
entrypoints: ['./src/argon2id.ts', './src/argon2id_worker.ts'],
outdir: './browser',
target: 'browser',
format: 'esm',
minify: {
identifiers: false,
syntax: true,
whitespace: true
},
plugins: [],
});

await Bun.write(Bun.file('./browser/argon2id_wasm_bg.wasm'), Bun.file('./src/argon2id_wasm_bg.wasm'));

if(browserBuild.success){
Logger.info('Bulding browser complete');
}else{
Logger.error('Bulding browser failed');
}

Logger.info('Start bulding module...');
let moduleBuild = await Bun.build({
entrypoints: ['./src/argon2id.ts', './src/argon2id_worker.ts'],
outdir: './module',
target: 'browser',
format: 'esm',
minify: false,
plugins: [
dts({output: {noBanner: true}})
],
});

await Bun.write(Bun.file('./module/argon2id_wasm_bg.wasm'), Bun.file('./src/argon2id_wasm_bg.wasm'));

if(moduleBuild.success){
Logger.info('Bulding module complete');
}else{
Logger.error('Bulding module failed');
}

fs.cp('./src/index.html', './dist/index.html', {recursive: true, force: true});

Logger.info('Start bundling dist...');
let distBuild = await Bun.build({
entrypoints: ['./src/index.ts', './src/argon2id_worker.ts'],
outdir: './dist',
target: 'browser',
format: 'esm',
minify: true,
sourcemap: 'none', // Bun still generates incorrect sourcemaps
plugins: [],
});

await Bun.write(Bun.file('./dist/argon2id_wasm_bg.wasm'), Bun.file('./src/argon2id_wasm_bg.wasm'));
await Bun.write(Bun.file('./dist/index.html'), Bun.file('./src/index.html'));

if(distBuild.success){
Logger.info('Bundling dist complete');
}else{
Logger.error('Bundling dist failed');
Logger.error(distBuild.logs);
}
Binary file added bun.lockb
Binary file not shown.
Binary file added dist/argon2id_wasm_bg.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions dist/argon2id_worker.js

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

32 changes: 32 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>Argon2id-WASM</title>
</head>
<body>
<h1><a href="https://github.com/Rabbit-Company/Argon2id-WASM" target="_blank">Argon2id-WASM</a></h1>
<form id="hashForm">
<textarea id="message" rows="5" cols="50"></textarea></br></br>
<label>Salt: </label><input id="salt" type="text" placeholder="Salt" required><br/>
<label>Parallelism Factor: </label><input id="p" type="number" min="1" max="224" value="4" placeholder="p" required><br/>
<label>Memory Cost: </label><input id="m" type="number" min="2" max="1048576" value="16" placeholder="m" required><br/>
<label>Iterations: </label><input id="t" type="number" min="1" max="100" value="3" placeholder="t" required><br/>
<label>Hash Length: </label><input id="l" type="number" min="4" max="65536" value="32" placeholder="l" required><br/><br/>
<button type="submit">Hash</button>
</form>
<p id="hash"></p>

<h1>Validator</h1>
<form id="verifyForm">
<textarea id="message2" rows="5" cols="50"></textarea></br></br>
<label>Hash Encoded: </label><input id="hashEncoded" type="text" placeholder="$argon2id$v=19$m=65536,t=3,p=4$OVg1TXI3eTlzcnc2SjIxNw$LtPyv2bn74MJPui2JBPXWx5jXMd1uUv3515emrYSlhM" required><br/></br>
<button type="submit">Validate</button>
</form>
<p id="validate"></p>

<h1>Performance</h1>
<p id="perf"></p>

<script type="module" src="index.js"></script>
</body>
</html>
Loading

0 comments on commit ac9d720

Please sign in to comment.