@schuttdev/gigai 0.1.0-beta.8 → 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
@@ -63,7 +63,16 @@ function connectWithToken(store, encryptedToken, orgUuid, encryptionKey, session
63
63
  } catch {
64
64
  throw new GigaiError(ErrorCode.TOKEN_DECRYPT_FAILED, "Failed to decrypt token");
65
65
  }
66
- if (decrypted.orgUuid !== "*" && 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) {
67
76
  throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
68
77
  }
69
78
  return store.createSession(orgUuid, sessionTtlSeconds);
@@ -1056,9 +1065,15 @@ This skill gives you access to tools running on the user's machine via the gigai
1056
1065
  };
1057
1066
  await writeFile2(join3(skillDir, "config.json"), JSON.stringify(skillConfig, null, 2) + "\n", { mode: 384 });
1058
1067
  console.log(` Skill template written to: ${skillDir}/`);
1068
+ const store = new AuthStore();
1069
+ const code = generatePairingCode(store, config.auth.pairingTtlSeconds);
1070
+ console.log(`
1071
+ Pairing code: ${code} (expires in ${config.auth.pairingTtlSeconds / 60} min)`);
1072
+ store.destroy();
1059
1073
  console.log(`
1060
1074
  Start the server with: gigai server start${httpsConfig ? "" : " --dev"}`);
1061
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.`);
1062
1077
  }
1063
1078
  async function loadConfigFile(path) {
1064
1079
  const configPath = resolve5(path ?? "gigai.config.json");
@@ -1171,7 +1186,7 @@ async function unwrapTool(name) {
1171
1186
  }
1172
1187
  async function generateServerPairingCode(configPath) {
1173
1188
  const { config } = await loadConfigFile(configPath);
1174
- const { AuthStore: AuthStore2 } = await import("./store-Y4V3TOYJ-GKOB6ANA.js");
1189
+ const { AuthStore: AuthStore2 } = await import("./store-XDNMGPYX-5CGK2GXY.js");
1175
1190
  const { generatePairingCode: generatePairingCode2 } = await import("./pairing-IGMDVOIZ-RA7GNFU7.js");
1176
1191
  const store = new AuthStore2();
1177
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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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-YHKBLFWY.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.8",
3
+ "version": "0.1.0-beta.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "gigai": "dist/index.js"