From 605cab4c85404ad3bc290ef4697cc956e083687c Mon Sep 17 00:00:00 2001 From: Pascal Perrenoud Date: Tue, 14 May 2024 14:38:30 +0200 Subject: [PATCH] Remove pwd and jwt (server only) Closes #9 --- index.ts | 2 -- package.json | 3 +-- src/jwt.ts | 8 -------- src/pwd.ts | 7 ------- test/pwd.test.ts | 35 ----------------------------------- 5 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 src/jwt.ts delete mode 100644 src/pwd.ts delete mode 100644 test/pwd.test.ts diff --git a/index.ts b/index.ts index 92684d3..857edfd 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,2 @@ -export * as JWT from 'jwt' -export * as pwd from 'pwd' export * as signature from 'signature' export * as boxes from 'boxes' diff --git a/package.json b/package.json index b66dcf2..4ddba83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crypto", - "description": "Various crypto utils for hashing, encryption, signature, ...", + "description": "Various crypto utils for encryption, signature, ...", "module": "index.ts", "type": "module", "files": ["index.ts"], @@ -8,7 +8,6 @@ "test": "bun test" }, "dependencies": { - "jose": "^5.3.0", "log": "^6.3.1", "result": "git+git@git.pband.ch:typescript/result.git", "zxcvbn": "^4.4.2" diff --git a/src/jwt.ts b/src/jwt.ts deleted file mode 100644 index f6bbf37..0000000 --- a/src/jwt.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type JWT = `${string}.${string}.${string}` - -export function create() : JWT { - throw "todo" -} -export function verify() : boolean { - throw "todo" -} diff --git a/src/pwd.ts b/src/pwd.ts deleted file mode 100644 index 1804fc3..0000000 --- a/src/pwd.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function hash(pwd: string) : Promise { - return Bun.password.hash(pwd) -} - -export async function verify(pwd: string, hash: string) : Promise { - return Bun.password.verify(pwd, hash).catch(() => false) -} diff --git a/test/pwd.test.ts b/test/pwd.test.ts deleted file mode 100644 index 3e58eb1..0000000 --- a/test/pwd.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import {test, expect} from 'bun:test' - -import {pwd} from '../index' - -test('base case', async () => { - const password = "AwesomePassword123!" - const hash = await pwd.hash(password) - const verification = await pwd.verify(password, hash) - expect(verification).toBe(true) -}) - -test('wrong password', async () => { - const password1 = "AwesomePassword123!" - const password2 = "AwesomePassword321!" - expect(password1).not.toEqual(password2) - - const hash = await pwd.hash(password1) - const verification = await pwd.verify(password2, hash) - expect(verification).toBe(false) -}) - -test('salt changes', async () => { - const password = "AwesomePassword123!" - const hash1 = await pwd.hash(password) - const hash2 = await pwd.hash(password) - expect(hash1).not.toEqual(hash2) -}) - -test('tampered hash', async () => { - const password = "AwesomePassword123" - const hash = await pwd.hash(password) - const tamperedHash = hash.replace('a', 'b') - const verification = await pwd.verify(password, tamperedHash) - expect(verification).toBe(false) -})