Skip to content

Commit

Permalink
feat: JSR support
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Apr 3, 2024
1 parent 6ce4f2a commit d8cb043
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno publish
13 changes: 13 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@denosaurs/argontwo",
"version": "0.2.0",
"exports": "./mod.ts",
"imports": {
"@std/encoding": "jsr:@std/encoding@0.221",
"@std/crypto": "jsr:@std/crypto@0.221",
"@denosaurs/lz4": "jsr:@denosaurs/lz4@0.1.4"
},
"tasks": {
"build": "deno run -A scripts/build.ts"
}
}
58 changes: 58 additions & 0 deletions deno.lock

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

2 changes: 1 addition & 1 deletion examples/phc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { timingSafeEqual } from "https://deno.land/std@0.204.0/crypto/timing_safe_equal.ts";
import { timingSafeEqual } from "@std/crypto";
import { Buffer } from "node:buffer";
import phc from "npm:@phc/format";
import { hash } from "../mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function hash(
password: BufferSource,
salt: BufferSource,
params?: Argon2Params,
) {
): ArrayBuffer {
params ??= {
algorithm: "Argon2id",
version: 0x13,
Expand Down
8 changes: 4 additions & 4 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { encodeBase64 } from "https://deno.land/std@0.204.0/encoding/base64.ts";
import { compress } from "https://deno.land/x/lz4@v0.1.2/mod.ts";
import { encodeBase64 } from "@std/encoding/base64";
import { compress } from "@denosaurs/lz4";

const name = "argontwo";

Expand All @@ -12,8 +12,8 @@ const wasm = await Deno.readFile(
);
const encoded = encodeBase64(compress(wasm));
const js = `// deno-fmt-ignore-file\n// deno-lint-ignore-file
import { decodeBase64 } from "https://deno.land/std@0.204.0/encoding/base64.ts";
import { decompress } from "https://deno.land/x/lz4@v0.1.2/mod.ts";
import { decodeBase64 } from "jsr:@std/encoding@0.221/base64";
import { decompress } from "jsr:@denosaurs/lz4@0.1.4";
export const source = decompress(decodeBase64("${encoded}"));`;

await Deno.writeTextFile("wasm/wasm.js", js);
2 changes: 1 addition & 1 deletion test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.204.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/assert@0.221";

import { hash } from "./mod.ts";

Expand Down
6 changes: 3 additions & 3 deletions wasm/wasm.js

Large diffs are not rendered by default.

0 comments on commit d8cb043

Please sign in to comment.