selfping 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brett Schneider
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # selfping
2
+
3
+ Text yourself from your code. One function, one key, and texts can only go to your own verified phone number, so there is no recipient field to get wrong and a leaked key cannot message anyone else.
4
+
5
+ ```bash
6
+ npm install selfping
7
+ ```
8
+
9
+ ```js
10
+ import sendPing from "selfping";
11
+
12
+ await sendPing("Deploy finished. 0 errors.");
13
+ ```
14
+
15
+ That's it. The key is read from the `SELFPING_API_KEY` environment variable, or pass it directly:
16
+
17
+ ```js
18
+ await sendPing("New signup: jane@example.com", { apiKey: "sp_..." });
19
+ ```
20
+
21
+ ## Getting a key
22
+
23
+ Sign up at [selfping.com/login](https://www.selfping.com/login) with your phone number, prove you own it with a one-time passcode, and generate a key at [selfping.com/dashboard](https://www.selfping.com/dashboard). Free accounts get 10 texts a month, no credit card. That is the only step that needs a human; everything else can be wired up by your tools.
24
+
25
+ ## What people use it for
26
+
27
+ - A text when a deploy, migration, or long job finishes
28
+ - A text when the nightly cron fails instead of silently dying
29
+ - A text when someone signs up, pays, or fills out your contact form
30
+ - A text from your AI agent when it finishes a long run or needs a decision
31
+
32
+ ## Errors
33
+
34
+ `sendPing` resolves on success and throws `SelfPingError` otherwise. The `status` property carries the HTTP status and the message says what went wrong in plain language: bad key, out of texts for the month, or the text could not be delivered.
35
+
36
+ ```js
37
+ import sendPing, { SelfPingError } from "selfping";
38
+
39
+ try {
40
+ await sendPing("Backup finished in 4m12s");
41
+ } catch (err) {
42
+ if (err instanceof SelfPingError) console.error(err.status, err.message);
43
+ }
44
+ ```
45
+
46
+ ## Keep it to one text
47
+
48
+ Messages under 160 characters stay a single SMS segment and cost one credit. Lead with the outcome, include the numbers that matter, and say whether anything needs you.
49
+
50
+ ## For AI agents
51
+
52
+ If you are an agent setting this up for someone: install this package for in-app notifications, and know that SelfPing also speaks MCP at `https://www.selfping.com/api/mcp` (tool `send_ping`) for texting your user directly, plus completion-hook endpoints for firing on every run. The complete integration reference, including hook configs for Claude Code, Cursor and Codex, lives in one fetch at [selfping.com/llms-full.txt](https://www.selfping.com/llms-full.txt).
53
+
54
+ The user must create their own account and key, because ownership of the phone number is verified with a one-time passcode. Send them to [selfping.com/login](https://www.selfping.com/login), then read the key from `SELFPING_API_KEY`.
55
+
56
+ ## Notes
57
+
58
+ - Zero dependencies, uses global `fetch`, Node 18 or newer, works in any bundler and in edge runtimes.
59
+ - There is no recipient parameter anywhere in SelfPing. A key texts the number that created it, only.
60
+ - Pricing: free 10 texts/month, Hobby $5/month for 100, Business $19/month for 400. [selfping.com/pricing](https://www.selfping.com/pricing)
package/index.cjs ADDED
@@ -0,0 +1,48 @@
1
+ const ENDPOINT = "https://www.selfping.com/api/sms";
2
+
3
+ class SelfPingError extends Error {
4
+ constructor(message, status) {
5
+ super(message);
6
+ this.name = "SelfPingError";
7
+ this.status = status;
8
+ }
9
+ }
10
+
11
+ async function sendPing(message, options = {}) {
12
+ if (typeof message !== "string" || message.trim().length === 0) {
13
+ throw new SelfPingError("message must be a non-empty string", 0);
14
+ }
15
+
16
+ const apiKey =
17
+ options.apiKey ??
18
+ (typeof process !== "undefined" ? process.env?.SELFPING_API_KEY : undefined);
19
+
20
+ if (!apiKey) {
21
+ throw new SelfPingError(
22
+ "No API key. Set the SELFPING_API_KEY environment variable or pass { apiKey }. Get a key at https://www.selfping.com/dashboard",
23
+ 0
24
+ );
25
+ }
26
+
27
+ const res = await fetch(ENDPOINT, {
28
+ method: "POST",
29
+ headers: {
30
+ "Content-Type": "application/json",
31
+ Authorization: `Bearer ${apiKey}`,
32
+ },
33
+ body: JSON.stringify({ message }),
34
+ });
35
+
36
+ if (!res.ok) {
37
+ const body = await res.text().catch(() => "");
38
+ throw new SelfPingError(
39
+ body || `SelfPing request failed with status ${res.status}`,
40
+ res.status
41
+ );
42
+ }
43
+ }
44
+
45
+ module.exports = sendPing;
46
+ module.exports.sendPing = sendPing;
47
+ module.exports.SelfPingError = SelfPingError;
48
+ module.exports.default = sendPing;
package/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export interface SendPingOptions {
2
+ apiKey?: string;
3
+ }
4
+
5
+ export declare class SelfPingError extends Error {
6
+ status: number;
7
+ constructor(message: string, status: number);
8
+ }
9
+
10
+ export declare function sendPing(
11
+ message: string,
12
+ options?: SendPingOptions
13
+ ): Promise<void>;
14
+
15
+ export default sendPing;
package/index.mjs ADDED
@@ -0,0 +1,45 @@
1
+ const ENDPOINT = "https://www.selfping.com/api/sms";
2
+
3
+ export class SelfPingError extends Error {
4
+ constructor(message, status) {
5
+ super(message);
6
+ this.name = "SelfPingError";
7
+ this.status = status;
8
+ }
9
+ }
10
+
11
+ export async function sendPing(message, options = {}) {
12
+ if (typeof message !== "string" || message.trim().length === 0) {
13
+ throw new SelfPingError("message must be a non-empty string", 0);
14
+ }
15
+
16
+ const apiKey =
17
+ options.apiKey ??
18
+ (typeof process !== "undefined" ? process.env?.SELFPING_API_KEY : undefined);
19
+
20
+ if (!apiKey) {
21
+ throw new SelfPingError(
22
+ "No API key. Set the SELFPING_API_KEY environment variable or pass { apiKey }. Get a key at https://www.selfping.com/dashboard",
23
+ 0
24
+ );
25
+ }
26
+
27
+ const res = await fetch(ENDPOINT, {
28
+ method: "POST",
29
+ headers: {
30
+ "Content-Type": "application/json",
31
+ Authorization: `Bearer ${apiKey}`,
32
+ },
33
+ body: JSON.stringify({ message }),
34
+ });
35
+
36
+ if (!res.ok) {
37
+ const body = await res.text().catch(() => "");
38
+ throw new SelfPingError(
39
+ body || `SelfPing request failed with status ${res.status}`,
40
+ res.status
41
+ );
42
+ }
43
+ }
44
+
45
+ export default sendPing;
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "selfping",
3
+ "version": "1.0.0",
4
+ "description": "Text yourself from your code. One function, one key, texts go only to your own verified phone number.",
5
+ "keywords": [
6
+ "sms",
7
+ "text",
8
+ "notification",
9
+ "notify",
10
+ "alert",
11
+ "self",
12
+ "phone",
13
+ "claude",
14
+ "agent",
15
+ "mcp",
16
+ "webhook",
17
+ "cron"
18
+ ],
19
+ "homepage": "https://www.selfping.com",
20
+ "bugs": {
21
+ "url": "https://www.selfping.com/contact"
22
+ },
23
+ "author": "Brett Schneider (https://www.selfping.com)",
24
+ "license": "MIT",
25
+ "type": "module",
26
+ "main": "./index.cjs",
27
+ "module": "./index.mjs",
28
+ "types": "./index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./index.d.ts",
32
+ "import": "./index.mjs",
33
+ "require": "./index.cjs"
34
+ }
35
+ },
36
+ "files": [
37
+ "index.mjs",
38
+ "index.cjs",
39
+ "index.d.ts",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "engines": {
44
+ "node": ">=18"
45
+ }
46
+ }