@lelu-auth/lelu 0.1.0 → 0.1.5
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.
Potentially problematic release.
This version of @lelu-auth/lelu might be problematic. Click here for more details.
- package/LICENSE +21 -21
- package/README.md +96 -55
- package/dist/{client-BD9h8CBT.d.mts → client-DY93sy4F.d.mts} +51 -2
- package/dist/{client-BD9h8CBT.d.ts → client-DY93sy4F.d.ts} +51 -2
- package/dist/express/index.d.mts +1 -1
- package/dist/express/index.d.ts +1 -1
- package/dist/express/index.js +42 -1
- package/dist/express/index.js.map +1 -1
- package/dist/express/index.mjs +42 -1
- package/dist/express/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -1
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.d.mts +1 -1
- package/dist/langchain/index.d.ts +1 -1
- package/dist/langchain/index.js.map +1 -1
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/react/index.js +42 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +42 -1
- package/dist/react/index.mjs.map +1 -1
- package/package.json +99 -95
- package/scripts/audit-log.js +56 -0
- package/scripts/lelu.js +69 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Lelu Audit Log CLI
|
|
4
|
+
async function main() {
|
|
5
|
+
try {
|
|
6
|
+
// Dynamic import to handle ESM module
|
|
7
|
+
const { createClient } = await import('@lelu-auth/lelu');
|
|
8
|
+
|
|
9
|
+
const baseUrl = process.env.LELU_PLATFORM_URL || process.argv[2] || 'http://localhost:3001';
|
|
10
|
+
const limit = parseInt(process.env.LELU_AUDIT_LIMIT || process.argv[3] || '20', 10);
|
|
11
|
+
|
|
12
|
+
const lelu = createClient({ baseUrl });
|
|
13
|
+
|
|
14
|
+
console.log(`Fetching audit log from ${baseUrl}...`);
|
|
15
|
+
const result = await lelu.listAuditEvents({ limit });
|
|
16
|
+
|
|
17
|
+
if (!result.events.length) {
|
|
18
|
+
console.log('No audit events found.');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log(`\nAudit Log (${result.count} events, limit: ${limit})`);
|
|
23
|
+
console.log('─'.repeat(80));
|
|
24
|
+
|
|
25
|
+
for (const event of result.events) {
|
|
26
|
+
const timestamp = new Date(event.timestamp).toLocaleString();
|
|
27
|
+
const confidence = event.confidenceScore ? ` (confidence: ${event.confidenceScore.toFixed(2)})` : '';
|
|
28
|
+
const resource = event.resource ? ` on ${JSON.stringify(event.resource)}` : '';
|
|
29
|
+
|
|
30
|
+
console.log(`[${timestamp}] ${event.actor} → ${event.action}${resource}`);
|
|
31
|
+
console.log(` Decision: ${event.decision}${confidence}`);
|
|
32
|
+
if (event.reason) {
|
|
33
|
+
console.log(` Reason: ${event.reason}`);
|
|
34
|
+
}
|
|
35
|
+
if (event.downgradedScope) {
|
|
36
|
+
console.log(` Downgraded scope: ${event.downgradedScope}`);
|
|
37
|
+
}
|
|
38
|
+
console.log(` Trace ID: ${event.traceId}`);
|
|
39
|
+
console.log('');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (result.nextCursor > 0) {
|
|
43
|
+
console.log(`Use cursor ${result.nextCursor} to fetch more events.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
} catch (err) {
|
|
47
|
+
console.error('Error fetching audit log:', err.message || err);
|
|
48
|
+
console.error('\nTroubleshooting:');
|
|
49
|
+
console.error('- Ensure the Lelu platform service is running');
|
|
50
|
+
console.error('- Check the platform URL (default: http://localhost:3001)');
|
|
51
|
+
console.error('- Verify your network connection');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
main();
|
package/scripts/lelu.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Lelu CLI
|
|
5
|
+
*
|
|
6
|
+
* Provides audit log viewing and other utilities for SDK users.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { spawnSync } = require("node:child_process");
|
|
10
|
+
const path = require("node:path");
|
|
11
|
+
|
|
12
|
+
function run(cmd, args, options = {}) {
|
|
13
|
+
const result = spawnSync(cmd, args, {
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
shell: false,
|
|
16
|
+
...options,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (result.error) {
|
|
20
|
+
throw result.error;
|
|
21
|
+
}
|
|
22
|
+
if (result.status !== 0) {
|
|
23
|
+
throw new Error(`${cmd} ${args.join(" ")} failed with code ${result.status}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function showAuditLog() {
|
|
28
|
+
const auditScript = path.join(__dirname, "audit-log.js");
|
|
29
|
+
run("node", [auditScript]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function printHelp() {
|
|
33
|
+
console.log(`
|
|
34
|
+
Lelu CLI
|
|
35
|
+
|
|
36
|
+
Usage:
|
|
37
|
+
lelu audit-log View recent audit events from the platform
|
|
38
|
+
lelu help Show this help
|
|
39
|
+
|
|
40
|
+
Environment Variables:
|
|
41
|
+
LELU_PLATFORM_URL Platform API URL (default: http://localhost:3001)
|
|
42
|
+
LELU_AUDIT_LIMIT Number of events to fetch (default: 20)
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
lelu audit-log # View recent audit events
|
|
46
|
+
LELU_AUDIT_LIMIT=50 lelu audit-log # View 50 recent events
|
|
47
|
+
LELU_PLATFORM_URL=https://api.example.com lelu audit-log # Use custom platform URL
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function main() {
|
|
52
|
+
const command = process.argv[2] || "audit-log";
|
|
53
|
+
|
|
54
|
+
if (command === "audit-log") {
|
|
55
|
+
showAuditLog();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (command === "help" || command === "-h" || command === "--help") {
|
|
60
|
+
printHelp();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.error(`Unknown command: ${command}`);
|
|
65
|
+
printHelp();
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main();
|