agentalarm 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/config.js +12 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentalarm",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Let AI agents, scripts and CI ring your iPhone through AgentAlarm: urgent alerts ring through Silent and Focus.",
5
5
  "keywords": ["agentalarm", "alarm", "iphone", "notifications", "claude-code", "cursor", "codex", "hooks", "mcp", "ai-agents"],
6
6
  "homepage": "https://alarm.achub.net",
package/src/config.js CHANGED
@@ -76,14 +76,22 @@ export function updateConfig(change, env = process.env) {
76
76
  return config;
77
77
  }
78
78
 
79
+ /** The Claude Code plugin's `agentalarm_key` option (sensitive); Claude Code exports it to the plugin's hooks. */
80
+ export const PLUGIN_KEY_ENV = 'CLAUDE_PLUGIN_OPTION_AGENTALARM_KEY';
81
+
79
82
  /**
80
- * The key and the server it belongs to; a key is never sent to another key's server. AGENTALARM_KEY (CI) wins and
81
- * goes to AGENTALARM_URL or the default server, never to the config file's; the saved key goes to its saved server.
83
+ * The key and the server it belongs to; a key is never sent to another key's server. AGENTALARM_KEY (CI) wins, then
84
+ * the Claude Code plugin's key option, which only ever goes to the default server; AGENTALARM_KEY goes to AGENTALARM_URL
85
+ * or the default server, never to the config file's.
86
+ * The saved key goes to its saved server.
82
87
  */
83
88
  export function credentials(config, env = process.env) {
84
89
  const trimmed = (url) => url.replace(/\/+$/, '');
85
- const envKey = (env.AGENTALARM_KEY || '').trim();
86
- if (envKey) return { key: envKey, baseUrl: trimmed(env.AGENTALARM_URL || DEFAULT_BASE_URL), fromEnv: true };
90
+ const ciKey = (env.AGENTALARM_KEY || '').trim();
91
+ if (ciKey) return { key: ciKey, baseUrl: trimmed(env.AGENTALARM_URL || DEFAULT_BASE_URL), fromEnv: true };
92
+ // The plugin's key option belongs to the hosted service only: no environment variable can send it elsewhere.
93
+ const pluginKey = (env[PLUGIN_KEY_ENV] || '').trim();
94
+ if (pluginKey) return { key: pluginKey, baseUrl: trimmed(DEFAULT_BASE_URL), fromEnv: true };
87
95
  const key = typeof config.key === 'string' ? config.key.trim() : '';
88
96
  return { key: key || null, baseUrl: trimmed(config.baseUrl || DEFAULT_BASE_URL), fromEnv: false };
89
97
  }