@bmhall2/skylight-mcp 1.1.7
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 +265 -0
- package/dist/api/auth.d.ts +38 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +62 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/client.d.ts +84 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +228 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/endpoints/calendar.d.ts +33 -0
- package/dist/api/endpoints/calendar.d.ts.map +1 -0
- package/dist/api/endpoints/calendar.js +60 -0
- package/dist/api/endpoints/calendar.js.map +1 -0
- package/dist/api/endpoints/categories.d.ts +23 -0
- package/dist/api/endpoints/categories.d.ts.map +1 -0
- package/dist/api/endpoints/categories.js +48 -0
- package/dist/api/endpoints/categories.js.map +1 -0
- package/dist/api/endpoints/chores.d.ts +50 -0
- package/dist/api/endpoints/chores.d.ts.map +1 -0
- package/dist/api/endpoints/chores.js +106 -0
- package/dist/api/endpoints/chores.js.map +1 -0
- package/dist/api/endpoints/devices.d.ts +6 -0
- package/dist/api/endpoints/devices.d.ts.map +1 -0
- package/dist/api/endpoints/devices.js +10 -0
- package/dist/api/endpoints/devices.js.map +1 -0
- package/dist/api/endpoints/frames.d.ts +6 -0
- package/dist/api/endpoints/frames.d.ts.map +1 -0
- package/dist/api/endpoints/frames.js +10 -0
- package/dist/api/endpoints/frames.js.map +1 -0
- package/dist/api/endpoints/lists.d.ts +55 -0
- package/dist/api/endpoints/lists.d.ts.map +1 -0
- package/dist/api/endpoints/lists.js +125 -0
- package/dist/api/endpoints/lists.js.map +1 -0
- package/dist/api/endpoints/meals.d.ts +102 -0
- package/dist/api/endpoints/meals.d.ts.map +1 -0
- package/dist/api/endpoints/meals.js +100 -0
- package/dist/api/endpoints/meals.js.map +1 -0
- package/dist/api/endpoints/misc.d.ts +27 -0
- package/dist/api/endpoints/misc.d.ts.map +1 -0
- package/dist/api/endpoints/misc.js +18 -0
- package/dist/api/endpoints/misc.js.map +1 -0
- package/dist/api/endpoints/photos.d.ts +13 -0
- package/dist/api/endpoints/photos.d.ts.map +1 -0
- package/dist/api/endpoints/photos.js +10 -0
- package/dist/api/endpoints/photos.js.map +1 -0
- package/dist/api/endpoints/rewards.d.ts +49 -0
- package/dist/api/endpoints/rewards.d.ts.map +1 -0
- package/dist/api/endpoints/rewards.js +105 -0
- package/dist/api/endpoints/rewards.js.map +1 -0
- package/dist/api/endpoints/taskbox.d.ts +13 -0
- package/dist/api/endpoints/taskbox.d.ts.map +1 -0
- package/dist/api/endpoints/taskbox.js +22 -0
- package/dist/api/endpoints/taskbox.js.map +1 -0
- package/dist/api/generated-types.d.ts +18967 -0
- package/dist/api/generated-types.d.ts.map +1 -0
- package/dist/api/generated-types.js +6 -0
- package/dist/api/generated-types.js.map +1 -0
- package/dist/api/types.d.ts +283 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +5 -0
- package/dist/api/types.js.map +1 -0
- package/dist/config.d.ts +52 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +80 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +48 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/calendar.d.ts +3 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +297 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/chores.d.ts +3 -0
- package/dist/tools/chores.d.ts.map +1 -0
- package/dist/tools/chores.js +349 -0
- package/dist/tools/chores.js.map +1 -0
- package/dist/tools/family.d.ts +3 -0
- package/dist/tools/family.d.ts.map +1 -0
- package/dist/tools/family.js +182 -0
- package/dist/tools/family.js.map +1 -0
- package/dist/tools/lists.d.ts +3 -0
- package/dist/tools/lists.d.ts.map +1 -0
- package/dist/tools/lists.js +481 -0
- package/dist/tools/lists.js.map +1 -0
- package/dist/tools/meals.d.ts +3 -0
- package/dist/tools/meals.d.ts.map +1 -0
- package/dist/tools/meals.js +319 -0
- package/dist/tools/meals.js.map +1 -0
- package/dist/tools/misc.d.ts +3 -0
- package/dist/tools/misc.d.ts.map +1 -0
- package/dist/tools/misc.js +101 -0
- package/dist/tools/misc.js.map +1 -0
- package/dist/tools/photos.d.ts +3 -0
- package/dist/tools/photos.d.ts.map +1 -0
- package/dist/tools/photos.js +42 -0
- package/dist/tools/photos.js.map +1 -0
- package/dist/tools/rewards.d.ts +3 -0
- package/dist/tools/rewards.d.ts.map +1 -0
- package/dist/tools/rewards.js +338 -0
- package/dist/tools/rewards.js.map +1 -0
- package/dist/tools/tasks.d.ts +3 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +68 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/utils/dates.d.ts +26 -0
- package/dist/utils/dates.d.ts.map +1 -0
- package/dist/utils/dates.js +109 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/errors.d.ts +45 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +102 -0
- package/dist/utils/errors.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 EagleByte
|
|
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,265 @@
|
|
|
1
|
+
# Skylight MCP Server
|
|
2
|
+
|
|
3
|
+
> **Maintained fork** of [TheEagleByte/skylight-mcp](https://github.com/TheEagleByte/skylight-mcp). The original project appears to be abandoned; this fork continues active development.
|
|
4
|
+
|
|
5
|
+
An MCP (Model Context Protocol) server for the Skylight Calendar API. Enables AI assistants like Claude to interact with your Skylight family calendar, chores, lists, and more.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Calendar**: Query calendar events ("What's on my calendar today?")
|
|
10
|
+
- **Chores**: View and create chores ("Add emptying dishwasher to chores")
|
|
11
|
+
- **Lists**: View grocery and to-do lists ("What's on the grocery list?")
|
|
12
|
+
- **Tasks**: Add items to the task box ("Add XYZ to my task list")
|
|
13
|
+
- **Family**: View family members and devices
|
|
14
|
+
- **Rewards**: Check reward points and available rewards
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### Installation
|
|
19
|
+
|
|
20
|
+
#### Option 1: npm package (Recommended)
|
|
21
|
+
|
|
22
|
+
**mcp.json:**
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"mcpServers": {
|
|
26
|
+
"skylight": {
|
|
27
|
+
"command": "npx",
|
|
28
|
+
"args": ["@bmhall2/skylight-mcp"],
|
|
29
|
+
"env": {
|
|
30
|
+
"SKYLIGHT_EMAIL": "your_email@example.com",
|
|
31
|
+
"SKYLIGHT_PASSWORD": "your_password",
|
|
32
|
+
"SKYLIGHT_FRAME_ID": "your_frame_id"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Claude Code:**
|
|
40
|
+
```bash
|
|
41
|
+
claude mcp add skylight npx @bmhall2/skylight-mcp \
|
|
42
|
+
-e SKYLIGHT_EMAIL=your_email@example.com \
|
|
43
|
+
-e SKYLIGHT_PASSWORD=your_password \
|
|
44
|
+
-e SKYLIGHT_FRAME_ID=your_frame_id
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Option 2: From source
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/bmhall2/skylight-mcp.git
|
|
51
|
+
cd skylight-mcp && npm install && npm run build
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then use in mcp.json:
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"skylight": {
|
|
59
|
+
"command": "node",
|
|
60
|
+
"args": ["/path/to/skylight-mcp/dist/index.js"],
|
|
61
|
+
"env": {
|
|
62
|
+
"SKYLIGHT_EMAIL": "your_email@example.com",
|
|
63
|
+
"SKYLIGHT_PASSWORD": "your_password",
|
|
64
|
+
"SKYLIGHT_FRAME_ID": "your_frame_id"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Instructions for AI
|
|
72
|
+
|
|
73
|
+
Copy this into your AI's custom instructions or system prompt:
|
|
74
|
+
|
|
75
|
+
> You have access to the Skylight MCP server. Skylight is a smart family calendar display that shows calendars, chores, grocery lists, meals, and rewards. Use the Skylight tools to help manage family schedules and organization.
|
|
76
|
+
>
|
|
77
|
+
> Tips:
|
|
78
|
+
> - Call `get_family_members` before assigning chores to get member names
|
|
79
|
+
> - Grocery items default to the main grocery list if no list specified
|
|
80
|
+
> - Dates accept "today", "tomorrow", day names, or YYYY-MM-DD format
|
|
81
|
+
> - Some tools (rewards, meals, photos) require Skylight Plus subscription
|
|
82
|
+
|
|
83
|
+
## Prerequisites
|
|
84
|
+
|
|
85
|
+
- Node.js 18+
|
|
86
|
+
- A Skylight account with an active subscription
|
|
87
|
+
- Your Skylight Frame ID (see [Finding your Frame ID](#finding-your-frame-id))
|
|
88
|
+
|
|
89
|
+
## Authentication
|
|
90
|
+
|
|
91
|
+
The MCP server supports two authentication methods:
|
|
92
|
+
|
|
93
|
+
### Option 1: Email/Password (Recommended)
|
|
94
|
+
|
|
95
|
+
Use your Skylight account credentials. The server will automatically log in and manage tokens.
|
|
96
|
+
|
|
97
|
+
```env
|
|
98
|
+
SKYLIGHT_EMAIL=your_email@example.com
|
|
99
|
+
SKYLIGHT_PASSWORD=your_password
|
|
100
|
+
SKYLIGHT_FRAME_ID=your_frame_id
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Option 2: Manual Token (Legacy)
|
|
104
|
+
|
|
105
|
+
Capture a token from the Skylight app using a proxy tool.
|
|
106
|
+
|
|
107
|
+
```env
|
|
108
|
+
SKYLIGHT_TOKEN=your_token_here
|
|
109
|
+
SKYLIGHT_FRAME_ID=your_frame_id
|
|
110
|
+
SKYLIGHT_AUTH_TYPE=bearer
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Finding your Frame ID
|
|
114
|
+
|
|
115
|
+
You still need to find your frame ID (the household identifier):
|
|
116
|
+
|
|
117
|
+
1. Use a proxy tool ([Proxyman](https://proxyman.io/), [Charles](https://www.charlesproxy.com/), or [mitmproxy](https://mitmproxy.org/))
|
|
118
|
+
2. Capture any API request from the Skylight app
|
|
119
|
+
3. Look at the URL path: `/api/frames/{frameId}/...`
|
|
120
|
+
4. Example: `/api/frames/abc123/chores` → frame ID is `abc123`
|
|
121
|
+
|
|
122
|
+
## Configuration
|
|
123
|
+
|
|
124
|
+
| Variable | Required | Description |
|
|
125
|
+
|----------|----------|-------------|
|
|
126
|
+
| `SKYLIGHT_EMAIL` | Option 1 | Your Skylight account email |
|
|
127
|
+
| `SKYLIGHT_PASSWORD` | Option 1 | Your Skylight account password |
|
|
128
|
+
| `SKYLIGHT_TOKEN` | Option 2 | Your API token (if not using email/password) |
|
|
129
|
+
| `SKYLIGHT_AUTH_TYPE` | No | `bearer` (default) or `basic` (for manual token) |
|
|
130
|
+
| `SKYLIGHT_FRAME_ID` | Yes | Your household frame ID |
|
|
131
|
+
| `SKYLIGHT_TIMEZONE` | No | Default timezone (default: `America/New_York`) |
|
|
132
|
+
|
|
133
|
+
### Example .env file:
|
|
134
|
+
|
|
135
|
+
```env
|
|
136
|
+
# Email/password auth (recommended)
|
|
137
|
+
SKYLIGHT_EMAIL=your_email@example.com
|
|
138
|
+
SKYLIGHT_PASSWORD=your_password
|
|
139
|
+
SKYLIGHT_FRAME_ID=your_frame_id
|
|
140
|
+
SKYLIGHT_TIMEZONE=America/New_York
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Available Tools
|
|
144
|
+
|
|
145
|
+
### Calendar Tools
|
|
146
|
+
|
|
147
|
+
| Tool | Description |
|
|
148
|
+
|------|-------------|
|
|
149
|
+
| `get_calendar_events` | Get calendar events for a date range |
|
|
150
|
+
| `get_source_calendars` | List connected calendar sources (Google, iCloud, etc.) |
|
|
151
|
+
|
|
152
|
+
### Chore Tools
|
|
153
|
+
|
|
154
|
+
| Tool | Description |
|
|
155
|
+
|------|-------------|
|
|
156
|
+
| `get_chores` | Get chores with optional filters (date, assignee, status) |
|
|
157
|
+
| `create_chore` | Create a new chore with optional recurrence |
|
|
158
|
+
|
|
159
|
+
### List Tools
|
|
160
|
+
|
|
161
|
+
| Tool | Description |
|
|
162
|
+
|------|-------------|
|
|
163
|
+
| `get_lists` | Get all available lists |
|
|
164
|
+
| `get_list_items` | Get items from a specific list |
|
|
165
|
+
|
|
166
|
+
### Task Tools
|
|
167
|
+
|
|
168
|
+
| Tool | Description |
|
|
169
|
+
|------|-------------|
|
|
170
|
+
| `create_task` | Add a task to the task box |
|
|
171
|
+
|
|
172
|
+
### Family Tools
|
|
173
|
+
|
|
174
|
+
| Tool | Description |
|
|
175
|
+
|------|-------------|
|
|
176
|
+
| `get_family_members` | Get family member profiles |
|
|
177
|
+
| `get_frame_info` | Get household/frame information |
|
|
178
|
+
| `get_devices` | List Skylight devices |
|
|
179
|
+
|
|
180
|
+
### Reward Tools
|
|
181
|
+
|
|
182
|
+
| Tool | Description |
|
|
183
|
+
|------|-------------|
|
|
184
|
+
| `get_rewards` | Get available rewards |
|
|
185
|
+
| `get_reward_points` | Get reward points balance |
|
|
186
|
+
|
|
187
|
+
## Example Queries
|
|
188
|
+
|
|
189
|
+
Once configured, you can ask Claude things like:
|
|
190
|
+
|
|
191
|
+
- "What's on my calendar today?"
|
|
192
|
+
- "What chores do I need to do this week?"
|
|
193
|
+
- "Add 'take out trash' to my chores for tomorrow"
|
|
194
|
+
- "What's on the grocery list?"
|
|
195
|
+
- "Add milk to my task list"
|
|
196
|
+
- "Who are the family members on Skylight?"
|
|
197
|
+
- "How many reward points does each person have?"
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Run in development mode (with hot reload)
|
|
203
|
+
npm run dev
|
|
204
|
+
|
|
205
|
+
# Build
|
|
206
|
+
npm run build
|
|
207
|
+
|
|
208
|
+
# Run tests
|
|
209
|
+
npm test
|
|
210
|
+
|
|
211
|
+
# Type check
|
|
212
|
+
npm run typecheck
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## API Documentation
|
|
216
|
+
|
|
217
|
+
This MCP server is built on top of the reverse-engineered Skylight API. The API endpoints were documented using the [skylight-api](https://github.com/TheEagleByte/skylight-api) project, which converts browser network traffic (HAR files) into an OpenAPI specification.
|
|
218
|
+
|
|
219
|
+
**API Resources:**
|
|
220
|
+
- [Interactive API Docs (Swagger UI)](https://theeaglebyte.github.io/skylight-api/swagger.html)
|
|
221
|
+
- [API Reference (ReDoc)](https://theeaglebyte.github.io/skylight-api/redoc.html)
|
|
222
|
+
- [OpenAPI Specification](https://theeaglebyte.github.io/skylight-api/openapi/openapi.yaml)
|
|
223
|
+
|
|
224
|
+
If you discover new API endpoints or find issues with the current documentation, please contribute to the [skylight-api](https://github.com/TheEagleByte/skylight-api) repository.
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
Contributions are welcome! Here's how you can help:
|
|
229
|
+
|
|
230
|
+
1. **Fork the repository** and create a feature branch
|
|
231
|
+
2. **Make your changes** with clear, descriptive commits
|
|
232
|
+
3. **Run tests** (`npm test`) and linting (`npm run lint`) before submitting
|
|
233
|
+
4. **Open a pull request** with a description of your changes
|
|
234
|
+
|
|
235
|
+
### Development Setup
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
git clone https://github.com/bmhall2/skylight-mcp.git
|
|
239
|
+
cd skylight-mcp
|
|
240
|
+
npm install
|
|
241
|
+
npm run dev # Start with hot reload
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Areas for Contribution
|
|
245
|
+
|
|
246
|
+
- Adding support for new Skylight API endpoints
|
|
247
|
+
- Improving error handling and edge cases
|
|
248
|
+
- Enhancing documentation
|
|
249
|
+
- Writing additional tests
|
|
250
|
+
|
|
251
|
+
## Issues & Support
|
|
252
|
+
|
|
253
|
+
- **Bug reports**: [Open an issue](https://github.com/bmhall2/skylight-mcp/issues/new) with steps to reproduce
|
|
254
|
+
- **Feature requests**: [Open an issue](https://github.com/bmhall2/skylight-mcp/issues/new) describing the use case
|
|
255
|
+
- **Questions**: [Start a discussion](https://github.com/bmhall2/skylight-mcp/discussions) or open an issue
|
|
256
|
+
|
|
257
|
+
Please include relevant details like your Node.js version, error messages, and configuration (with sensitive values redacted).
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT
|
|
262
|
+
|
|
263
|
+
## Disclaimer
|
|
264
|
+
|
|
265
|
+
This is an unofficial integration. The Skylight API is reverse-engineered and may change without notice. Use at your own risk.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skylight Authentication
|
|
3
|
+
* Handles login via email/password to obtain API token
|
|
4
|
+
*/
|
|
5
|
+
export interface LoginResponse {
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
type: "authenticated_user";
|
|
9
|
+
attributes: {
|
|
10
|
+
email: string;
|
|
11
|
+
token: string;
|
|
12
|
+
subscription_status: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
meta?: {
|
|
16
|
+
password_reset?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface AuthResult {
|
|
20
|
+
userId: string;
|
|
21
|
+
email: string;
|
|
22
|
+
token: string;
|
|
23
|
+
subscriptionStatus: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Login to Skylight with email and password
|
|
27
|
+
* Returns the authentication token and user info
|
|
28
|
+
*/
|
|
29
|
+
export declare function login(email: string, password: string): Promise<AuthResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Get cached auth result or login if needed
|
|
32
|
+
*/
|
|
33
|
+
export declare function getAuth(email: string, password: string): Promise<AuthResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Clear cached auth (for re-login)
|
|
36
|
+
*/
|
|
37
|
+
export declare function clearAuthCache(): void;
|
|
38
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,oBAAoB,CAAC;QAC3B,UAAU,EAAE;YACV,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;YACd,mBAAmB,EAAE,MAAM,CAAC;SAC7B,CAAC;KACH,CAAC;IACF,IAAI,CAAC,EAAE;QACL,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuChF;AAKD;;GAEG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAOlF;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
|
package/dist/api/auth.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skylight Authentication
|
|
3
|
+
* Handles login via email/password to obtain API token
|
|
4
|
+
*/
|
|
5
|
+
const BASE_URL = "https://app.ourskylight.com";
|
|
6
|
+
/**
|
|
7
|
+
* Login to Skylight with email and password
|
|
8
|
+
* Returns the authentication token and user info
|
|
9
|
+
*/
|
|
10
|
+
export async function login(email, password) {
|
|
11
|
+
console.error(`[auth] Attempting login for ${email}...`);
|
|
12
|
+
const response = await fetch(`${BASE_URL}/api/sessions`, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
Accept: "application/json",
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({ email, password }),
|
|
19
|
+
});
|
|
20
|
+
console.error(`[auth] Login response status: ${response.status}`);
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
let errorBody = "";
|
|
23
|
+
try {
|
|
24
|
+
errorBody = await response.text();
|
|
25
|
+
console.error(`[auth] Login error response: ${errorBody}`);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// ignore
|
|
29
|
+
}
|
|
30
|
+
if (response.status === 401) {
|
|
31
|
+
throw new Error(`Invalid email or password. Please check your SKYLIGHT_EMAIL and SKYLIGHT_PASSWORD environment variables.`);
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Login failed: HTTP ${response.status}${errorBody ? ` - ${errorBody}` : ""}`);
|
|
34
|
+
}
|
|
35
|
+
const data = (await response.json());
|
|
36
|
+
console.error(`[auth] Login successful, token prefix: ${data.data.attributes.token.substring(0, 10)}...`);
|
|
37
|
+
return {
|
|
38
|
+
userId: data.data.id,
|
|
39
|
+
email: data.data.attributes.email,
|
|
40
|
+
token: data.data.attributes.token,
|
|
41
|
+
subscriptionStatus: data.data.attributes.subscription_status,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Cache for auth result
|
|
45
|
+
let cachedAuth = null;
|
|
46
|
+
/**
|
|
47
|
+
* Get cached auth result or login if needed
|
|
48
|
+
*/
|
|
49
|
+
export async function getAuth(email, password) {
|
|
50
|
+
if (cachedAuth) {
|
|
51
|
+
return cachedAuth;
|
|
52
|
+
}
|
|
53
|
+
cachedAuth = await login(email, password);
|
|
54
|
+
return cachedAuth;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clear cached auth (for re-login)
|
|
58
|
+
*/
|
|
59
|
+
export function clearAuthCache() {
|
|
60
|
+
cachedAuth = null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,QAAQ,GAAG,6BAA6B,CAAC;AAwB/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,KAAa,EAAE,QAAgB;IACzD,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,KAAK,CAAC,CAAC;IAEzD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,QAAQ,eAAe,EAAE;QACvD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;SAC3B;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;KAC1C,CAAC,CAAC;IAEH,OAAO,CAAC,KAAK,CAAC,iCAAiC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;QAC9H,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAkB,CAAC;IAEtD,OAAO,CAAC,KAAK,CAAC,0CAA0C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAE1G,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK;QACjC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK;QACjC,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB;KAC7D,CAAC;AACJ,CAAC;AAED,wBAAwB;AACxB,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAAa,EAAE,QAAgB;IAC3D,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,UAAU,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type Config } from "../config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Skylight subscription status types
|
|
4
|
+
*/
|
|
5
|
+
export type SubscriptionStatus = "plus" | "free" | "trial" | null;
|
|
6
|
+
export interface RequestOptions {
|
|
7
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
8
|
+
params?: Record<string, string | boolean | number | undefined>;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Skylight API Client
|
|
13
|
+
* Handles authentication and HTTP requests to the Skylight API
|
|
14
|
+
*/
|
|
15
|
+
export declare class SkylightClient {
|
|
16
|
+
private config;
|
|
17
|
+
private resolvedToken;
|
|
18
|
+
private resolvedUserId;
|
|
19
|
+
private loginPromise;
|
|
20
|
+
private subscriptionStatus;
|
|
21
|
+
constructor(config?: Config);
|
|
22
|
+
/**
|
|
23
|
+
* Get the authentication credentials
|
|
24
|
+
* If using email/password auth, will login first
|
|
25
|
+
*/
|
|
26
|
+
private getCredentials;
|
|
27
|
+
/**
|
|
28
|
+
* Perform login and return token and userId
|
|
29
|
+
*/
|
|
30
|
+
private performLogin;
|
|
31
|
+
/**
|
|
32
|
+
* Build the Authorization header
|
|
33
|
+
* For email/password auth: Basic base64(userId:token)
|
|
34
|
+
* For manual token auth: Bearer or Basic based on config
|
|
35
|
+
*/
|
|
36
|
+
private getAuthHeader;
|
|
37
|
+
/**
|
|
38
|
+
* Build URL with query parameters
|
|
39
|
+
*/
|
|
40
|
+
private buildUrl;
|
|
41
|
+
/**
|
|
42
|
+
* Handle API response errors
|
|
43
|
+
*/
|
|
44
|
+
private handleResponseError;
|
|
45
|
+
/**
|
|
46
|
+
* Make an authenticated request to the Skylight API
|
|
47
|
+
*/
|
|
48
|
+
request<T>(endpoint: string, options?: RequestOptions, isRetry?: boolean): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* GET request helper
|
|
51
|
+
*/
|
|
52
|
+
get<T>(endpoint: string, params?: Record<string, string | boolean | number | undefined>): Promise<T>;
|
|
53
|
+
/**
|
|
54
|
+
* POST request helper
|
|
55
|
+
*/
|
|
56
|
+
post<T>(endpoint: string, body: unknown): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the frame ID from config
|
|
59
|
+
*/
|
|
60
|
+
get frameId(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get the timezone from config
|
|
63
|
+
*/
|
|
64
|
+
get timezone(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Check if user has Plus subscription
|
|
67
|
+
*/
|
|
68
|
+
hasPlus(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get the subscription status
|
|
71
|
+
*/
|
|
72
|
+
getSubscriptionStatus(): SubscriptionStatus;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the client (triggers login if using email/password auth)
|
|
75
|
+
*/
|
|
76
|
+
initialize(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export declare function getClient(): SkylightClient;
|
|
79
|
+
/**
|
|
80
|
+
* Initialize the client singleton and return it
|
|
81
|
+
* This triggers login if using email/password auth
|
|
82
|
+
*/
|
|
83
|
+
export declare function initializeClient(): Promise<SkylightClient>;
|
|
84
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAWrE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,YAAY,CAA2D;IAC/E,OAAO,CAAC,kBAAkB,CAA4B;gBAE1C,MAAM,CAAC,EAAE,MAAM;IAI3B;;;OAGG;YACW,cAAc;IA6B5B;;OAEG;YACW,YAAY;IAa1B;;;;OAIG;YACW,aAAa;IAgB3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAchB;;OAEG;YACW,mBAAmB;IAyCjC;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IA6C7F;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1G;;OAEG;IACG,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1D;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,qBAAqB,IAAI,kBAAkB;IAI3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC;AAKD,wBAAgB,SAAS,IAAI,cAAc,CAK1C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC,CAIhE"}
|