@schuttdev/gigai 0.1.0-beta.8 → 0.2.2
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/dist/{chunk-4XUWD3DZ.js → chunk-7C3UYEKE.js} +1 -8
- package/dist/{dist-YHKBLFWY.js → dist-U7NYIMA4.js} +536 -129
- package/dist/index.js +508 -92
- package/package.json +3 -2
- package/dist/chunk-FN4LCKUA.js +0 -42
- package/dist/chunk-OWDYY3IG.js +0 -73
- package/dist/pairing-IGMDVOIZ-RA7GNFU7.js +0 -10
- package/dist/store-Y4V3TOYJ-GKOB6ANA.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schuttdev/gigai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"gigai": "dist/index.js"
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
31
31
|
"@inquirer/prompts": "^7.0.0",
|
|
32
32
|
"nanoid": "^5.0.0",
|
|
33
|
-
"zod": "^3.22.0"
|
|
33
|
+
"zod": "^3.22.0",
|
|
34
|
+
"undici": "^6.0.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@gigai/shared": "*",
|
package/dist/chunk-FN4LCKUA.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
ErrorCode,
|
|
4
|
-
GigaiError,
|
|
5
|
-
encrypt
|
|
6
|
-
} from "./chunk-4XUWD3DZ.js";
|
|
7
|
-
|
|
8
|
-
// ../server/dist/chunk-54TEF6CS.mjs
|
|
9
|
-
import { nanoid } from "nanoid";
|
|
10
|
-
var PAIRING_CODE_LENGTH = 8;
|
|
11
|
-
var PAIRING_CODE_CHARS = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
12
|
-
function generatePairingCode(store, ttlSeconds) {
|
|
13
|
-
let code = "";
|
|
14
|
-
const bytes = nanoid(PAIRING_CODE_LENGTH);
|
|
15
|
-
for (let i = 0; i < PAIRING_CODE_LENGTH; i++) {
|
|
16
|
-
code += PAIRING_CODE_CHARS[bytes.charCodeAt(i) % PAIRING_CODE_CHARS.length];
|
|
17
|
-
}
|
|
18
|
-
store.addPairingCode(code, ttlSeconds);
|
|
19
|
-
return code;
|
|
20
|
-
}
|
|
21
|
-
function validateAndPair(store, code, orgUuid, encryptionKey, serverFingerprint) {
|
|
22
|
-
const entry = store.getPairingCode(code.toUpperCase());
|
|
23
|
-
if (!entry) {
|
|
24
|
-
throw new GigaiError(ErrorCode.PAIRING_INVALID, "Invalid pairing code");
|
|
25
|
-
}
|
|
26
|
-
if (entry.used) {
|
|
27
|
-
throw new GigaiError(ErrorCode.PAIRING_USED, "Pairing code already used");
|
|
28
|
-
}
|
|
29
|
-
if (entry.expiresAt < Date.now()) {
|
|
30
|
-
throw new GigaiError(ErrorCode.PAIRING_EXPIRED, "Pairing code expired");
|
|
31
|
-
}
|
|
32
|
-
store.markPairingCodeUsed(code.toUpperCase());
|
|
33
|
-
return encrypt(
|
|
34
|
-
{ orgUuid, serverFingerprint, createdAt: Date.now() },
|
|
35
|
-
encryptionKey
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
generatePairingCode,
|
|
41
|
-
validateAndPair
|
|
42
|
-
};
|
package/dist/chunk-OWDYY3IG.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// ../server/dist/chunk-RZTCSUFS.mjs
|
|
4
|
-
import { nanoid } from "nanoid";
|
|
5
|
-
var AuthStore = class {
|
|
6
|
-
pairingCodes = /* @__PURE__ */ new Map();
|
|
7
|
-
sessions = /* @__PURE__ */ new Map();
|
|
8
|
-
cleanupInterval;
|
|
9
|
-
constructor() {
|
|
10
|
-
this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
|
|
11
|
-
}
|
|
12
|
-
// Pairing codes
|
|
13
|
-
addPairingCode(code, ttlSeconds) {
|
|
14
|
-
const entry = {
|
|
15
|
-
code,
|
|
16
|
-
expiresAt: Date.now() + ttlSeconds * 1e3,
|
|
17
|
-
used: false
|
|
18
|
-
};
|
|
19
|
-
this.pairingCodes.set(code, entry);
|
|
20
|
-
return entry;
|
|
21
|
-
}
|
|
22
|
-
getPairingCode(code) {
|
|
23
|
-
return this.pairingCodes.get(code);
|
|
24
|
-
}
|
|
25
|
-
markPairingCodeUsed(code) {
|
|
26
|
-
const entry = this.pairingCodes.get(code);
|
|
27
|
-
if (entry) {
|
|
28
|
-
entry.used = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Sessions
|
|
32
|
-
createSession(orgUuid, ttlSeconds) {
|
|
33
|
-
const session = {
|
|
34
|
-
id: nanoid(32),
|
|
35
|
-
orgUuid,
|
|
36
|
-
token: nanoid(48),
|
|
37
|
-
expiresAt: Date.now() + ttlSeconds * 1e3,
|
|
38
|
-
lastActivity: Date.now()
|
|
39
|
-
};
|
|
40
|
-
this.sessions.set(session.token, session);
|
|
41
|
-
return session;
|
|
42
|
-
}
|
|
43
|
-
getSession(token) {
|
|
44
|
-
const session = this.sessions.get(token);
|
|
45
|
-
if (session) {
|
|
46
|
-
session.lastActivity = Date.now();
|
|
47
|
-
}
|
|
48
|
-
return session;
|
|
49
|
-
}
|
|
50
|
-
// Cleanup
|
|
51
|
-
cleanup() {
|
|
52
|
-
const now = Date.now();
|
|
53
|
-
for (const [key, code] of this.pairingCodes) {
|
|
54
|
-
if (code.expiresAt < now) {
|
|
55
|
-
this.pairingCodes.delete(key);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const [key, session] of this.sessions) {
|
|
59
|
-
if (session.expiresAt < now) {
|
|
60
|
-
this.sessions.delete(key);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
destroy() {
|
|
65
|
-
clearInterval(this.cleanupInterval);
|
|
66
|
-
this.pairingCodes.clear();
|
|
67
|
-
this.sessions.clear();
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export {
|
|
72
|
-
AuthStore
|
|
73
|
-
};
|