aj-tool 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/bin/aj.js +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +64 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/apikey/get.d.ts +3 -0
- package/dist/commands/apikey/get.d.ts.map +1 -0
- package/dist/commands/apikey/get.js +25 -0
- package/dist/commands/apikey/get.js.map +1 -0
- package/dist/commands/auth/login.d.ts +3 -0
- package/dist/commands/auth/login.d.ts.map +1 -0
- package/dist/commands/auth/login.js +38 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/auth/logout.d.ts +3 -0
- package/dist/commands/auth/logout.d.ts.map +1 -0
- package/dist/commands/auth/logout.js +12 -0
- package/dist/commands/auth/logout.js.map +1 -0
- package/dist/commands/auth/whoami.d.ts +3 -0
- package/dist/commands/auth/whoami.d.ts.map +1 -0
- package/dist/commands/auth/whoami.js +24 -0
- package/dist/commands/auth/whoami.js.map +1 -0
- package/dist/commands/request/get.d.ts +3 -0
- package/dist/commands/request/get.d.ts.map +1 -0
- package/dist/commands/request/get.js +46 -0
- package/dist/commands/request/get.js.map +1 -0
- package/dist/commands/request/index.d.ts +3 -0
- package/dist/commands/request/index.d.ts.map +1 -0
- package/dist/commands/request/index.js +10 -0
- package/dist/commands/request/index.js.map +1 -0
- package/dist/commands/request/list.d.ts +3 -0
- package/dist/commands/request/list.d.ts.map +1 -0
- package/dist/commands/request/list.js +37 -0
- package/dist/commands/request/list.js.map +1 -0
- package/dist/commands/rule/create.d.ts +3 -0
- package/dist/commands/rule/create.d.ts.map +1 -0
- package/dist/commands/rule/create.js +35 -0
- package/dist/commands/rule/create.js.map +1 -0
- package/dist/commands/rule/delete.d.ts +3 -0
- package/dist/commands/rule/delete.d.ts.map +1 -0
- package/dist/commands/rule/delete.js +32 -0
- package/dist/commands/rule/delete.js.map +1 -0
- package/dist/commands/rule/index.d.ts +3 -0
- package/dist/commands/rule/index.d.ts.map +1 -0
- package/dist/commands/rule/index.js +12 -0
- package/dist/commands/rule/index.js.map +1 -0
- package/dist/commands/rule/list.d.ts +3 -0
- package/dist/commands/rule/list.d.ts.map +1 -0
- package/dist/commands/rule/list.js +34 -0
- package/dist/commands/rule/list.js.map +1 -0
- package/dist/commands/site/create.d.ts +3 -0
- package/dist/commands/site/create.d.ts.map +1 -0
- package/dist/commands/site/create.js +29 -0
- package/dist/commands/site/create.js.map +1 -0
- package/dist/commands/site/delete.d.ts +3 -0
- package/dist/commands/site/delete.d.ts.map +1 -0
- package/dist/commands/site/delete.js +32 -0
- package/dist/commands/site/delete.js.map +1 -0
- package/dist/commands/site/index.d.ts +3 -0
- package/dist/commands/site/index.d.ts.map +1 -0
- package/dist/commands/site/index.js +12 -0
- package/dist/commands/site/index.js.map +1 -0
- package/dist/commands/site/list.d.ts +3 -0
- package/dist/commands/site/list.d.ts.map +1 -0
- package/dist/commands/site/list.js +22 -0
- package/dist/commands/site/list.js.map +1 -0
- package/dist/commands/site/rename.d.ts +3 -0
- package/dist/commands/site/rename.d.ts.map +1 -0
- package/dist/commands/site/rename.js +27 -0
- package/dist/commands/site/rename.js.map +1 -0
- package/dist/commands/team/create.d.ts +3 -0
- package/dist/commands/team/create.d.ts.map +1 -0
- package/dist/commands/team/create.js +24 -0
- package/dist/commands/team/create.js.map +1 -0
- package/dist/commands/team/delete.d.ts +3 -0
- package/dist/commands/team/delete.d.ts.map +1 -0
- package/dist/commands/team/delete.js +34 -0
- package/dist/commands/team/delete.js.map +1 -0
- package/dist/commands/team/index.d.ts +3 -0
- package/dist/commands/team/index.d.ts.map +1 -0
- package/dist/commands/team/index.js +10 -0
- package/dist/commands/team/index.js.map +1 -0
- package/dist/commands/team/list.d.ts +3 -0
- package/dist/commands/team/list.d.ts.map +1 -0
- package/dist/commands/team/list.js +24 -0
- package/dist/commands/team/list.js.map +1 -0
- package/dist/lib/api-client.d.ts +25 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +130 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/auth.d.ts +5 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +29 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/config.d.ts +8 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +36 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +7 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +12 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/errors.d.ts +18 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +35 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/output.d.ts +18 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +101 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/types.d.ts +508 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +104 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/validators.d.ts +10 -0
- package/dist/lib/validators.d.ts.map +1 -0
- package/dist/lib/validators.js +60 -0
- package/dist/lib/validators.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Dechrai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Arcjet CLI (`aj`)
|
|
2
|
+
|
|
3
|
+
An unofficial command-line interface for managing [Arcjet](https://arcjet.com) teams, sites, API keys, rules, and request logs.
|
|
4
|
+
|
|
5
|
+
## Why not the MCP server?
|
|
6
|
+
|
|
7
|
+
Arcjet publishes an [MCP server](https://github.com/arcjet/arcjet-mcp) that
|
|
8
|
+
works well when your AI tooling supports it. But MCP servers need to be held in
|
|
9
|
+
context for the duration of a session, consuming resources even when Arcjet
|
|
10
|
+
interaction is only needed occasionally.
|
|
11
|
+
|
|
12
|
+
A CLI is simpler. Any coding agent, script, or CI pipeline can shell out to `aj`
|
|
13
|
+
when needed and move on. All you need in your `AGENTS.md` or `CLAUDE.md` is:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Use `aj` to interact with Arcjet (manage teams, sites, API keys, rules, and request logs).
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
No persistent connections, no protocol negotiation, no context window cost.
|
|
20
|
+
|
|
21
|
+
I built this for my own workflow. When I showed friends, they wanted it too --
|
|
22
|
+
so here it is.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
Requires Node.js >= 22.
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm install -g aj-tool
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or run directly with npx:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npx aj-tool team list
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Authentication
|
|
39
|
+
|
|
40
|
+
The CLI uses your Arcjet dashboard session cookie for authentication. To log in:
|
|
41
|
+
|
|
42
|
+
1. Sign in to [app.arcjet.com](https://app.arcjet.com) in your browser
|
|
43
|
+
2. Open DevTools > Application > Cookies
|
|
44
|
+
3. Copy the value of the `session` cookie
|
|
45
|
+
4. Run:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
aj login
|
|
49
|
+
# Paste your session cookie when prompted
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For CI/scripting, pass the session directly:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
aj login --session <value>
|
|
56
|
+
# or set the environment variable
|
|
57
|
+
export ARCJET_SESSION=<value>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Your session is stored in `~/.config/arcjet/config.json` with 0600 permissions.
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Teams
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
aj team list
|
|
68
|
+
aj team create "My Team"
|
|
69
|
+
aj team delete --team-id team_01abc...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Sites
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
aj site list --team-id team_01abc...
|
|
76
|
+
aj site create --team-id team_01abc... "My Site"
|
|
77
|
+
aj site rename --site-id site_01abc... "New Name"
|
|
78
|
+
aj site delete --site-id site_01abc...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### API Keys
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
aj apikey --site-id site_01abc...
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Request Logs
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
aj request list --site-id site_01abc... --limit 50
|
|
91
|
+
aj request get --site-id site_01abc... req_01abc...
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Rules
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
aj rule list --site-id site_01abc...
|
|
98
|
+
aj rule create --site-id site_01abc... '{"shield": {"mode": "MODE_LIVE"}}'
|
|
99
|
+
aj rule delete --site-id site_01abc... remote_rule_01abc...
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Account
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
aj whoami
|
|
106
|
+
aj logout
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Global Options
|
|
110
|
+
|
|
111
|
+
| Flag | Description |
|
|
112
|
+
|------|-------------|
|
|
113
|
+
| `--json` | Output raw JSON (useful for scripting and piping) |
|
|
114
|
+
| `--no-color` | Disable colored output |
|
|
115
|
+
| `--verbose` | Show debug information including API calls |
|
|
116
|
+
| `--version` | Print version |
|
|
117
|
+
| `--help` | Show help for any command |
|
|
118
|
+
|
|
119
|
+
Example:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
aj site list --team-id team_01abc... --json | jq '.[].name'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Development
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
git clone https://github.com/bendechrai/aj-tool.git
|
|
129
|
+
cd aj-tool
|
|
130
|
+
npm install
|
|
131
|
+
npm run build
|
|
132
|
+
node bin/aj.js --help
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
For watch mode during development:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
npm run dev # tsc --watch in one terminal
|
|
139
|
+
node bin/aj.js team list # test in another
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## How the API Was Documented
|
|
143
|
+
|
|
144
|
+
This project interacts with Arcjet's management API, which was documented entirely
|
|
145
|
+
from publicly available sources:
|
|
146
|
+
|
|
147
|
+
- Arcjet's open-source repositories ([arcjet-js](https://github.com/arcjet/arcjet-js),
|
|
148
|
+
[arcjet-py](https://github.com/arcjet/arcjet-py),
|
|
149
|
+
[@arcjet/mcp](https://github.com/arcjet/arcjet-mcp))
|
|
150
|
+
- Standard browser DevTools network inspection of the public Arcjet dashboard
|
|
151
|
+
|
|
152
|
+
No insider knowledge, private APIs, decompilation, or unauthorized access was used.
|
|
153
|
+
See [docs/API_DISCOVERY_METHODOLOGY.md](docs/API_DISCOVERY_METHODOLOGY.md) for full
|
|
154
|
+
details, and [docs/API_REFERENCE.yaml](docs/API_REFERENCE.yaml) for the OpenAPI spec.
|
|
155
|
+
|
|
156
|
+
## Disclaimer
|
|
157
|
+
|
|
158
|
+
This is an **unofficial** project and is not affiliated with, endorsed by, or
|
|
159
|
+
supported by Arcjet. It interacts with Arcjet's web API, which is undocumented and
|
|
160
|
+
may change at any time without notice. Use at your own risk.
|
|
161
|
+
|
|
162
|
+
"Arcjet" is a trademark of Arcjet Limited. This project uses the name solely to
|
|
163
|
+
describe its functionality.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
package/bin/aj.js
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { VERSION } from "./lib/constants.js";
|
|
3
|
+
import { configure, error, isVerbose } from "./lib/output.js";
|
|
4
|
+
import { ArcjetCliError, AuthError } from "./lib/errors.js";
|
|
5
|
+
import { registerLoginCommand } from "./commands/auth/login.js";
|
|
6
|
+
import { registerLogoutCommand } from "./commands/auth/logout.js";
|
|
7
|
+
import { registerWhoamiCommand } from "./commands/auth/whoami.js";
|
|
8
|
+
import { registerTeamCommands } from "./commands/team/index.js";
|
|
9
|
+
import { registerSiteCommands } from "./commands/site/index.js";
|
|
10
|
+
import { registerApiKeyCommand } from "./commands/apikey/get.js";
|
|
11
|
+
import { registerRequestCommands } from "./commands/request/index.js";
|
|
12
|
+
import { registerRuleCommands } from "./commands/rule/index.js";
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program
|
|
15
|
+
.name("aj")
|
|
16
|
+
.description("Arcjet CLI -- manage teams, sites, and resources")
|
|
17
|
+
.version(VERSION)
|
|
18
|
+
.option("--json", "Output raw JSON", false)
|
|
19
|
+
.option("--no-color", "Disable colored output")
|
|
20
|
+
.option("--verbose", "Enable verbose output", false);
|
|
21
|
+
// Configure output from global options before any command runs
|
|
22
|
+
program.hook("preAction", (thisCommand) => {
|
|
23
|
+
const opts = thisCommand.opts();
|
|
24
|
+
configure(opts);
|
|
25
|
+
});
|
|
26
|
+
// Auth commands (registered on root)
|
|
27
|
+
registerLoginCommand(program);
|
|
28
|
+
registerLogoutCommand(program);
|
|
29
|
+
registerWhoamiCommand(program);
|
|
30
|
+
// Resource commands
|
|
31
|
+
registerTeamCommands(program);
|
|
32
|
+
registerSiteCommands(program);
|
|
33
|
+
registerApiKeyCommand(program);
|
|
34
|
+
registerRequestCommands(program);
|
|
35
|
+
registerRuleCommands(program);
|
|
36
|
+
async function main() {
|
|
37
|
+
try {
|
|
38
|
+
await program.parseAsync(process.argv);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof AuthError) {
|
|
42
|
+
error(err.message);
|
|
43
|
+
process.exit(err.exitCode);
|
|
44
|
+
}
|
|
45
|
+
if (err instanceof ArcjetCliError) {
|
|
46
|
+
error(err.message);
|
|
47
|
+
if (isVerbose() && err.stack) {
|
|
48
|
+
console.error(err.stack);
|
|
49
|
+
}
|
|
50
|
+
process.exit(err.exitCode);
|
|
51
|
+
}
|
|
52
|
+
if (err instanceof Error) {
|
|
53
|
+
error(err.message);
|
|
54
|
+
if (isVerbose() && err.stack) {
|
|
55
|
+
console.error(err.stack);
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
error("An unexpected error occurred.");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
main();
|
|
64
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,IAAI,CAAC;KACV,WAAW,CAAC,kDAAkD,CAAC;KAC/D,OAAO,CAAC,OAAO,CA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,CAAC;YAC3B,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACnB,IAAI,SAAS,EAAE,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/apikey/get.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqB5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { requireAuth } from "../../lib/auth.js";
|
|
3
|
+
import { validateSiteId } from "../../lib/validators.js";
|
|
4
|
+
import { isJsonMode, printJson, printRecord } from "../../lib/output.js";
|
|
5
|
+
export function registerApiKeyCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command("apikey")
|
|
8
|
+
.description("Get the API key for a site")
|
|
9
|
+
.requiredOption("--site-id <siteId>", "Site ID")
|
|
10
|
+
.action(async (options) => {
|
|
11
|
+
const siteId = validateSiteId(options.siteId);
|
|
12
|
+
const session = requireAuth();
|
|
13
|
+
const client = new ArcjetApiClient(session);
|
|
14
|
+
const site = await client.getSite(siteId);
|
|
15
|
+
if (isJsonMode()) {
|
|
16
|
+
printJson({ key: site.key, siteId: site.id, name: site.name });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
printRecord({
|
|
20
|
+
Site: site.name,
|
|
21
|
+
Key: site.key,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/apikey/get.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEzE,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,4BAA4B,CAAC;SACzC,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC;SAC/C,MAAM,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;QAED,WAAW,CAAC;YACV,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAuC1D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { saveSession } from "../../lib/auth.js";
|
|
3
|
+
import { success, error, info, prompt, isJsonMode, printJson } from "../../lib/output.js";
|
|
4
|
+
export function registerLoginCommand(parent) {
|
|
5
|
+
parent
|
|
6
|
+
.command("login")
|
|
7
|
+
.description("Authenticate with Arcjet")
|
|
8
|
+
.option("--session <value>", "Session cookie value (non-interactive)")
|
|
9
|
+
.action(async (options) => {
|
|
10
|
+
let session = options.session;
|
|
11
|
+
if (!session) {
|
|
12
|
+
info("Log in to https://app.arcjet.com in your browser.");
|
|
13
|
+
info("Open DevTools > Application > Cookies > copy the 'session' cookie value.");
|
|
14
|
+
info("");
|
|
15
|
+
session = await prompt("Paste your session cookie: ");
|
|
16
|
+
}
|
|
17
|
+
if (!session) {
|
|
18
|
+
error("No session provided.");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const client = new ArcjetApiClient(session);
|
|
22
|
+
try {
|
|
23
|
+
const user = await client.validateSession();
|
|
24
|
+
saveSession(session);
|
|
25
|
+
if (isJsonMode()) {
|
|
26
|
+
printJson(user);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
success(`Logged in as ${user.name} (${user.email})`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
error("Invalid session. Make sure you copied the full cookie value.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE1F,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAClD,MAAM;SACH,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0BAA0B,CAAC;SACvC,MAAM,CAAC,mBAAmB,EAAE,wCAAwC,CAAC;SACrE,MAAM,CAAC,KAAK,EAAE,OAA6B,EAAE,EAAE;QAC9C,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAE9B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,mDAAmD,CAAC,CAAC;YAC1D,IAAI,CACF,0EAA0E,CAC3E,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,CAAC;YACT,OAAO,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;YAC5C,WAAW,CAAC,OAAO,CAAC,CAAC;YAErB,IAAI,UAAU,EAAE,EAAE,CAAC;gBACjB,SAAS,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,gBAAgB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,CACH,8DAA8D,CAC/D,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAQ3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { clearSession } from "../../lib/auth.js";
|
|
2
|
+
import { success } from "../../lib/output.js";
|
|
3
|
+
export function registerLogoutCommand(parent) {
|
|
4
|
+
parent
|
|
5
|
+
.command("logout")
|
|
6
|
+
.description("Clear stored Arcjet session")
|
|
7
|
+
.action(() => {
|
|
8
|
+
clearSession();
|
|
9
|
+
success("Logged out.");
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,UAAU,qBAAqB,CAAC,MAAe;IACnD,MAAM;SACH,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,GAAG,EAAE;QACX,YAAY,EAAE,CAAC;QACf,OAAO,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAmB3D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { requireAuth } from "../../lib/auth.js";
|
|
3
|
+
import { printJson, printRecord, isJsonMode } from "../../lib/output.js";
|
|
4
|
+
export function registerWhoamiCommand(parent) {
|
|
5
|
+
parent
|
|
6
|
+
.command("whoami")
|
|
7
|
+
.description("Show the current authenticated user")
|
|
8
|
+
.action(async () => {
|
|
9
|
+
const session = requireAuth();
|
|
10
|
+
const client = new ArcjetApiClient(session);
|
|
11
|
+
const user = await client.validateSession();
|
|
12
|
+
if (isJsonMode()) {
|
|
13
|
+
printJson(user);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
printRecord({
|
|
17
|
+
Name: user.name,
|
|
18
|
+
Email: user.email,
|
|
19
|
+
Expires: user.expires,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/commands/auth/whoami.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzE,MAAM,UAAU,qBAAqB,CAAC,MAAe;IACnD,MAAM;SACH,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,qCAAqC,CAAC;SAClD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;QAE5C,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,WAAW,CAAC;gBACV,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/request/get.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CA4C/D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { requireAuth } from "../../lib/auth.js";
|
|
3
|
+
import { validateSiteId, validateRequestId } from "../../lib/validators.js";
|
|
4
|
+
import { isJsonMode, printJson, printRecord } from "../../lib/output.js";
|
|
5
|
+
export function registerRequestGetCommand(parent) {
|
|
6
|
+
parent
|
|
7
|
+
.command("get")
|
|
8
|
+
.description("Get details for a specific request")
|
|
9
|
+
.requiredOption("--site-id <siteId>", "Site ID")
|
|
10
|
+
.argument("<requestId>", "Request ID")
|
|
11
|
+
.action(async (requestId, options) => {
|
|
12
|
+
const siteId = validateSiteId(options.siteId);
|
|
13
|
+
const reqId = validateRequestId(requestId);
|
|
14
|
+
const session = requireAuth();
|
|
15
|
+
const client = new ArcjetApiClient(session);
|
|
16
|
+
const request = await client.getRequest(siteId, reqId);
|
|
17
|
+
if (isJsonMode()) {
|
|
18
|
+
printJson(request);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
printRecord({
|
|
22
|
+
ID: request.id,
|
|
23
|
+
Conclusion: request.conclusion.replace("CONCLUSION_", ""),
|
|
24
|
+
Reason: (request.reason ?? "").replace("REASON_", ""),
|
|
25
|
+
Method: request.method ?? "",
|
|
26
|
+
Path: request.path ?? "",
|
|
27
|
+
Host: request.host ?? "",
|
|
28
|
+
IP: request.ip ?? "",
|
|
29
|
+
Protocol: request.protocol ?? "",
|
|
30
|
+
SDK: [request.sdk_stack, request.sdk_version]
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.join(" "),
|
|
33
|
+
Suspicious: request.suspicious ? "Yes" : "No",
|
|
34
|
+
Received: request.received_at ?? "",
|
|
35
|
+
});
|
|
36
|
+
if (request.reason_details) {
|
|
37
|
+
console.log("\nReason Details:");
|
|
38
|
+
console.log(JSON.stringify(request.reason_details, null, 2));
|
|
39
|
+
}
|
|
40
|
+
if (request.rules_results && request.rules_results.length > 0) {
|
|
41
|
+
console.log("\nRule Results:");
|
|
42
|
+
console.log(JSON.stringify(request.rules_results, null, 2));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/request/get.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE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Q,IAAI,EAAE;YAChC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;iBAC1C,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,GAAG,CAAC;YACZ,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YAC7C,QAAQ,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;SACpC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/request/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAO9D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { registerRequestListCommand } from "./list.js";
|
|
2
|
+
import { registerRequestGetCommand } from "./get.js";
|
|
3
|
+
export function registerRequestCommands(program) {
|
|
4
|
+
const request = program
|
|
5
|
+
.command("request")
|
|
6
|
+
.description("Inspect Arcjet request logs");
|
|
7
|
+
registerRequestListCommand(request);
|
|
8
|
+
registerRequestGetCommand(request);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/request/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,6BAA6B,CAAC,CAAC;IAE9C,0BAA0B,CAAC,OAAO,CAAC,CAAC;IACpC,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/request/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAuChE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { requireAuth } from "../../lib/auth.js";
|
|
3
|
+
import { validateSiteId } from "../../lib/validators.js";
|
|
4
|
+
import { isJsonMode, printJson, printTable, info } from "../../lib/output.js";
|
|
5
|
+
export function registerRequestListCommand(parent) {
|
|
6
|
+
parent
|
|
7
|
+
.command("list")
|
|
8
|
+
.description("List requests for a site")
|
|
9
|
+
.requiredOption("--site-id <siteId>", "Site ID")
|
|
10
|
+
.option("--limit <n>", "Max results", "20")
|
|
11
|
+
.option("--cursor <cursor>", "Pagination cursor")
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const siteId = validateSiteId(options.siteId);
|
|
14
|
+
const session = requireAuth();
|
|
15
|
+
const client = new ArcjetApiClient(session);
|
|
16
|
+
const result = await client.listRequests(siteId, {
|
|
17
|
+
limit: parseInt(options.limit, 10),
|
|
18
|
+
cursor: options.cursor,
|
|
19
|
+
});
|
|
20
|
+
if (isJsonMode()) {
|
|
21
|
+
printJson(result);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
printTable(["ID", "Conclusion", "Reason", "Path", "IP", "Received"], result.data.map((r) => [
|
|
25
|
+
r.id,
|
|
26
|
+
r.conclusion.replace("CONCLUSION_", ""),
|
|
27
|
+
(r.reason ?? "").replace("REASON_", ""),
|
|
28
|
+
r.path ?? "",
|
|
29
|
+
r.ip ?? "",
|
|
30
|
+
r.received_at ?? "",
|
|
31
|
+
]));
|
|
32
|
+
if (result.nextCursor) {
|
|
33
|
+
info(`\nNext page: --cursor "${result.nextCursor}"`);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/request/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,UAAU,0BAA0B,CAAC,MAAe;IACxD,MAAM;SACH,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,0BAA0B,CAAC;SACvC,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC;SAC/C,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,IAAI,CAAC;SAC1C,MAAM,CAAC,mBAAmB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/commands/rule/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAkC/D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ArcjetApiClient } from "../../lib/api-client.js";
|
|
2
|
+
import { requireAuth } from "../../lib/auth.js";
|
|
3
|
+
import { validateSiteId } from "../../lib/validators.js";
|
|
4
|
+
import { isJsonMode, printJson, printRecord, success, error } from "../../lib/output.js";
|
|
5
|
+
export function registerRuleCreateCommand(parent) {
|
|
6
|
+
parent
|
|
7
|
+
.command("create")
|
|
8
|
+
.description("Create a remote rule for a site")
|
|
9
|
+
.requiredOption("--site-id <siteId>", "Site ID")
|
|
10
|
+
.argument("<json>", "Rule configuration as JSON string")
|
|
11
|
+
.action(async (json, options) => {
|
|
12
|
+
const siteId = validateSiteId(options.siteId);
|
|
13
|
+
const session = requireAuth();
|
|
14
|
+
let ruleConfig;
|
|
15
|
+
try {
|
|
16
|
+
ruleConfig = JSON.parse(json);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
error("Invalid JSON. Provide a valid rule configuration.");
|
|
20
|
+
error('Example: \'{"shield": {"mode": "MODE_LIVE"}}\'');
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
const client = new ArcjetApiClient(session);
|
|
24
|
+
const result = await client.createRule(siteId, ruleConfig);
|
|
25
|
+
if (isJsonMode()) {
|
|
26
|
+
printJson(result);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
success("Created rule");
|
|
30
|
+
printRecord({
|
|
31
|
+
ID: result.id,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/rule/create.ts"],"names":[],"m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