msteams 0.1.0 → 0.1.2
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 +21 -0
- package/README.md +94 -80
- package/package.json +5 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shotaro Nakamura
|
|
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
CHANGED
|
@@ -1,107 +1,121 @@
|
|
|
1
1
|
# teams-api
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`msteams` is a lightweight TypeScript library and CLI for interacting with Microsoft Teams endpoints used by the web client.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Warning
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
7
|
+
* Node.js is currently not supported yet. Use Bun
|
|
8
|
+
* Auth token should be updated in 24 hours. Automatic token updating is working in progress.
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## Overview
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
- CLI: use the `teams` command to fetch notifications, messages, channels, and user/team data
|
|
13
|
+
- Library: use `TeamsClient` and `TokenManager` to access the same endpoints from TypeScript
|
|
14
|
+
- Token handling: refresh token is stored as a local profile in `~/.teams-cli/<name>.json`
|
|
15
|
+
- Machine mode: use `--json` for scripts and automation
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
> Warning: This package uses unofficial endpoints. Behavior may change if Microsoft updates those APIs.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
console.log('teams:', bootstrap.teams?.length ?? 0)
|
|
20
|
-
console.log('chats:', bootstrap.chats?.length ?? 0)
|
|
19
|
+
## Install
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
```bash
|
|
22
|
+
bun add msteams
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
```bash
|
|
26
|
+
npm install msteams
|
|
27
|
+
```
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
import { TeamsApiClient } from './index.ts'
|
|
29
|
+
## CLI usage
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
```bash
|
|
32
|
+
# Show help
|
|
33
|
+
bunx --bun teams --help
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
### Set refresh token
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
bun
|
|
40
|
-
# 出力されたファイルは bunx oxfmt で整形
|
|
39
|
+
bunx --bun teams set-refresh-token --refresh-token=<your_refresh_token>
|
|
41
40
|
```
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- `
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- `cookie` のみでクライアントを作成。初回 API 呼び出し時、または `refreshSkypeTokenFromCookie()` で `authsvc` から `skypeToken` を取得
|
|
49
|
-
- `listBootstrap()`
|
|
50
|
-
- `api/csa/{geo}/api/v3/teams/users/me` を呼び、チーム/チャット一覧を取得
|
|
51
|
-
- `listTeams()`, `listChats()`
|
|
52
|
-
- `listBootstrap()` の便利ラッパー
|
|
53
|
-
- `listChannelPosts(teamId, channelId)`
|
|
54
|
-
- `api/csa/{geo}/api/v1/teams/{teamId}/channels/{channelId}` を呼び、投稿スレッド(`replyChains`)を取得
|
|
55
|
-
- `listChannelMessages(teamId, channelId)`
|
|
56
|
-
- `replyChains` からメッセージを平坦化
|
|
57
|
-
- `getConversation(conversationId)`
|
|
58
|
-
- `api/chatsvc/{geo}/api/v1/users/ME/conversations/{conversationId}` を取得
|
|
59
|
-
- `listConversationMessages(conversationId, options)`
|
|
60
|
-
- `api/chatsvc/{geo}/api/v1/users/ME/conversations/{conversationId}/messages` を取得
|
|
61
|
-
- `listNotificationMessages()`, `listMentionMessages()`, `listAnnotationMessages()`
|
|
62
|
-
- それぞれ `48:notifications`, `48:mentions`, `48:annotations` の便利ラッパー
|
|
63
|
-
|
|
64
|
-
## CLI Usage
|
|
42
|
+
- Default profile path: `~/.teams-cli/default.json`
|
|
43
|
+
- You can change the profile with `--profile`
|
|
44
|
+
- You can also pass token via `--refresh-token` or `REFRESH_TOKEN`
|
|
45
|
+
|
|
46
|
+
### Common commands
|
|
65
47
|
|
|
66
48
|
```bash
|
|
67
|
-
|
|
49
|
+
# Fetch latest notifications (default: 20)
|
|
50
|
+
teams notifications [--limit N]
|
|
51
|
+
|
|
52
|
+
# Fetch conversation messages
|
|
53
|
+
teams messages <conversationId> [--limit N]
|
|
54
|
+
|
|
55
|
+
# Fetch channel messages
|
|
56
|
+
teams channel messages <channelId> [--limit N]
|
|
57
|
+
|
|
58
|
+
# List teams
|
|
59
|
+
teams teams list
|
|
60
|
+
|
|
61
|
+
# List channels in a team
|
|
62
|
+
teams teams channels <teamId>
|
|
63
|
+
|
|
64
|
+
# Fetch current user snapshot
|
|
65
|
+
teams me
|
|
68
66
|
```
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
### Common options
|
|
69
|
+
|
|
70
|
+
- `--json`: output only JSON
|
|
71
|
+
- `--no-color`: disable ANSI colors
|
|
72
|
+
- `--profile=<name>`: use another local profile name
|
|
73
|
+
- `--profile-json=<path>`: use a custom profile JSON file
|
|
74
|
+
- `--refresh-token=<token>`: set token for current run
|
|
75
|
+
- `--help`: show help
|
|
76
|
+
|
|
77
|
+
## Library usage
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { TeamsClient, TokenManager } from 'msteams'
|
|
81
|
+
|
|
82
|
+
const tokenManager = new TokenManager(process.env.REFRESH_TOKEN || '')
|
|
83
|
+
const client = new TeamsClient(tokenManager)
|
|
84
|
+
|
|
85
|
+
const me = await client.teams.users.me.fetch()
|
|
86
|
+
console.log(me.teams?.length ?? 0, 'teams')
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const notifications = await client.teams.notifications.fetchMessages({ pageSize: 10 })
|
|
91
|
+
console.log(notifications.messages?.length ?? 0)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Exported API
|
|
95
|
+
|
|
96
|
+
- `TokenManager`
|
|
97
|
+
- `ScopeTokenProvider`
|
|
98
|
+
- `TeamsClient`
|
|
99
|
+
- `teams.conversations.fetchMessages`
|
|
100
|
+
- `teams.notifications.fetchMessages`, `fetchMentions`, `fetchAnnotations`
|
|
101
|
+
- `teams.channels.fetch`, `teams.channels.fetchMessages`
|
|
102
|
+
- `teams.users.fetchShortProfile`
|
|
103
|
+
- `teams.users.me.fetch`, `teams.users.me.fetchPinnedChannels`
|
|
104
|
+
|
|
105
|
+
## Development
|
|
71
106
|
|
|
72
107
|
```bash
|
|
73
|
-
|
|
108
|
+
bun install
|
|
109
|
+
bun run build
|
|
110
|
+
bun run fmt
|
|
74
111
|
```
|
|
75
112
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- 参加チーム一覧を取得
|
|
86
|
-
- `teams teams channels <teamId>`
|
|
87
|
-
- 指定チームのチャンネル一覧を取得
|
|
88
|
-
- `teams me`
|
|
89
|
-
- 現在ユーザー情報(チーム/チャット含む)を取得
|
|
90
|
-
- `teams set-refresh-token --refresh-token=<token> [--profile=<name>]`
|
|
91
|
-
- プロファイルへリフレッシュトークンを保存
|
|
92
|
-
|
|
93
|
-
### Options
|
|
94
|
-
|
|
95
|
-
- `--profile=<name>`: `~/.teams-cli/<name>.json` を使用(既定: `default`)
|
|
96
|
-
- `--profile-json=<path>`: 任意の profile json を使用
|
|
97
|
-
- `--refresh-token=<token>`: リフレッシュトークンを指定
|
|
98
|
-
- `--json`: 機械可読 JSON で出力
|
|
99
|
-
- `--no-color`: ANSI カラーを無効化
|
|
100
|
-
- `--help`: ヘルプ表示
|
|
101
|
-
|
|
102
|
-
## Notes
|
|
103
|
-
|
|
104
|
-
- 本実装は **write 系 API を含みません**。
|
|
105
|
-
- `HAR` は通常 `Authorization/Cookie` を完全に含まないため、抽出できる `skypeToken` の有効期限切れ時は再取得が必要です。
|
|
106
|
-
- `cookie` 単体で動かす場合でも、内部では `https://teams.microsoft.com/api/authsvc/v1.0/authz` に対して `cookie` を使い `skypeToken` を取得してから各 API を呼びます。
|
|
107
|
-
- `fromCookie()` で `endpoint.baseUrl` を上書きした場合、`endpoint.authzUrl` を未指定ならクラウド環境に応じた `authsvc` URL を自動推定します。
|
|
113
|
+
The package uses `vite-plus` to build both library and CLI entry points.
|
|
114
|
+
|
|
115
|
+
## Repository
|
|
116
|
+
|
|
117
|
+
- https://github.com/nakasyou/teams-api
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msteams",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./dist/index.d.mts"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/nakasyou/teams-api.git"
|
|
21
|
+
},
|
|
18
22
|
"type": "module",
|
|
19
23
|
"scripts": {
|
|
20
24
|
"cli": "bun run src/cli/index.ts",
|