@schuttdev/gigai 0.1.0-beta.9 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schuttdev/gigai",
3
- "version": "0.1.0-beta.9",
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": "*",
@@ -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
- };
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ../server/dist/chunk-KF32K7J3.mjs
4
- import { nanoid } from "nanoid";
5
- var AuthStore = class {
6
- pairingCodes = /* @__PURE__ */ new Map();
7
- sessions = /* @__PURE__ */ new Map();
8
- boundOrgs = /* @__PURE__ */ new Map();
9
- // serverFingerprint -> orgUuid
10
- cleanupInterval;
11
- constructor() {
12
- this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
13
- }
14
- // Pairing codes
15
- addPairingCode(code, ttlSeconds) {
16
- const entry = {
17
- code,
18
- expiresAt: Date.now() + ttlSeconds * 1e3,
19
- used: false
20
- };
21
- this.pairingCodes.set(code, entry);
22
- return entry;
23
- }
24
- getPairingCode(code) {
25
- return this.pairingCodes.get(code);
26
- }
27
- markPairingCodeUsed(code) {
28
- const entry = this.pairingCodes.get(code);
29
- if (entry) {
30
- entry.used = true;
31
- }
32
- }
33
- // Sessions
34
- createSession(orgUuid, ttlSeconds) {
35
- const session = {
36
- id: nanoid(32),
37
- orgUuid,
38
- token: nanoid(48),
39
- expiresAt: Date.now() + ttlSeconds * 1e3,
40
- lastActivity: Date.now()
41
- };
42
- this.sessions.set(session.token, session);
43
- return session;
44
- }
45
- getSession(token) {
46
- const session = this.sessions.get(token);
47
- if (session) {
48
- session.lastActivity = Date.now();
49
- }
50
- return session;
51
- }
52
- // Org binding (bind-on-first-use for wildcard tokens)
53
- bindOrg(fingerprint, orgUuid) {
54
- this.boundOrgs.set(fingerprint, orgUuid);
55
- }
56
- getBoundOrg(fingerprint) {
57
- return this.boundOrgs.get(fingerprint);
58
- }
59
- // Cleanup
60
- cleanup() {
61
- const now = Date.now();
62
- for (const [key, code] of this.pairingCodes) {
63
- if (code.expiresAt < now) {
64
- this.pairingCodes.delete(key);
65
- }
66
- }
67
- for (const [key, session] of this.sessions) {
68
- if (session.expiresAt < now) {
69
- this.sessions.delete(key);
70
- }
71
- }
72
- }
73
- destroy() {
74
- clearInterval(this.cleanupInterval);
75
- this.pairingCodes.clear();
76
- this.sessions.clear();
77
- }
78
- };
79
-
80
- export {
81
- AuthStore
82
- };
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- generatePairingCode,
4
- validateAndPair
5
- } from "./chunk-FN4LCKUA.js";
6
- import "./chunk-4XUWD3DZ.js";
7
- export {
8
- generatePairingCode,
9
- validateAndPair
10
- };
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- AuthStore
4
- } from "./chunk-OMGUT7RM.js";
5
- export {
6
- AuthStore
7
- };