@lifeaitools/clauth 0.4.1 → 0.5.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/.clauth-skill/SKILL.md +184 -184
- package/.clauth-skill/references/keys-guide.md +270 -270
- package/.clauth-skill/references/operator-guide.md +148 -148
- package/README.md +125 -125
- package/cli/api.js +113 -113
- package/cli/commands/install.js +291 -291
- package/cli/commands/scrub.js +231 -231
- package/cli/commands/serve.js +526 -1
- package/cli/commands/uninstall.js +164 -164
- package/cli/fingerprint.js +91 -91
- package/cli/index.js +5 -1
- package/install.ps1 +44 -44
- package/install.sh +38 -38
- package/package.json +54 -54
- package/scripts/bin/bootstrap-linux +0 -0
- package/scripts/bin/bootstrap-macos +0 -0
- package/scripts/bootstrap.cjs +43 -43
- package/scripts/build.sh +45 -45
- package/supabase/functions/auth-vault/index.ts +235 -235
- package/supabase/migrations/001_clauth_schema.sql +103 -103
- package/supabase/migrations/002_vault_helpers.sql +90 -90
- package/supabase/migrations/20260317_lockout.sql +26 -26
package/cli/api.js
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
// cli/api.js
|
|
2
|
-
// Thin client that calls the auth-vault Edge Function
|
|
3
|
-
|
|
4
|
-
import { createRequire } from "module";
|
|
5
|
-
const require = createRequire(import.meta.url);
|
|
6
|
-
|
|
7
|
-
import Conf from "conf";
|
|
8
|
-
import { getConfOptions } from "./conf-path.js";
|
|
9
|
-
|
|
10
|
-
const config = new Conf(getConfOptions());
|
|
11
|
-
|
|
12
|
-
// ============================================================
|
|
13
|
-
// Get Edge Function base URL from local config
|
|
14
|
-
// ============================================================
|
|
15
|
-
export function getBaseUrl() {
|
|
16
|
-
const url = config.get("supabase_url") || process.env.CLAUTH_SUPABASE_URL;
|
|
17
|
-
if (!url) throw new Error("Supabase URL not configured. Run: clauth setup");
|
|
18
|
-
return `${url}/functions/v1/auth-vault`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getAnonKey() {
|
|
22
|
-
const key = config.get("supabase_anon_key") || process.env.CLAUTH_SUPABASE_ANON_KEY;
|
|
23
|
-
if (!key) throw new Error("Supabase anon key not configured. Run: clauth setup");
|
|
24
|
-
return key;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ============================================================
|
|
28
|
-
// Core POST helper
|
|
29
|
-
// ============================================================
|
|
30
|
-
async function post(route, body) {
|
|
31
|
-
const url = `${getBaseUrl()}/${route}`;
|
|
32
|
-
const anonKey = getAnonKey();
|
|
33
|
-
|
|
34
|
-
const res = await fetch(url, {
|
|
35
|
-
method: "POST",
|
|
36
|
-
headers: {
|
|
37
|
-
"Content-Type": "application/json",
|
|
38
|
-
"Authorization": `Bearer ${anonKey}`
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify(body)
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const data = await res.json();
|
|
44
|
-
if (!res.ok && !data.error) throw new Error(`HTTP ${res.status}`);
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ============================================================
|
|
49
|
-
// Auth-bearing calls (require HMAC token)
|
|
50
|
-
// ============================================================
|
|
51
|
-
async function authPost(route, password, machineHash, token, timestamp, extra = {}) {
|
|
52
|
-
return post(route, {
|
|
53
|
-
machine_hash: machineHash,
|
|
54
|
-
token,
|
|
55
|
-
timestamp,
|
|
56
|
-
password,
|
|
57
|
-
...extra
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// ============================================================
|
|
62
|
-
// Exported API surface
|
|
63
|
-
// ============================================================
|
|
64
|
-
|
|
65
|
-
export async function retrieve(password, machineHash, token, timestamp, service) {
|
|
66
|
-
return authPost("retrieve", password, machineHash, token, timestamp, { service });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export async function write(password, machineHash, token, timestamp, service, value) {
|
|
70
|
-
return authPost("write", password, machineHash, token, timestamp, { service, value });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function enable(password, machineHash, token, timestamp, service, enabled) {
|
|
74
|
-
return authPost("enable", password, machineHash, token, timestamp, { service, enabled });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function addService(password, machineHash, token, timestamp, name, label, key_type, description) {
|
|
78
|
-
return authPost("add", password, machineHash, token, timestamp, { name, label, key_type, description });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export async function removeService(password, machineHash, token, timestamp, service, confirm) {
|
|
82
|
-
return authPost("remove", password, machineHash, token, timestamp, { service, confirm });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export async function revoke(password, machineHash, token, timestamp, service, confirm) {
|
|
86
|
-
return authPost("revoke", password, machineHash, token, timestamp, { service, confirm });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export async function status(password, machineHash, token, timestamp) {
|
|
90
|
-
return authPost("status", password, machineHash, token, timestamp);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export async function test(password, machineHash, token, timestamp) {
|
|
94
|
-
return authPost("test", password, machineHash, token, timestamp);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function changePassword(password, machineHash, token, timestamp, newSeedHash) {
|
|
98
|
-
return authPost("change-password", password, machineHash, token, timestamp, { new_hmac_seed_hash: newSeedHash });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export async function registerMachine(machineHash, seedHash, label, adminToken) {
|
|
102
|
-
return post("register-machine", {
|
|
103
|
-
machine_hash: machineHash,
|
|
104
|
-
hmac_seed_hash: seedHash,
|
|
105
|
-
label,
|
|
106
|
-
admin_token: adminToken
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export default {
|
|
111
|
-
retrieve, write, enable, addService, removeService, revoke,
|
|
112
|
-
status, test, registerMachine, getBaseUrl, getAnonKey
|
|
113
|
-
};
|
|
1
|
+
// cli/api.js
|
|
2
|
+
// Thin client that calls the auth-vault Edge Function
|
|
3
|
+
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
import Conf from "conf";
|
|
8
|
+
import { getConfOptions } from "./conf-path.js";
|
|
9
|
+
|
|
10
|
+
const config = new Conf(getConfOptions());
|
|
11
|
+
|
|
12
|
+
// ============================================================
|
|
13
|
+
// Get Edge Function base URL from local config
|
|
14
|
+
// ============================================================
|
|
15
|
+
export function getBaseUrl() {
|
|
16
|
+
const url = config.get("supabase_url") || process.env.CLAUTH_SUPABASE_URL;
|
|
17
|
+
if (!url) throw new Error("Supabase URL not configured. Run: clauth setup");
|
|
18
|
+
return `${url}/functions/v1/auth-vault`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getAnonKey() {
|
|
22
|
+
const key = config.get("supabase_anon_key") || process.env.CLAUTH_SUPABASE_ANON_KEY;
|
|
23
|
+
if (!key) throw new Error("Supabase anon key not configured. Run: clauth setup");
|
|
24
|
+
return key;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ============================================================
|
|
28
|
+
// Core POST helper
|
|
29
|
+
// ============================================================
|
|
30
|
+
async function post(route, body) {
|
|
31
|
+
const url = `${getBaseUrl()}/${route}`;
|
|
32
|
+
const anonKey = getAnonKey();
|
|
33
|
+
|
|
34
|
+
const res = await fetch(url, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"Authorization": `Bearer ${anonKey}`
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify(body)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const data = await res.json();
|
|
44
|
+
if (!res.ok && !data.error) throw new Error(`HTTP ${res.status}`);
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============================================================
|
|
49
|
+
// Auth-bearing calls (require HMAC token)
|
|
50
|
+
// ============================================================
|
|
51
|
+
async function authPost(route, password, machineHash, token, timestamp, extra = {}) {
|
|
52
|
+
return post(route, {
|
|
53
|
+
machine_hash: machineHash,
|
|
54
|
+
token,
|
|
55
|
+
timestamp,
|
|
56
|
+
password,
|
|
57
|
+
...extra
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ============================================================
|
|
62
|
+
// Exported API surface
|
|
63
|
+
// ============================================================
|
|
64
|
+
|
|
65
|
+
export async function retrieve(password, machineHash, token, timestamp, service) {
|
|
66
|
+
return authPost("retrieve", password, machineHash, token, timestamp, { service });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function write(password, machineHash, token, timestamp, service, value) {
|
|
70
|
+
return authPost("write", password, machineHash, token, timestamp, { service, value });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function enable(password, machineHash, token, timestamp, service, enabled) {
|
|
74
|
+
return authPost("enable", password, machineHash, token, timestamp, { service, enabled });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function addService(password, machineHash, token, timestamp, name, label, key_type, description) {
|
|
78
|
+
return authPost("add", password, machineHash, token, timestamp, { name, label, key_type, description });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function removeService(password, machineHash, token, timestamp, service, confirm) {
|
|
82
|
+
return authPost("remove", password, machineHash, token, timestamp, { service, confirm });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function revoke(password, machineHash, token, timestamp, service, confirm) {
|
|
86
|
+
return authPost("revoke", password, machineHash, token, timestamp, { service, confirm });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function status(password, machineHash, token, timestamp) {
|
|
90
|
+
return authPost("status", password, machineHash, token, timestamp);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function test(password, machineHash, token, timestamp) {
|
|
94
|
+
return authPost("test", password, machineHash, token, timestamp);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function changePassword(password, machineHash, token, timestamp, newSeedHash) {
|
|
98
|
+
return authPost("change-password", password, machineHash, token, timestamp, { new_hmac_seed_hash: newSeedHash });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function registerMachine(machineHash, seedHash, label, adminToken) {
|
|
102
|
+
return post("register-machine", {
|
|
103
|
+
machine_hash: machineHash,
|
|
104
|
+
hmac_seed_hash: seedHash,
|
|
105
|
+
label,
|
|
106
|
+
admin_token: adminToken
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default {
|
|
111
|
+
retrieve, write, enable, addService, removeService, revoke,
|
|
112
|
+
status, test, registerMachine, getBaseUrl, getAnonKey
|
|
113
|
+
};
|