@kenkaiiii/gg-pixel 4.3.84 → 4.3.85

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/index.d.ts CHANGED
@@ -74,6 +74,12 @@ interface InstallOptions {
74
74
  interface InstallResult {
75
75
  projectId: string;
76
76
  projectKey: string;
77
+ /**
78
+ * Per-project bearer secret returned by the server on creation. Stored in
79
+ * ~/.gg/projects.json and required for every /api/* call (read/list/patch/
80
+ * delete). Never leaves the user's machine — never inlined into source.
81
+ */
82
+ projectSecret: string;
77
83
  projectName: string;
78
84
  projectKind: ProjectKind;
79
85
  initFilePath: string;
package/dist/index.js CHANGED
@@ -457,8 +457,8 @@ async function install(opts = {}) {
457
457
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
458
458
  let created;
459
459
  let reused = false;
460
- if (existing && existingKey) {
461
- created = { id: existing.id, key: existingKey };
460
+ if (existing && existing.secret && existingKey) {
461
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
462
462
  reused = true;
463
463
  } else {
464
464
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -475,10 +475,11 @@ async function install(opts = {}) {
475
475
  if (kind !== "browser" && kind !== "tauri") {
476
476
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
477
477
  }
478
- writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot);
478
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot, created.secret);
479
479
  return {
480
480
  projectId: created.id,
481
481
  projectKey: created.key,
482
+ projectSecret: created.secret,
482
483
  projectName,
483
484
  projectKind: kind,
484
485
  initFilePath: wired.primaryInitPath,
@@ -535,8 +536,10 @@ async function createProject(fetchFn, ingestUrl, name) {
535
536
  throw new Error(`POST /api/projects failed: ${res.status} ${await safeText(res)}`);
536
537
  }
537
538
  const body = await res.json();
538
- if (!body.id || !body.key) throw new Error("response missing id/key");
539
- return { id: body.id, key: body.key };
539
+ if (!body.id || !body.key || !body.secret) {
540
+ throw new Error("response missing id/key/secret");
541
+ }
542
+ return { id: body.id, key: body.key, secret: body.secret };
540
543
  }
541
544
  async function safeText(r) {
542
545
  try {
@@ -1442,8 +1445,8 @@ async function installGo(ctx) {
1442
1445
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1443
1446
  let created;
1444
1447
  let reused = false;
1445
- if (existing && existingKey) {
1446
- created = { id: existing.id, key: existingKey };
1448
+ if (existing && existing.secret && existingKey) {
1449
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1447
1450
  reused = true;
1448
1451
  } else {
1449
1452
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1471,10 +1474,11 @@ func init() {
1471
1474
  "utf8"
1472
1475
  );
1473
1476
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1474
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1477
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1475
1478
  return {
1476
1479
  projectId: created.id,
1477
1480
  projectKey: created.key,
1481
+ projectSecret: created.secret,
1478
1482
  projectName,
1479
1483
  projectKind: "go",
1480
1484
  initFilePath,
@@ -1515,8 +1519,8 @@ async function installRuby(ctx) {
1515
1519
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1516
1520
  let created;
1517
1521
  let reused = false;
1518
- if (existing && existingKey) {
1519
- created = { id: existing.id, key: existingKey };
1522
+ if (existing && existing.secret && existingKey) {
1523
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1520
1524
  reused = true;
1521
1525
  } else {
1522
1526
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1535,10 +1539,11 @@ GGPixel.init(
1535
1539
  "utf8"
1536
1540
  );
1537
1541
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1538
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1542
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1539
1543
  return {
1540
1544
  projectId: created.id,
1541
1545
  projectKey: created.key,
1546
+ projectSecret: created.secret,
1542
1547
  projectName,
1543
1548
  projectKind: "ruby",
1544
1549
  initFilePath,
@@ -1591,8 +1596,8 @@ async function installPython(ctx) {
1591
1596
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1592
1597
  let created;
1593
1598
  let reused = false;
1594
- if (existing && existingKey) {
1595
- created = { id: existing.id, key: existingKey };
1599
+ if (existing && existing.secret && existingKey) {
1600
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1596
1601
  reused = true;
1597
1602
  } else {
1598
1603
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1602,11 +1607,12 @@ async function installPython(ctx) {
1602
1607
  const initFilePath = join2(projectRoot, "gg_pixel_init.py");
1603
1608
  writeFileSync(initFilePath, renderPythonInitFile(ingestUrl, created.key), "utf8");
1604
1609
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1605
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1610
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1606
1611
  const entryWiring = wirePythonEntry(projectRoot, initFilePath);
1607
1612
  return {
1608
1613
  projectId: created.id,
1609
1614
  projectKey: created.key,
1615
+ projectSecret: created.secret,
1610
1616
  projectName,
1611
1617
  projectKind: "python",
1612
1618
  initFilePath,
@@ -1724,7 +1730,7 @@ function findPythonEntryFile(projectRoot) {
1724
1730
  }
1725
1731
  return null;
1726
1732
  }
1727
- function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
1733
+ function writeProjectsMapping(projectsJsonPath, projectId, name, path, secret) {
1728
1734
  mkdirSync2(dirname2(projectsJsonPath), { recursive: true });
1729
1735
  let map = {};
1730
1736
  if (existsSync2(projectsJsonPath)) {
@@ -1733,7 +1739,9 @@ function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
1733
1739
  } catch {
1734
1740
  }
1735
1741
  }
1736
- map[projectId] = { name, path };
1742
+ const entry = { name, path };
1743
+ if (secret) entry.secret = secret;
1744
+ map[projectId] = entry;
1737
1745
  writeFileSync(projectsJsonPath, `${JSON.stringify(map, null, 2)}
1738
1746
  `, "utf8");
1739
1747
  }