smsforwarder 1.1.0 → 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
@@ -10,11 +10,11 @@ smsforwarder login sk_your_key
10
10
  CODE=$(smsforwarder code --timeout 90)
11
11
  ```
12
12
 
13
- `code` waits for the newest code to arrive and prints only the code. It exits with status 2 if nothing arrives in time. If other codes arrived in the same window it says so on stderr; `smsforwarder messages --codes` lists them so you can pick by the text.
13
+ `code` waits for the newest text to arrive and prints its code. If no code was recognised in the text, it prints the whole text instead (and says so on stderr), so nothing is lost. It exits with status 2 if nothing arrives in time. If other texts arrived in the same window it says so on stderr; `smsforwarder messages` lists them in full so you can pick by the text.
14
14
 
15
15
  ```
16
16
  smsforwarder code [--timeout sec] [--since time] [--json]
17
- smsforwarder messages [--minutes n] [--codes] [--limit n] [--json]
17
+ smsforwarder messages [--minutes n] [--limit n] [--json]
18
18
  smsforwarder devices
19
19
  smsforwarder webhook set <url> | rm | test
20
20
  smsforwarder mcp # MCP config for Claude, Cursor and other AI tools
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smsforwarder",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Get SMS verification codes from your own phone in scripts and AI agents. CLI for SMS Forwarder (smsforwarder.app).",
5
5
  "type": "module",
6
6
  "bin": { "smsforwarder": "smsforwarder.mjs" },
package/smsforwarder.mjs CHANGED
@@ -11,11 +11,11 @@ const HELP = `SMS Forwarder — verification codes from your phone, in your term
11
11
 
12
12
  Usage:
13
13
  smsforwarder login <api-key> Save your API key (from the phone app)
14
- smsforwarder code [options] Wait for the newest verification code and print it
14
+ smsforwarder code [options] Wait for the newest text and print its code, or the whole text if no code was recognised
15
15
  --timeout <sec> How long to wait, max 120 (default 60)
16
16
  --since <time> Only messages after this ISO time / unix ms (default: 2 minutes ago)
17
- --json Print the whole result as JSON, including other codes that arrived in the same window
18
- smsforwarder messages [--minutes n] [--codes] [--limit n] [--json]
17
+ --json Print the whole result as JSON, including every other message from the same window
18
+ smsforwarder messages [--minutes n] [--limit n] [--json]
19
19
  Messages from the last n minutes (default 10), newest first
20
20
  smsforwarder devices List connected phones
21
21
  smsforwarder webhook set <url> Send every new message to your URL (prints the signing secret)
@@ -85,6 +85,7 @@ const cmd = pos[0];
85
85
  for (const gone of ["from", "contains"]) {
86
86
  if (opt[gone] !== undefined) die(`--${gone} is gone: who sends a code can't be predicted. Take the newest code, or list recent messages and pick by text.`);
87
87
  }
88
+ if (opt.codes !== undefined) die("--codes is gone: some codes can't be picked out of the text, so every message is listed in full.");
88
89
 
89
90
  switch (cmd) {
90
91
  case "login": {
@@ -101,19 +102,23 @@ switch (cmd) {
101
102
  case "wait": {
102
103
  const timeout = Math.min(Number(opt.timeout ?? 60) || 60, 120);
103
104
  const { status, data } = await call("GET", "/v1/codes/wait" + qs({ since: opt.since, timeout }));
104
- if (status === 404 || !data.code) die(`No code arrived within ${timeout}s.`, 2);
105
+ if (status === 404 || !data.message) die(`No message arrived within ${timeout}s.`, 2);
105
106
  if (opt.json) console.log(JSON.stringify(data, null, 2));
106
107
  else {
107
- console.log(data.code);
108
- if (data.otherCodes?.length) {
109
- process.stderr.write(`${data.otherCodes.length} other code(s) arrived in the same window; run \`smsforwarder messages --codes\` to pick by text.\n`);
108
+ if (data.code) console.log(data.code);
109
+ else {
110
+ console.log(data.message.body);
111
+ process.stderr.write("No code was recognised in this text, so the whole text is printed above.\n");
112
+ }
113
+ if (data.otherMessages?.length) {
114
+ process.stderr.write(`${data.otherMessages.length} other message(s) arrived in the same window; run \`smsforwarder messages\` to pick by text.\n`);
110
115
  }
111
116
  }
112
117
  break;
113
118
  }
114
119
  case "messages":
115
120
  case "ls": {
116
- const { data } = await call("GET", "/v1/messages" + qs({ minutes: opt.minutes ?? 10, limit: opt.limit ?? 20, codes_only: opt.codes ? "true" : undefined }));
121
+ const { data } = await call("GET", "/v1/messages" + qs({ minutes: opt.minutes ?? 10, limit: opt.limit ?? 20 }));
117
122
  if (opt.json) {
118
123
  console.log(JSON.stringify(data.messages, null, 2));
119
124
  break;
@@ -121,7 +126,7 @@ switch (cmd) {
121
126
  if (!data.messages.length) console.log("No messages yet.");
122
127
  for (const m of data.messages) {
123
128
  const who = m.service || m.from || "?";
124
- console.log(`${ago(m.receivedAt).padEnd(8)} ${who}${m.code ? ` [${m.code}]` : ""}\n ${m.body.replace(/\s+/g, " ").slice(0, 160)}`);
129
+ console.log(`${ago(m.receivedAt).padEnd(8)} ${who}${m.code ? ` [${m.code}]` : ""}\n ${m.body.replace(/\s+/g, " ")}`);
125
130
  }
126
131
  break;
127
132
  }