commit 891b54034b25cb933d4c0a2cb5f0ee45e5d35f98 Author: Pascal Perrenoud Date: Wed Jun 5 23:17:19 2024 +0200 init project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ede773 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.idea/ +bun.lockb +package-lock.json +node_modules/ +._* +.DS_Store diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..8eb12b4 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,22 @@ +when: + - path: + include: [ + 'src/**/*.ts', + 'index.ts' + ] + +steps: + install: + image: node + when: + - event: [pull_request, push, manual] + commands: + - npm install + + test: + image: oven/bun:alpine + when: + - event: [pull_request, push, manual] + depends_on: install + commands: + - bun test diff --git a/README.md b/README.md new file mode 100644 index 0000000..e318c47 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Tests : ![CI status](https://ci.pband.ch/api/badges/11/status.svg "CI status") + +# Crypto tools +Various crypto tools used often. +The lib is based as much as possible on the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) ! +The JWT part uses [JOSE](https://github.com/panva/jose) as it implements all the JWT functions. +The signature part uses [noble-ed25519](https://github.com/paulmillr/noble-ed25519) instead of the Web Crypto API, so you can derive a KeyPair from a password. diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 0000000..0f705fb --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,2 @@ +[test] +preload = "./test/init.ts" diff --git a/package.json b/package.json new file mode 100644 index 0000000..7d8d413 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "crypto", + "description": "Various crypto utils for encryption, signature, ...", + "version": "1.0.0", + + "author": "Pascal Perrenoud ", + + "module": "index.ts", + "type": "module", + "files": ["index.ts", "src"], + + "scripts": { + "test": "bun test" + }, + + "dependencies": { + "@noble/ed25519": "^2.1.0", + "jose": "^5.3.0", + "log": "git+https://git.pband.ch/typescript/log.git", + "misc": "git+https://git.pband.ch/typescript/misc.git" + }, + "devDependencies": { + "@happy-dom/global-registrator": "^14.10.2", + "@types/bun": "^1.1.2", + "logger-console": "git+https://git.pband.ch/typescript/logger-console.git" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } +} diff --git a/test/init.ts b/test/init.ts new file mode 100644 index 0000000..02ef1b1 --- /dev/null +++ b/test/init.ts @@ -0,0 +1,8 @@ +import {GlobalRegistrator} from '@happy-dom/global-registrator' +import {Console} from 'logger-console' +import {writers, Level} from 'log' + +GlobalRegistrator.register() + +const logger = new Console({ minLevel: Level.DEBUG, with_color: true }) +writers.set('console', logger) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..dd41062 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext","dom"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "allowJs": true, + "checkJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "forceConsistentCasingInFileNames": true, + "noPropertyAccessFromIndexSignature": false + }, + + "include": [ + "index.ts", + "src/**/*.ts" + ] +}