@signetai/connector-pi 1.0.0 → 1.0.1

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACb,KAAK,aAAa,EAElB,KAAK,eAAe,EASpB,MAAM,wBAAwB,CAAC;AAUhC,eAAO,MAAM,yBAAyB,mCAAqC,CAAC;AAC5E,eAAO,MAAM,eAAe,qCAA2B,CAAC;AACxD,eAAO,MAAM,UAAU,sCAAsB,CAAC;AAC9C,eAAO,MAAM,wBAAwB,gDAAoC,CAAC;AAC1E,eAAO,MAAM,wBAAwB,4CAAoC,CAAC;AAC1E,eAAO,MAAM,iBAAiB,qCAA6B,CAAC;AAC5D,eAAO,MAAM,sBAAsB,qCAAkC,CAAC;AACtE,eAAO,MAAM,yBAAyB,wDAAqC,CAAC;AAsB5E,qBAAa,WAAY,SAAQ,aAAa;IAC7C,QAAQ,CAAC,IAAI,QAAQ;IACrB,QAAQ,CAAC,SAAS,QAAQ;IAE1B,YAAY,IAAI,MAAM;IAItB,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,wBAAwB;IAIhC,aAAa,IAAI,MAAM;IAIjB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA4CjD,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAmB3C,WAAW,IAAI,OAAO;CAGtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACb,KAAK,aAAa,EAElB,KAAK,eAAe,EAUpB,MAAM,wBAAwB,CAAC;AAUhC,eAAO,MAAM,yBAAyB,mCAAqC,CAAC;AAC5E,eAAO,MAAM,eAAe,qCAA2B,CAAC;AACxD,eAAO,MAAM,UAAU,sCAAsB,CAAC;AAC9C,eAAO,MAAM,wBAAwB,gDAAoC,CAAC;AAC1E,eAAO,MAAM,wBAAwB,4CAAoC,CAAC;AAC1E,eAAO,MAAM,iBAAiB,qCAA6B,CAAC;AAC5D,eAAO,MAAM,sBAAsB,qCAAkC,CAAC;AACtE,eAAO,MAAM,yBAAyB,wDAAqC,CAAC;AAsB5E,qBAAa,WAAY,SAAQ,aAAa;IAC7C,QAAQ,CAAC,IAAI,QAAQ;IACrB,QAAQ,CAAC,SAAS,QAAQ;IAE1B,YAAY,IAAI,MAAM;IAItB,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,wBAAwB;IAIhC,aAAa,IAAI,MAAM;IAIjB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA0CjD,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAmB3C,WAAW,IAAI,OAAO;CAGtB"}
package/dist/index.js CHANGED
@@ -1,10 +1,26 @@
1
1
  // src/index.ts
2
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
2
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3 } from "node:fs";
3
3
  import { dirname as dirname4, join as join5 } from "node:path";
4
4
 
5
5
  // ../../../libs/connector-base/dist/index.js
6
6
  import { randomBytes } from "node:crypto";
7
- import { existsSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
7
+ import {
8
+ chmodSync,
9
+ closeSync,
10
+ constants,
11
+ existsSync,
12
+ fchmodSync,
13
+ fstatSync,
14
+ ftruncateSync,
15
+ openSync,
16
+ readFileSync,
17
+ realpathSync,
18
+ renameSync,
19
+ statSync,
20
+ unlinkSync,
21
+ writeFileSync,
22
+ writeSync
23
+ } from "node:fs";
8
24
  import { homedir } from "node:os";
9
25
  import { basename as basename2, dirname as dirname2, isAbsolute, join as join3, relative, sep } from "node:path";
10
26
  import { createRequire } from "node:module";
@@ -18224,6 +18240,34 @@ ${content}`);
18224
18240
  return this.install(basePath);
18225
18241
  }
18226
18242
  }
18243
+ function containsSignetApiKey(content) {
18244
+ const key = resolveSignetApiKey();
18245
+ if (key === undefined)
18246
+ return false;
18247
+ if (!/^[A-Za-z0-9._~+/=-]+$/.test(key))
18248
+ return true;
18249
+ return content.includes(key);
18250
+ }
18251
+ function atomicWriteText(path, content, mode) {
18252
+ const tmp = join3(dirname2(path), `.${randomBytes(6).toString("hex")}.tmp`);
18253
+ let writeMode = mode;
18254
+ if (writeMode === undefined) {
18255
+ try {
18256
+ writeMode = statSync(path).mode & 511;
18257
+ } catch {}
18258
+ }
18259
+ if (containsSignetApiKey(content))
18260
+ writeMode = (writeMode ?? 384) & 448;
18261
+ try {
18262
+ writeFileSync(tmp, content, { encoding: "utf-8", mode: writeMode });
18263
+ renameSync(tmp, path);
18264
+ } catch (err) {
18265
+ try {
18266
+ unlinkSync(tmp);
18267
+ } catch {}
18268
+ throw err;
18269
+ }
18270
+ }
18227
18271
  var MANAGED_DAEMON_URL_DEFAULT = "http://127.0.0.1:3850";
18228
18272
  var MANAGED_AGENT_ID_DEFAULT = "default";
18229
18273
  function readTrimmedEnv2(name) {
@@ -18324,6 +18368,15 @@ function removeManagedExtensionFile(filePath, marker) {
18324
18368
  unlinkSync(filePath);
18325
18369
  return true;
18326
18370
  }
18371
+ function writeManagedExtensionFile(filePath, content) {
18372
+ if (readManagedExtensionFile(filePath) !== content) {
18373
+ atomicWriteText(filePath, content, 384);
18374
+ return true;
18375
+ }
18376
+ if ((statSync(filePath).mode & 63) !== 0)
18377
+ chmodSync(filePath, 384);
18378
+ return false;
18379
+ }
18327
18380
 
18328
18381
  // ../../../libs/connector-base/dist/agent-dir.js
18329
18382
  import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
@@ -44074,9 +44127,7 @@ class PiConnector extends BaseConnector {
44074
44127
  agentId: resolveSignetAgentId(),
44075
44128
  apiKey: resolveSignetApiKey()
44076
44129
  });
44077
- const previous = existsSync3(targetPath) ? readFileSync3(targetPath, "utf8") : null;
44078
- if (previous !== managedContent) {
44079
- writeFileSync3(targetPath, managedContent, "utf8");
44130
+ if (writeManagedExtensionFile(targetPath, managedContent)) {
44080
44131
  filesWritten.push(targetPath);
44081
44132
  }
44082
44133
  const configPath = getPiConfigPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-pi",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Signet connector for pi",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "typecheck": "tsc --noEmit"
26
26
  },
27
27
  "dependencies": {
28
- "@signetai/connector-base": "1.0.0"
28
+ "@signetai/connector-base": "1.0.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@signet/pi-extension": "workspace:*",