@stacksjs/tlsx
Version:
A TLS/HTTPS library with automation.
151 lines (100 loc) • 4.28 kB
Markdown
<p align="center"><img src=".github/art/cover.png" alt="Social Card of this repo"></p>
[![npm version][npm-version-src]][npm-version-href]
[![GitHub Actions][github-actions-src]][github-actions-href]
[](http://commitizen.github.io/cz-cli/)
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
<!-- [![Codecov][codecov-src]][codecov-href] -->
>
- SSL Support _(HTTPS by default)_
- Automatically Renews Expired Certificates
- Configurable
```bash
bun install -d @stacksjs/tlsx
bunx @stacksjs/tlsx
npx @stacksjs/tlsx
```
Please note, we are looking to publish this package to npm under the name `tlsx`. _Hoping npm will release the name for us._
<!-- _Alternatively, you can install:_
```bash
brew install tlsx
pkgx install tlsx
``` -->
There are two ways of using this reverse proxy: _as a library or as a CLI._
Given the npm package is installed:
```ts
import type { AddCertOptions, CAOptions, CertificateOptions, TlsConfig, TlsOptions } from '@stacksjs/tlsx'
import { addCertToSystemTrustStoreAndSaveCerts, config, forge, generateCert, pki, storeCertificate, tls } from '@stacksjs/tlsx'
// ...
```
```bash
tlsx --help
tlsx version
```
The Reverse Proxy can be configured using a `tls.config.ts` _(or `tls.config.js`)_ file and it will be automatically loaded when running the `tlsx` command.
```ts
// tlsx.config.{ts,js}
import type { TlsConfig } from '@stacksjs/tlsx'
export default {
domain: 'stacks.localhost',
hostCertCN: 'stacks.localhost',
caCertPath: path.join(os.homedir(), '.stacks', 'ssl', `tlsx.localhost.ca.crt`),
certPath: path.join(os.homedir(), '.stacks', 'ssl', `tlsx.localhost.crt`),
keyPath: path.join(os.homedir(), '.stacks', 'ssl', `tlsx.localhost.crt.key`),
altNameIPs: ['127.0.0.1'],
altNameURIs: ['localhost'],
organizationName: 'stacksjs.org',
countryName: 'US',
stateName: 'California',
localityName: 'Playa Vista',
commonName: 'stacks.localhost',
validityDays: 180,
verbose: false,
} satisfies TlsConfig
```
_Then run:_
```bash
tlsx
```
To learn more, head over to the [documentation](https://tlsx.sh/).
```bash
bun test
```
Please see our [releases](https://github.com/stacksjs/tlsx/releases) page for more information on what has changed recently.
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
[](https://github.com/stacksjs/stacks/discussions)
For casual chit-chat with others using this package:
[](https://discord.gg/stacksjs)
Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 _We also publish them on our website._
Our address: Stacks.js, 12665 Village Ln
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
- [JetBrains](https://www.jetbrains.com/)
- [The Solana Foundation](https://solana.com/)
- [Chris Breuer](https://github.com/chrisbbreuer)
- [All Contributors](../../contributors)
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
Made with 💙
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/tlsx?style=flat-square
[npm-version-href]: https://npmjs.com/package/@stacksjs/tlsx
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/tlsx/ci.yml?style=flat-square&branch=main
[github-actions-href]: https://github.com/stacksjs/tlsx/actions?query=workflow%3Aci
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/tlsx/main?style=flat-square
[codecov-href]: https://codecov.io/gh/stacksjs/tlsx -->