@schuttdev/gigai 0.1.0-beta.7 → 0.1.0-beta.9

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.
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // ../server/dist/chunk-RZTCSUFS.mjs
3
+ // ../server/dist/chunk-KF32K7J3.mjs
4
4
  import { nanoid } from "nanoid";
5
5
  var AuthStore = class {
6
6
  pairingCodes = /* @__PURE__ */ new Map();
7
7
  sessions = /* @__PURE__ */ new Map();
8
+ boundOrgs = /* @__PURE__ */ new Map();
9
+ // serverFingerprint -> orgUuid
8
10
  cleanupInterval;
9
11
  constructor() {
10
12
  this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
@@ -47,6 +49,13 @@ var AuthStore = class {
47
49
  }
48
50
  return session;
49
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
+ }
50
59
  // Cleanup
51
60
  cleanup() {
52
61
  const now = Date.now();
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  AuthStore
4
- } from "./chunk-OWDYY3IG.js";
4
+ } from "./chunk-OMGUT7RM.js";
5
5
  import {
6
6
  generatePairingCode,
7
7
  validateAndPair
@@ -11,6 +11,7 @@ import {
11
11
  GigaiConfigSchema,
12
12
  GigaiError,
13
13
  decrypt,
14
+ encrypt,
14
15
  generateEncryptionKey
15
16
  } from "./chunk-4XUWD3DZ.js";
16
17
 
@@ -45,6 +46,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
45
46
  import { resolve as resolve4, join as join3 } from "path";
46
47
  import { execFile } from "child_process";
47
48
  import { promisify } from "util";
49
+ import { randomBytes as randomBytes2 } from "crypto";
48
50
  import { input as input2 } from "@inquirer/prompts";
49
51
  import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
50
52
  import { resolve as resolve5 } from "path";
@@ -61,7 +63,16 @@ function connectWithToken(store, encryptedToken, orgUuid, encryptionKey, session
61
63
  } catch {
62
64
  throw new GigaiError(ErrorCode.TOKEN_DECRYPT_FAILED, "Failed to decrypt token");
63
65
  }
64
- if (decrypted.orgUuid !== orgUuid) {
66
+ if (decrypted.orgUuid === "*") {
67
+ const bound = store.getBoundOrg(decrypted.serverFingerprint);
68
+ if (bound) {
69
+ if (bound !== orgUuid) {
70
+ throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
71
+ }
72
+ } else {
73
+ store.bindOrg(decrypted.serverFingerprint, orgUuid);
74
+ }
75
+ } else if (decrypted.orgUuid !== orgUuid) {
65
76
  throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
66
77
  }
67
78
  return store.createSession(orgUuid, sessionTtlSeconds);
@@ -1042,20 +1053,27 @@ This skill gives you access to tools running on the user's machine via the gigai
1042
1053
  - All tool execution happens on the user's machine, not in this container
1043
1054
  `;
1044
1055
  await writeFile2(join3(skillDir, "SKILL.md"), skillMd);
1056
+ const tokenPayload = {
1057
+ orgUuid: "*",
1058
+ serverFingerprint: randomBytes2(16).toString("hex"),
1059
+ createdAt: Date.now()
1060
+ };
1061
+ const encryptedToken = encrypt(tokenPayload, encryptionKey);
1045
1062
  const skillConfig = {
1046
1063
  server: serverUrl,
1047
- token: "<PASTE_ENCRYPTED_TOKEN_HERE>"
1064
+ token: JSON.stringify(encryptedToken)
1048
1065
  };
1049
- await writeFile2(join3(skillDir, "config.json"), JSON.stringify(skillConfig, null, 2) + "\n");
1066
+ await writeFile2(join3(skillDir, "config.json"), JSON.stringify(skillConfig, null, 2) + "\n", { mode: 384 });
1050
1067
  console.log(` Skill template written to: ${skillDir}/`);
1051
1068
  const store = new AuthStore();
1052
1069
  const code = generatePairingCode(store, config.auth.pairingTtlSeconds);
1053
1070
  console.log(`
1054
- Pairing code: ${code}`);
1055
- console.log(` Expires in ${config.auth.pairingTtlSeconds / 60} minutes.`);
1071
+ Pairing code: ${code} (expires in ${config.auth.pairingTtlSeconds / 60} min)`);
1072
+ store.destroy();
1056
1073
  console.log(`
1057
1074
  Start the server with: gigai server start${httpsConfig ? "" : " --dev"}`);
1058
- store.destroy();
1075
+ console.log(` Then upload gigai-skill/ contents to your Claude Project.`);
1076
+ console.log(` The token will bind to the first org UUID that connects.`);
1059
1077
  }
1060
1078
  async function loadConfigFile(path) {
1061
1079
  const configPath = resolve5(path ?? "gigai.config.json");
@@ -1168,7 +1186,7 @@ async function unwrapTool(name) {
1168
1186
  }
1169
1187
  async function generateServerPairingCode(configPath) {
1170
1188
  const { config } = await loadConfigFile(configPath);
1171
- const { AuthStore: AuthStore2 } = await import("./store-Y4V3TOYJ-GKOB6ANA.js");
1189
+ const { AuthStore: AuthStore2 } = await import("./store-XDNMGPYX-5CGK2GXY.js");
1172
1190
  const { generatePairingCode: generatePairingCode2 } = await import("./pairing-IGMDVOIZ-RA7GNFU7.js");
1173
1191
  const store = new AuthStore2();
1174
1192
  const code = generatePairingCode2(store, config.auth.pairingTtlSeconds);
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ function runCitty() {
438
438
  dev: { type: "boolean", description: "Development mode (no HTTPS)" }
439
439
  },
440
440
  async run({ args }) {
441
- const { startServer } = await import("./dist-X77HZGDE.js");
441
+ const { startServer } = await import("./dist-CU5WVKG2.js");
442
442
  const extraArgs = [];
443
443
  if (args.config) extraArgs.push("--config", args.config);
444
444
  if (args.dev) extraArgs.push("--dev");
@@ -449,7 +449,7 @@ function runCitty() {
449
449
  init: defineCommand({
450
450
  meta: { name: "init", description: "Interactive setup wizard" },
451
451
  async run() {
452
- const { runInit } = await import("./dist-X77HZGDE.js");
452
+ const { runInit } = await import("./dist-CU5WVKG2.js");
453
453
  await runInit();
454
454
  }
455
455
  }),
@@ -459,7 +459,7 @@ function runCitty() {
459
459
  config: { type: "string", alias: "c", description: "Config file path" }
460
460
  },
461
461
  async run({ args }) {
462
- const { generateServerPairingCode } = await import("./dist-X77HZGDE.js");
462
+ const { generateServerPairingCode } = await import("./dist-CU5WVKG2.js");
463
463
  await generateServerPairingCode(args.config);
464
464
  }
465
465
  }),
@@ -486,21 +486,21 @@ function runCitty() {
486
486
  cli: defineCommand({
487
487
  meta: { name: "cli", description: "Wrap a CLI command" },
488
488
  async run() {
489
- const { wrapCli } = await import("./dist-X77HZGDE.js");
489
+ const { wrapCli } = await import("./dist-CU5WVKG2.js");
490
490
  await wrapCli();
491
491
  }
492
492
  }),
493
493
  mcp: defineCommand({
494
494
  meta: { name: "mcp", description: "Wrap an MCP server" },
495
495
  async run() {
496
- const { wrapMcp } = await import("./dist-X77HZGDE.js");
496
+ const { wrapMcp } = await import("./dist-CU5WVKG2.js");
497
497
  await wrapMcp();
498
498
  }
499
499
  }),
500
500
  script: defineCommand({
501
501
  meta: { name: "script", description: "Wrap a script" },
502
502
  async run() {
503
- const { wrapScript } = await import("./dist-X77HZGDE.js");
503
+ const { wrapScript } = await import("./dist-CU5WVKG2.js");
504
504
  await wrapScript();
505
505
  }
506
506
  }),
@@ -510,7 +510,7 @@ function runCitty() {
510
510
  path: { type: "positional", description: "Path to config file", required: true }
511
511
  },
512
512
  async run({ args }) {
513
- const { wrapImport } = await import("./dist-X77HZGDE.js");
513
+ const { wrapImport } = await import("./dist-CU5WVKG2.js");
514
514
  await wrapImport(args.path);
515
515
  }
516
516
  })
@@ -522,7 +522,7 @@ function runCitty() {
522
522
  name: { type: "positional", description: "Tool name", required: true }
523
523
  },
524
524
  async run({ args }) {
525
- const { unwrapTool } = await import("./dist-X77HZGDE.js");
525
+ const { unwrapTool } = await import("./dist-CU5WVKG2.js");
526
526
  await unwrapTool(args.name);
527
527
  }
528
528
  });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  AuthStore
4
- } from "./chunk-OWDYY3IG.js";
4
+ } from "./chunk-OMGUT7RM.js";
5
5
  export {
6
6
  AuthStore
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schuttdev/gigai",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0-beta.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "gigai": "dist/index.js"