@almyty/auth 0.1.2 → 1.2.0

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/README.md CHANGED
@@ -38,10 +38,14 @@ $ npx @almyty/auth whoami
38
38
 
39
39
  `login` runs entirely on your machine. It starts a loopback HTTP server, opens your browser to the almyty login page, and receives the token via POST body -- never in a URL. No password enters the CLI process.
40
40
 
41
- ## Docs
41
+ ## About almyty
42
42
 
43
- https://almyty.com/docs
43
+ almyty is the full-stack platform for AI agents, agnostic by design: any LLM, any
44
+ API turned into tools, served over MCP, A2A, UTCP, and Agent Skills. Open source,
45
+ no lock-in.
44
46
 
45
- ## License
47
+ - Website — https://almyty.com
48
+ - Docs — https://docs.almyty.com
49
+ - Source — https://github.com/almyty-inc/almyty
46
50
 
47
- BSL-1.1
51
+ Apache-2.0 © Almyty Inc.
package/dist/config.d.ts CHANGED
@@ -5,6 +5,12 @@ export interface AlmytyConfig {
5
5
  }
6
6
  export declare function loadConfig(): AlmytyConfig;
7
7
  export declare function saveConfig(config: AlmytyConfig): void;
8
+ /**
9
+ * Refuse an insecure (http://) backend URL for a remote host: the JWT
10
+ * crosses this connection, so plaintext to anything but loopback would
11
+ * leak it. http is allowed only for localhost (local dev).
12
+ */
13
+ export declare function assertSecureBackendUrl(url: string): void;
8
14
  /**
9
15
  * Resolve the API URL from (in order): flag > env > config > default.
10
16
  */
package/dist/config.js CHANGED
@@ -23,14 +23,39 @@ export function loadConfig() {
23
23
  export function saveConfig(config) {
24
24
  writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', 'utf-8');
25
25
  }
26
+ /**
27
+ * Refuse an insecure (http://) backend URL for a remote host: the JWT
28
+ * crosses this connection, so plaintext to anything but loopback would
29
+ * leak it. http is allowed only for localhost (local dev).
30
+ */
31
+ export function assertSecureBackendUrl(url) {
32
+ let parsed;
33
+ try {
34
+ parsed = new URL(url);
35
+ }
36
+ catch {
37
+ throw new Error(`Invalid backend URL: ${url}`);
38
+ }
39
+ const host = parsed.hostname;
40
+ const isLoopback = host === 'localhost' ||
41
+ host === '127.0.0.1' ||
42
+ host === '::1' ||
43
+ host.endsWith('.localhost');
44
+ if (parsed.protocol !== 'https:' && !isLoopback) {
45
+ throw new Error(`Refusing an insecure ${parsed.protocol}// backend URL for a remote host: ${url}. ` +
46
+ 'Use https:// (http is only allowed for localhost).');
47
+ }
48
+ }
26
49
  /**
27
50
  * Resolve the API URL from (in order): flag > env > config > default.
28
51
  */
29
52
  export function resolveApiUrl(flagValue) {
30
- return flagValue
31
- || process.env.ALMYTY_URL
32
- || loadConfig().apiUrl
33
- || 'https://api.almyty.com';
53
+ const url = flagValue ||
54
+ process.env.ALMYTY_URL ||
55
+ loadConfig().apiUrl ||
56
+ 'https://api.almyty.com';
57
+ assertSecureBackendUrl(url);
58
+ return url;
34
59
  }
35
60
  /**
36
61
  * Resolve the frontend URL from (in order): flag > env > config > default.
@@ -21,16 +21,24 @@ export function loadCredentials() {
21
21
  }
22
22
  }
23
23
  export function saveCredentials(creds) {
24
- mkdirSync(CREDENTIALS_DIR, { recursive: true });
25
- writeFileSync(CREDENTIALS_FILE, JSON.stringify(creds, null, 2));
26
- // Ensure the file is owner-only readable. writeFileSync's `mode` option
27
- // only applies on creation; chmod is idempotent and safer when the file
28
- // already exists with looser permissions.
24
+ // Owner-only directory (0700). mkdir's mode only applies on creation, so
25
+ // chmod an existing dir too — best-effort (no-op/throw on Windows).
26
+ mkdirSync(CREDENTIALS_DIR, { recursive: true, mode: 0o700 });
27
+ try {
28
+ chmodSync(CREDENTIALS_DIR, 0o700);
29
+ }
30
+ catch {
31
+ /* best-effort */
32
+ }
33
+ // Create the file 0600 from the start (closes the brief world-readable
34
+ // window that exists when a file is created with default perms and only
35
+ // chmod'd afterwards). chmod again for the already-exists case.
36
+ writeFileSync(CREDENTIALS_FILE, JSON.stringify(creds, null, 2), { mode: 0o600 });
29
37
  try {
30
38
  chmodSync(CREDENTIALS_FILE, 0o600);
31
39
  }
32
40
  catch {
33
- // Best-effort on platforms (Windows) where chmod may not apply.
41
+ /* best-effort on platforms where chmod may not apply */
34
42
  }
35
43
  }
36
44
  export function clearCredentials() {
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@almyty/auth",
3
- "version": "0.1.2",
4
- "description": "Browser-based login for almyty CLIs (skills, agents, chat, mcp-server)",
3
+ "version": "1.2.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Browser-based login shared by every almyty CLI. Run it once and agents, chat, skills, and mcp-server all reuse the credentials.",
5
8
  "type": "module",
6
9
  "main": "dist/index.js",
7
10
  "bin": {
@@ -25,11 +28,20 @@
25
28
  "cli"
26
29
  ],
27
30
  "author": "almyty",
28
- "license": "BSL-1.1",
31
+ "license": "Apache-2.0",
29
32
  "devDependencies": {
30
33
  "@types/node": "^25.4.0",
31
34
  "tsx": "^4.7.0",
32
35
  "typescript": "^5.3.0",
33
36
  "vitest": "^4.1.0"
37
+ },
38
+ "homepage": "https://almyty.com",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/almyty-inc/almyty.git",
42
+ "directory": "packages/auth-cli"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/almyty-inc/almyty/issues"
34
46
  }
35
47
  }