Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck authored Jun 12, 2024
1 parent 0e53714 commit 9be1a0d
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 186 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
[![deno.land/x](https://img.shields.io/badge/deno.land%2Fx-libs-0a3040?style=flat&logo=deno&labelColor=black)](https://deno.land/x/libs) [![Playground](https://img.shields.io/badge/Playground--black?style=flat&logo=windowsterminal&labelColor=black)](https://libs.lecoq.io)
[![ci](https://github.com/lowlighter/libs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/lowlighter/libs/actions/workflows/ci.yml)

This is a collection of carefully crafted _TypeScript_ libraries. These try to be minimal, unbloated and convenient.
This is a collection of carefully crafted _TypeScript_ libraries.
They try to be as minimal, unbloated and convenient as possible.

They honor [web standards](https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/The_web_and_web_standards) for maximum compatibility cross-runtimes which makes most of them compatible with [deno](https://deno.com) , [Node.js](https://nodejs.org),
[bun](https://bun.sh) and even browsers out of the box.
They honor [web standards](https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/The_web_and_web_standards) for maximum compatibility cross-runtime, which makes most of them compatible with [Deno](https://deno.com), [Node.js](https://nodejs.org),
[Bun](https://bun.sh) and even browsers out of the box.

See table below for a list of available libraries and their features, compatibility, test coverage and playgrounds.

Expand Down Expand Up @@ -198,31 +199,36 @@ See table below for a list of available libraries and their features, compatibil
<tr><th><a href="https://libs.lecoq.io/xml"><img src="https://img.shields.io/badge/Playground--black?style=flat&logo=windowsterminal&labelColor=black"></a></th></tr>
<tr><th><a href="https://libs-coverage.lecoq.io/xml"><img src="https://libs-coverage.lecoq.io/xml/badge.svg"></a></th></tr></table>

> Each package is versioned independently. Releases are fully automated and are published on every push to the `main` branch. Versioning follows [semver](https://semver.org) rules.
> Each package is versioned independently.
> Releases are fully automated and are published on every push to the `main` branch.
> Versioning follows [SemVer](https://semver.org) rules.
## 🧑‍💻 Cli utilities
## 🧑‍💻 CLI Utilities

A set of useful CLI scripts are also provided. Please note that these can only be run on deno runtime.
We also provide a set of useful CLI scripts.

> [!IMPORTANT] Please note that these only run on the Deno runtime.
### TypeScript code coverage enhancer

Enhance coverage reports generated with `deno coverage` by adding syntax highlighting and better styling thanks to [matcha.css](https://github.com/lowlighter/matcha).
Enhance coverage reports generated with `deno coverage` by adding syntax highlighting and better styling using [matcha.css](https://github.com/lowlighter/matcha).

```sh
deno run jsr:@libs/bundle/ts/cli/coverage --help
```

### TypeScript package publisher

Publish a TypeScript package to a npm registry (transpilation to JavaScript and conversion from `deno.jsonc` to `package.json` will automatically be performed) or to [deno.land/x](https://deno.land/x) (webhooks must be configured beforehand).
Publish a TypeScript package to an npm registry (transpilation to JavaScript and conversion from `deno.jsonc` to `package.json` will automatically be performed) or to [deno.land/x](https://deno.land/x) (webhooks must be configured beforehand).

```sh
deno run jsr:@libs/bundle/ts/cli/publish --help
```

### CSS formatter

Format CSS code similarly to `prettier` or `deno fmt`. Can be used with `--check` to validate that CSS code is correctly formatted.
Format CSS code similarly to `prettier` or `deno fmt`.
Use `--check` to validate that CSS code is correctly formatted.

```sh
deno run jsr:@libs/bundle/css/cli/fmt --help
Expand All @@ -238,18 +244,19 @@ deno run jsr:@libs/bundle/css/cli/check --help

### XHTML formatter

Format HTML and HTML/XML code similarly `deno fmt`. Can be used with `--check` to validate that HTML/XML code is correctly formatted.
Format HTML and HTML/XML code similarly `deno fmt`.
Use `--check` to validate that HTML/XML code is correctly formatted.

> [!WARNING]\
> This formatter is currently experimental and may **break** your documents (mainly reorder nodes, remove comments, wrongly self-close tag in HTML, etc.). It requires `--unstable` flag to be run without `--check` flag.
> This formatter is currently experimental and may **break** your documents (by reordering nodes, removing comments, wrongly self-closing tags in HTML, etc.).
> It requires `--unstable` flag to write changes; that is, to run without `--check` flag.
```sh
deno run jsr:@libs/bundle/xhtml/cli/fmt --help
```

### Web assembly builder

Compile a rust project to Web assembly and minify output.
Compile a Rust project to Web assembly and minify output.

```sh
deno run jsr:@libs/bundle/wasm/cli/build --help
Expand All @@ -259,7 +266,6 @@ deno run jsr:@libs/bundle/wasm/cli/build --help

This work is licensed under the [MIT License](./LICENSE).

If you include a significant part of it in your own project, _**you should keep the license notice**_ with it, including the mention of the additional original authors if any.
If you include a significant part of it in your own project, _**you must keep the license notice**_ with it, including the mention of the additional original authors if any.

> [!IMPORTANT]\
> Love these bytes ? Consider [`💝 sponsoring me`](https://github.com/sponsors/lowlighter), even one-time contributions are greatly appreciated !
> [!IMPORTANT] Love these bytes? Consider [`💝 sponsoring me`](https://github.com/sponsors/lowlighter), even one-time contributions are greatly appreciated!
43 changes: 15 additions & 28 deletions bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@

### ✨ Features

- Support passing either raw TypeScript string or file URL
- Support for banner option
- Minification enabled by default
- Support advanced minification through [Terser](https://terser.org)

### 📜 License and credits

```
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
https://github.com/lowlighter/libs/blob/main/LICENSE
```
- Support for passing either a raw TypeScript string or a file URL.
- Support for injecting comment banners (e.g., for licenses).
- Minification is enabled by default.
- Support for advanced minification through [Terser](https://terser.org).

## 🎨 CSS

Expand All @@ -29,31 +22,25 @@ https://github.com/lowlighter/libs/blob/main/LICENSE

### ✨ Features

- Support passing either raw CSS string or file URL
- Support for banner option
- Support minification through [CSSO](https://github.com/css/csso)
- Support fomatting and linting through [StyleLint](https://github.com/stylelint/stylelint)
- Compatibility checker against [MDN compatibility data](https://github.com/mdn/browser-compat-data)

### 📜 License and credits

```
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
https://github.com/lowlighter/libs/blob/main/LICENSE
```
- Support for passing either a raw CSS string or a file URL.
- Support for injecting comment banners (e.g., for licenses).
- Support for minification through [CSSO](https://github.com/css/csso).
- Support for formatting and linting through [StyleLint](https://github.com/stylelint/stylelint).
- Support form compatibility checking against [MDN compatibility data](https://github.com/mdn/browser-compat-data).

## 🔬 WASM

Launch `wasm-pack` for a Rust project, inject generated bindings as a base64 string and minify the JS output!

- [`📚 Documentation`](https://jsr.io/@libs/bundle/doc/wasm/~)

### ✨ Features

- Launch `wasm-pack` for a rust project, inject generated bindings as base64 string and minify JS output
- Support for banner option
- Support for injecting comment banners (e.g., for licenses).

### 📜 License and credits
## 📜 License and credits

```
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
```plaintext
Copyright (c) Simon Lecoq <@lowlighter>. (MIT License)
https://github.com/lowlighter/libs/blob/main/LICENSE
```
4 changes: 2 additions & 2 deletions bundle/css/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import { SEPARATOR } from "@std/path/constants"
* A banner option can be provided to prepend a comment to the output, which can be useful for licensing information.
*
* @example
* ```
* ```ts
* // From file
* import { bundle } from "./bundle.ts"
* console.log(await bundle(new URL("testing/test_bundle.css", import.meta.url)))
* ```
*
* @example
* ```
* ```ts
* // From string
* import { bundle } from "./bundle.ts"
* console.log(await bundle(`body { color: salmon; }`))
Expand Down
4 changes: 2 additions & 2 deletions bundle/css/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const vendors = /^(?:@|::|:)?(?<prefix>-(?:webkit|moz|o|ms|__debug)-)/
* ```
* ________________________________________________________________________________
*
* Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
* Copyright (c) Simon Lecoq <@lowlighter>. (MIT License)
* https://github.com/lowlighter/libs/blob/main/LICENSE
*
* @author Simon Lecoq (lowlighter)
Expand Down Expand Up @@ -129,7 +129,7 @@ export async function compatibility(input: URL | string, { query = "defaults", l
* ```
* ________________________________________________________________________________
*
* Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
* Copyright (c) Simon Lecoq <@lowlighter>. (MIT License)
* https://github.com/lowlighter/libs/blob/main/LICENSE
*
* @author Simon Lecoq (lowlighter)
Expand Down
3 changes: 2 additions & 1 deletion bundle/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"**/package-lock.json",
"**/wasm_*",
"**/*.mjs"
]
],
"proseWrap": "preserve"
}
}
6 changes: 3 additions & 3 deletions bundle/ts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import { delay } from "@std/async/delay"
* Use the `shadow` option to replace the local URLs (using `file://` scheme) with a shadow url to avoid exposing real paths.
*
* @example
* ```
* ```ts
* // From file
* import { bundle } from "./bundle.ts"
* console.log(await bundle(new URL(import.meta.url)))
* ```
* @example
* ```
* ```ts
* // From string
* import { bundle } from "./bundle.ts"
* console.log(await bundle(new URL(import.meta.url), { config: new URL("deno.jsonc", import.meta.url) }))
* ```
*
* @example
* ```
* ```ts
* // From string
* import { bundle } from "./bundle.ts"
* console.log(await bundle(`console.log("Hello world")`))
Expand Down
45 changes: 19 additions & 26 deletions crypto/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
# 🧮 Crypto utilities
# 🧮 Cryptographic utilities

[![JSR](https://jsr.io/badges/@libs/crypto)](https://jsr.io/@libs/crypto) [![JSR Score](https://jsr.io/badges/@libs/crypto/score)](https://jsr.io/@libs/crypto)
[![NPM](https://img.shields.io/npm/v/@lowlighter%2Fcrypto?logo=npm&labelColor=cb0000&color=183e4e)](https://www.npmjs.com/package/@lowlighter/crypto) [![Coverage](https://libs-coverage.lecoq.io/crypto/badge.svg)](https://libs-coverage.lecoq.io/crypto)

## 🔑 Time-based One-Time Password (TOTP)

Issue a new TOTP secret with metadata (issuer, account, image, etc.).

- [`🦕 Playground`](https://libs.lecoq.io/crypto/totp)
- [`📚 Documentation`](https://jsr.io/@libs/crypto/doc/totp/~)

### ✨ Features

- Issue a new TOTP secret with metadata (issuer, account, image, etc.)
- No external dependencies
- Lightweight

### 📜 License and credits

```
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
https://github.com/lowlighter/libs/blob/main/LICENSE
```

This library is based on the well-written article of [@rajat-sr](https://github.com/rajat-sr) on [hackernoon](https://hackernoon.com) :
- Has no external dependencies.
- Is lightweight.

- [How To Implement Google Authenticator Two Factor Auth in JavaScript](https://hackernoon.com/how-to-implement-google-authenticator-two-factor-auth-in-javascript-091wy3vh3)
This library is based on the well-written article of [@rajat-sr](https://github.com/rajat-sr) [How To Implement Google Authenticator Two Factor Auth in JavaScript](https://hackernoon.com/how-to-implement-google-authenticator-two-factor-auth-in-javascript-091wy3vh3)

## 🔐 Symmetric encryption (using AES-GCM 256 with a PBKDF2 derived key)

Expand All @@ -32,24 +24,25 @@ This library is based on the well-written article of [@rajat-sr](https://github.

### ✨ Features

- Use native [`Web Crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) APIs
- Use [`AES-GCM 256-bits`](https://en.wikipedia.org/wiki/Galois/Counter_Mode) with [`PBKDF2`](https://en.wikipedia.org/wiki/PBKDF2) derived key to encrypt and decrypt messages
- Encrypted messages are different each time thanks to [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector)
- The derived key from a given `seed`/`password` are always the same
- Added functionalities which also introduce additional entropy:
- With [SHA-256](https://en.wikipedia.org/wiki/SHA-2) to guarantee integrity
- With stored size to guarantee integrity _(for messages with length < 255)_
- With padding to force length be `256` or `512` bytes and obfuscate the original size _(can be disabled using `0` as value)_
- Use the native [`Web Crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) APIs.
- Uses a [`AES-GCM 256-bits`](https://en.wikipedia.org/wiki/Galois/Counter_Mode) with [`PBKDF2`](https://en.wikipedia.org/wiki/PBKDF2)-derived key to encrypt and decrypt messages.
- Encrypted messages are different each time thanks to an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector).
- The derived keys from a given `seed`/`password` are always the same.
- Includes functionalities to introduce additional entropy:
- Support for [SHA-256](https://en.wikipedia.org/wiki/SHA-2) to guarantee integrity.
- Support for retaining the stored size to help verify integrity _(for messages with length < 255)_
- Support for adding padding to force length be `256` or `512` bytes and obfuscate the original size _(can be disabled using `0` as value)_

### 📜 License and credits
## 📜 License and credits

```
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
```plaintext
Copyright (c) Simon Lecoq <@lowlighter>. (MIT License)
https://github.com/lowlighter/libs/blob/main/LICENSE
```

> [!CAUTION]
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND
>
> The author is not responsible for any damage that could be caused by the use of this library. It is your responsibility to use it properly and to understand the security implications of the choices you make.
> The author is not responsible for any damage that could be caused by the use of this library.
> It is your responsibility to use it properly and to understand the security implications of the choices you make.
3 changes: 2 additions & 1 deletion crypto/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"**/package-lock.json",
"**/wasm_*",
"**/*.mjs"
]
],
"proseWrap": "preserve"
}
}
6 changes: 3 additions & 3 deletions crypto/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function hash(message: string, { algorithm = "SHA-256" as Algorithm
* Encrypt message with key.
*
* It returns an hexadecimal string structured as follows:
* ```
* ```plaintext
* ┌──────────────────────┬─────────────────┬────────────┬───────────┬────────────┬╴╴╴╴╴╴╴╴╴╴╴╴╴╴┐
* │ Initial Vector [16b] │ Signature [16b] │ Hash [64b] │ Size [8b] │ Value [Xb] │ Padding [Yb] ┊
* └──────────────────────┴─────────────────┴────────────┴───────────┴────────────┴╴╴╴╴╴╴╴╴╴╴╴╴╴╴┘
Expand Down Expand Up @@ -165,7 +165,7 @@ export async function decrypt(message: string, { key }: { key: CryptoKey | strin
* Convert encryption key to {@link https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey | CryptoKey}.
*
* @example
* ```
* ```ts
* import { importKey } from "./encryption.ts"
* console.assert(await importKey("e8bf6e323c23036402989c3e89fe8e6219c18edbfde74a461b5f27d806e51f47") instanceof CryptoKey)
* ```
Expand All @@ -178,7 +178,7 @@ export async function importKey(key: string): Promise<CryptoKey> {
* Generate encryption key from seed and salt.
*
* @example
* ```
* ```ts
* import { exportKey } from "./encryption.ts"
* console.assert(typeof await exportKey({ seed: "", salt: "" }) === "string")
* ```
Expand Down
10 changes: 5 additions & 5 deletions crypto/totp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* https://hackernoon.com/how-to-implement-google-authenticator-two-factor-auth-in-javascript-091wy3vh3
*
* Significant changes includes:
* - Use of native WebCrypto and Typed buffer APIs instead of Node.js APIs
* - Follow the Google Authenticator spec at https://github.com/google/google-authenticator/wiki/Key-Uri-Format
* - Ignored parameters are hard-coded to their default values
* - Code was condensed
* - Use of native WebCrypto and TypedBuffer APIs instead of Node.js APIs.
* - Follow the Google Authenticator spec at <https://github.com/google/google-authenticator/wiki/Key-Uri-Format>.
* - Ignore parameters are hard-coded to their default values.
* - Condense code.
*
* @example
* ```ts
Expand All @@ -30,7 +30,7 @@
* https://www.verifyr.com/en/otp/check
* ________________________________________________________________________________
*
* Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
* Copyright (c) Simon Lecoq <@lowlighter>. (MIT License)
* https://github.com/lowlighter/libs/blob/main/LICENSE
* @module
*/
Expand Down
3 changes: 2 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"**/package-lock.json",
"**/wasm_*",
"**/*.mjs"
]
],
"proseWrap": "preserve"
}
}
Loading

0 comments on commit 9be1a0d

Please sign in to comment.