sendkit-mcp 0.1.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/dist/db.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +132 -0
- package/dist/oauth-store.d.ts +17 -0
- package/dist/oauth-store.js +85 -0
- package/dist/pkce.d.ts +7 -0
- package/dist/routes/auth.d.ts +2 -0
- package/dist/routes/auth.js +1764 -0
- package/dist/users.d.ts +9 -0
- package/dist/users.js +79 -0
- package/package.json +43 -0
package/dist/users.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type User = {
|
|
2
|
+
id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
telegramBotToken: string | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function createUser(username: string, password: string): Promise<User>;
|
|
7
|
+
export declare function verifyUser(username: string, password: string): Promise<User | null>;
|
|
8
|
+
export declare function getUserById(id: string): User | null;
|
|
9
|
+
export declare function setTelegramBotToken(userId: string, botToken: string): void;
|
package/dist/users.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/users.ts
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
// src/db.ts
|
|
5
|
+
import { Database } from "bun:sqlite";
|
|
6
|
+
var db = new Database("sendkit.db", { create: true });
|
|
7
|
+
db.exec("PRAGMA journal_mode = WAL;");
|
|
8
|
+
db.exec(`
|
|
9
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
10
|
+
id TEXT PRIMARY KEY,
|
|
11
|
+
username TEXT UNIQUE NOT NULL,
|
|
12
|
+
password_hash TEXT NOT NULL,
|
|
13
|
+
telegram_bot_token TEXT,
|
|
14
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
15
|
+
);
|
|
16
|
+
`);
|
|
17
|
+
db.exec(`
|
|
18
|
+
CREATE TABLE IF NOT EXISTS authorization_codes (
|
|
19
|
+
code TEXT PRIMARY KEY,
|
|
20
|
+
user_id TEXT NOT NULL,
|
|
21
|
+
code_challenge TEXT NOT NULL,
|
|
22
|
+
redirect_uri TEXT NOT NULL,
|
|
23
|
+
expires_at INTEGER NOT NULL,
|
|
24
|
+
used INTEGER NOT NULL DEFAULT 0,
|
|
25
|
+
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
26
|
+
);
|
|
27
|
+
`);
|
|
28
|
+
db.exec(`
|
|
29
|
+
CREATE TABLE IF NOT EXISTS access_tokens (
|
|
30
|
+
token TEXT PRIMARY KEY,
|
|
31
|
+
user_id TEXT NOT NULL,
|
|
32
|
+
expires_at INTEGER NOT NULL,
|
|
33
|
+
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
34
|
+
);
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
// src/users.ts
|
|
38
|
+
async function createUser(username, password) {
|
|
39
|
+
const existing = db.query("SELECT id FROM users WHERE username = ?").get(username);
|
|
40
|
+
if (existing) {
|
|
41
|
+
throw new Error("Username already taken");
|
|
42
|
+
}
|
|
43
|
+
const id = randomUUID();
|
|
44
|
+
const passwordHash = await Bun.password.hash(password);
|
|
45
|
+
db.query("INSERT INTO users (id, username, password_hash) VALUES (?, ?, ?)").run(id, username, passwordHash);
|
|
46
|
+
return { id, username, telegramBotToken: null };
|
|
47
|
+
}
|
|
48
|
+
async function verifyUser(username, password) {
|
|
49
|
+
const row = db.query("SELECT id, username, password_hash, telegram_bot_token FROM users WHERE username = ?").get(username);
|
|
50
|
+
if (!row)
|
|
51
|
+
return null;
|
|
52
|
+
const passwordMatches = await Bun.password.verify(password, row.password_hash);
|
|
53
|
+
if (!passwordMatches)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
id: row.id,
|
|
57
|
+
username: row.username,
|
|
58
|
+
telegramBotToken: row.telegram_bot_token
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function getUserById(id) {
|
|
62
|
+
const row = db.query("SELECT id, username, telegram_bot_token FROM users WHERE id = ?").get(id);
|
|
63
|
+
if (!row)
|
|
64
|
+
return null;
|
|
65
|
+
return {
|
|
66
|
+
id: row.id,
|
|
67
|
+
username: row.username,
|
|
68
|
+
telegramBotToken: row.telegram_bot_token
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function setTelegramBotToken(userId, botToken) {
|
|
72
|
+
db.query("UPDATE users SET telegram_bot_token = ? WHERE id = ?").run(botToken, userId);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
verifyUser,
|
|
76
|
+
setTelegramBotToken,
|
|
77
|
+
getUserById,
|
|
78
|
+
createUser
|
|
79
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sendkit-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sendkit-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./oauth-store": {
|
|
16
|
+
"types": "./dist/oauth-store.d.ts",
|
|
17
|
+
"import": "./dist/oauth-store.js"
|
|
18
|
+
},
|
|
19
|
+
"./users": {
|
|
20
|
+
"types": "./dist/users.d.ts",
|
|
21
|
+
"import": "./dist/users.js"
|
|
22
|
+
},
|
|
23
|
+
"./routes/auth": {
|
|
24
|
+
"types": "./dist/routes/auth.d.ts",
|
|
25
|
+
"import": "./dist/routes/auth.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun build ./src/index.ts ./src/oauth-store.ts ./src/users.ts ./src/routes/auth.ts --outdir ./dist --target node --format esm --external @modelcontextprotocol/sdk --external zod && tsc",
|
|
33
|
+
"postbuild": "node -e \"require('fs').chmodSync('./dist/index.js', 0o755)\""
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
37
|
+
"sendkit-core": "^0.1.0",
|
|
38
|
+
"zod": "^4.4.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^26.1.0"
|
|
42
|
+
}
|
|
43
|
+
}
|