mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:09:41 +01:00
GraphQL, WebSocket, import, runner and CLI (M5, M6) plus packaging
- GraphQL editor with schema introspection, cached schema, autocomplete and explorer - WebSocket: auth and subprotocols in the handshake, text/JSON/hex/file messages, saved messages, live log with filter, search and export, reconnect with backoff - Import from Postman (collections and environments), Bruno, Insomnia, OpenAPI/Swagger and cURL; imported scripts are kept as docs, never run; credentials move to the gitignored secrets file - Code snippets for cURL, fetch, Python, HTTPie, Go, PowerShell; Postman export - Runner for folders and collections with JSON and JUnit reports - knock CLI: send, run, import, auth login/debug/logout - Large JSON responses parsed off the main thread - PKGBUILDs, desktop entry with knock:// handler, CI workflow, README
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<p><img src="logo/knock-wordmark-on-light.svg#gh-light-mode-only" alt="knock" height="48"><img src="logo/knock-wordmark-on-dark.svg#gh-dark-mode-only" alt="knock" height="48"></p>
|
||||
|
||||
An offline desktop API client for REST, GraphQL and WebSocket. No account, no cloud, no telemetry. Collections are folders of YAML files that live in your git repository.
|
||||
|
||||
## What makes it different
|
||||
|
||||
- **JSON bodies without typing brackets.** Every JSON body has a form view (keys, types, values, drag to reorder) and a code view on the same text. Switching is lossless: key order, `{{variables}}` as raw values and numbers larger than 2^53 survive. Attach a JSON Schema and the form suggests fields, marks required ones and validates while you type.
|
||||
- **OAuth that shows its work.** Enter the issuer, knock runs discovery. The redirect URI sits at the top with a copy button. Log in once; knock refreshes tokens, retries once after a 401 and attaches them. When something fails, the auth debugger marks the step, shows the raw exchange, offers it as cURL and explains the provider's error in plain words.
|
||||
|
||||
## Features
|
||||
|
||||
- HTTP/1.1 and HTTP/2, every method, query and path parameters synced with the URL, all body types, timeouts, redirect chain, TLS options, proxies, extra CA bundles, client certificates (PEM, PKCS#12), cookie jar per collection
|
||||
- Auth: Basic, Bearer, API key, Digest, JWT, AWS SigV4, OAuth 1.0a, OAuth 2.0 (authorization code + PKCE, client credentials, device code, password), OpenID Connect with ID token validation against the JWKS
|
||||
- Variables in every field with scopes runtime → request → folder → environment → collection → global, hover for value and origin, dynamic values (`{{$uuid}}`, `{{$timestamp}}`, …), extract rules for chaining
|
||||
- Secrets in the system keyring (Secret Service / KWallet) or a gitignored `*.secrets.yaml`, masked in history and exports
|
||||
- Response viewer with JSON tree, search and JSONPath filter, previews for HTML, images and PDF, diff against the previous response, timeline, bodies up to 50 MB without freezing
|
||||
- GraphQL with schema introspection, autocomplete and an explorer; WebSocket with composer, saved messages and a live log
|
||||
- Assertions, a runner for folders and collections, JUnit and JSON reports
|
||||
- Import from Postman, Bruno, Insomnia, OpenAPI and cURL; code snippets for cURL, fetch, Python, HTTPie, Go and PowerShell
|
||||
|
||||
## Collection format
|
||||
|
||||
```
|
||||
my-api/
|
||||
knock.yaml # name, collection auth, headers, variables
|
||||
environments/
|
||||
local.yaml
|
||||
prod.yaml
|
||||
prod.secrets.yaml # gitignored
|
||||
users/
|
||||
folder.yaml # folder auth, headers, variables, order
|
||||
create-user.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
name: Create user
|
||||
type: http
|
||||
method: POST
|
||||
url: "{{baseUrl}}/users"
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
content: |
|
||||
{
|
||||
"name": "{{userName}}",
|
||||
"roles": ["admin"]
|
||||
}
|
||||
extract:
|
||||
- { var: userId, from: json, path: $.id }
|
||||
assert:
|
||||
- { on: status, equals: 201 }
|
||||
```
|
||||
|
||||
Unknown fields are kept when knock saves a file, and changes from git or an editor are picked up live.
|
||||
|
||||
## Command line
|
||||
|
||||
```sh
|
||||
knock send users/create-user.yaml --env local
|
||||
knock run . --env staging --reporter junit --output report.xml
|
||||
knock auth login users --env prod # browser login, token shared with the app
|
||||
knock auth debug users --env prod --verbose
|
||||
```
|
||||
|
||||
`knock run` exits with 1 when an assertion fails. In CI, secrets come from `KNOCK_SECRET_<NAME>` environment variables (set `KNOCK_NO_KEYRING=1` where no keyring exists).
|
||||
|
||||
## Building
|
||||
|
||||
Requirements: Rust (stable), Node.js 20+, and on Linux `webkit2gtk-4.1`, `gtk3`, `libsecret`.
|
||||
|
||||
```sh
|
||||
npm ci
|
||||
npm run tauri dev # run the app
|
||||
npm run tauri build # deb, rpm, AppImage in target/release/bundle
|
||||
cargo build --release -p knock-cli
|
||||
cargo test -p knock-core
|
||||
```
|
||||
|
||||
Arch Linux: `packaging/arch/knock` builds from source, `packaging/arch/knock-bin` repackages the release `.deb`.
|
||||
|
||||
If the window stays blank on Wayland, WebKitGTK's DMA-BUF renderer is the usual cause; knock turns it off by default. Set `KNOCK_DMABUF=1` to turn it back on.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user