@sigma-auth/cli 0.0.1
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 +39 -0
- package/package.json +47 -0
- package/src/args.ts +81 -0
- package/src/commands.ts +593 -0
- package/src/config.ts +78 -0
- package/src/cookies.ts +170 -0
- package/src/error.ts +72 -0
- package/src/fsutil.ts +48 -0
- package/src/http.ts +90 -0
- package/src/identity.ts +155 -0
- package/src/index.ts +62 -0
- package/src/output.ts +50 -0
- package/src/password.ts +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Open Protocol Labs
|
|
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,39 @@
|
|
|
1
|
+
# @sigma-auth/cli
|
|
2
|
+
|
|
3
|
+
Headless CLI for [Sigma Auth](https://auth.sigmaidentity.com). Create a Bitcoin (BAP) identity key **locally**, sign in with Bitcoin-Auth, push `bitcoin-backup` ciphertext, and register OAuth clients.
|
|
4
|
+
|
|
5
|
+
The server never sees private keys. Identity is a BAP member key, not an API key.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx @sigma-auth/cli --help
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Agent one-shot
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
export SIGMA_AUTH_URL=https://auth.sigmaidentity.com
|
|
15
|
+
export SIGMA_BACKUP_PASSWORD="$(openssl rand -base64 32)"
|
|
16
|
+
|
|
17
|
+
bunx @sigma-auth/cli identity create \
|
|
18
|
+
--label "agent" \
|
|
19
|
+
--out ./identity.bep \
|
|
20
|
+
--signin \
|
|
21
|
+
--push-backup \
|
|
22
|
+
--json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
|
|
27
|
+
| Command | Job |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `sigma identity create` | Create Type42 master + first BAP, encrypt `.bep` |
|
|
30
|
+
| `sigma identity info` | Public fields from a local backup |
|
|
31
|
+
| `sigma backup encrypt` | JSON → `.bep` |
|
|
32
|
+
| `sigma auth sign-in` | Member-key Bitcoin-Auth; cookie jar; register BAP |
|
|
33
|
+
| `sigma backup push` | POST ciphertext only |
|
|
34
|
+
| `sigma oauth register` | Session `/api/oauth-clients` or RFC 7591 DCR |
|
|
35
|
+
| `sigma doctor` | Env, files, RFC 8414, session |
|
|
36
|
+
|
|
37
|
+
Password sources (exactly one): `--password-file`, `--password-stdin`, or `SIGMA_BACKUP_PASSWORD`. `--password` on argv is rejected.
|
|
38
|
+
|
|
39
|
+
Contract: `docs/specs/sigma-cli-v1.md` in [sigma-auth](https://github.com/b-open-io/sigma-auth).
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigma-auth/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Headless Sigma Auth CLI: create a BAP identity locally, sign in with Bitcoin-Auth, push encrypted backups, register OAuth clients",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sigma": "./src/index.ts"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"sigma": "bun run src/index.ts",
|
|
15
|
+
"test": "bun test tests",
|
|
16
|
+
"lint": "biome check .",
|
|
17
|
+
"build": "bun test tests"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"sigma-auth",
|
|
24
|
+
"bitcoin",
|
|
25
|
+
"bap",
|
|
26
|
+
"oauth",
|
|
27
|
+
"cli"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/b-open-io/sigma-auth-cli.git"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"bun": ">=1.1.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@bsv/sdk": "^2.1.6",
|
|
39
|
+
"bitcoin-auth": "^0.0.8",
|
|
40
|
+
"bitcoin-backup": "^0.0.13",
|
|
41
|
+
"bsv-bap": "^0.3.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/bun": "latest",
|
|
45
|
+
"typescript": "^5"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/args.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { usage } from "./error.ts";
|
|
2
|
+
|
|
3
|
+
const BOOL_FLAGS = new Set([
|
|
4
|
+
"json",
|
|
5
|
+
"quiet",
|
|
6
|
+
"force",
|
|
7
|
+
"help",
|
|
8
|
+
"signin",
|
|
9
|
+
"push-backup",
|
|
10
|
+
"show-mnemonic",
|
|
11
|
+
"public",
|
|
12
|
+
"password-stdin",
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const REPEATABLE = new Set(["redirect-uri", "grant-type"]);
|
|
16
|
+
|
|
17
|
+
export type ParsedArgs = {
|
|
18
|
+
positional: string[];
|
|
19
|
+
flags: Record<string, string[]>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function flag(args: ParsedArgs, name: string): string | undefined {
|
|
23
|
+
const values = args.flags[name];
|
|
24
|
+
return values?.[0];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function flagList(args: ParsedArgs, name: string): string[] {
|
|
28
|
+
return args.flags[name] ?? [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function boolFlag(args: ParsedArgs, name: string): boolean {
|
|
32
|
+
return args.flags[name]?.[0] === "true";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function parseArgs(argv: string[]): ParsedArgs {
|
|
36
|
+
const positional: string[] = [];
|
|
37
|
+
const flags: Record<string, string[]> = {};
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < argv.length; i++) {
|
|
40
|
+
const token = argv[i];
|
|
41
|
+
if (token === undefined) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (token === "--password" || token.startsWith("--password=")) {
|
|
45
|
+
usage("--password is not allowed; use --password-file, --password-stdin, or SIGMA_BACKUP_PASSWORD");
|
|
46
|
+
}
|
|
47
|
+
if (token === "-h") {
|
|
48
|
+
flags.help = ["true"];
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (token === "--") {
|
|
52
|
+
positional.push(...argv.slice(i + 1));
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
if (!token.startsWith("--")) {
|
|
56
|
+
positional.push(token);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const eq = token.indexOf("=");
|
|
60
|
+
const name = (eq === -1 ? token.slice(2) : token.slice(2, eq)).trim();
|
|
61
|
+
if (!name) {
|
|
62
|
+
usage("empty flag");
|
|
63
|
+
}
|
|
64
|
+
if (BOOL_FLAGS.has(name)) {
|
|
65
|
+
const raw = eq === -1 ? "true" : token.slice(eq + 1);
|
|
66
|
+
flags[name] = [raw === "false" ? "false" : "true"];
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const value = eq === -1 ? argv[++i] : token.slice(eq + 1);
|
|
70
|
+
if (value === undefined || value.startsWith("--")) {
|
|
71
|
+
usage(`missing value for --${name}`);
|
|
72
|
+
}
|
|
73
|
+
if (REPEATABLE.has(name)) {
|
|
74
|
+
flags[name] = [...(flags[name] ?? []), value];
|
|
75
|
+
} else {
|
|
76
|
+
flags[name] = [value];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return { positional, flags };
|
|
81
|
+
}
|