@vybit/oauth2-sdk 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/README.md +137 -0
- package/dist/__tests__/oauth2-client.test.d.ts +8 -0
- package/dist/__tests__/oauth2-client.test.d.ts.map +1 -0
- package/dist/__tests__/oauth2-client.test.js +267 -0
- package/dist/__tests__/oauth2-client.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth2-client.d.ts +88 -0
- package/dist/oauth2-client.d.ts.map +1 -0
- package/dist/oauth2-client.js +247 -0
- package/dist/oauth2-client.js.map +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# @vybit/oauth2-sdk
|
|
2
|
+
|
|
3
|
+
OAuth 2.0 authentication SDK for Vybit.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Complete OAuth2 implementation for Vybit authentication, including authorization URL generation, token exchange, and authenticated API calls.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @vybit/oauth2-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { VybitOAuth2Client } from '@vybit/oauth2-sdk';
|
|
19
|
+
|
|
20
|
+
// Create client with your OAuth2 credentials
|
|
21
|
+
const client = new VybitOAuth2Client({
|
|
22
|
+
clientId: 'your-client-id',
|
|
23
|
+
clientSecret: 'your-client-secret',
|
|
24
|
+
redirectUri: 'https://yourapp.com/oauth/callback'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Step 1: Generate authorization URL
|
|
28
|
+
const authUrl = client.getAuthorizationUrl({
|
|
29
|
+
state: 'unique-state-value',
|
|
30
|
+
scope: 'read write'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Redirect user to authUrl...
|
|
34
|
+
|
|
35
|
+
// Step 2: Exchange authorization code for token
|
|
36
|
+
const token = await client.exchangeCodeForToken('auth-code-from-callback');
|
|
37
|
+
|
|
38
|
+
// Step 3: Make authenticated API calls
|
|
39
|
+
const vybits = await client.getVybitList();
|
|
40
|
+
await client.sendVybitNotification('trigger-key', {
|
|
41
|
+
message: 'Hello from your app!'
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Environment Management
|
|
46
|
+
|
|
47
|
+
The SDK always uses production Vybit endpoints:
|
|
48
|
+
- **Authentication**: `https://app.vybit.net`
|
|
49
|
+
- **API**: `https://vybit.net`
|
|
50
|
+
|
|
51
|
+
For different environments (dev/staging/prod), create separate Vybit accounts with their own OAuth credentials rather than using different endpoints.
|
|
52
|
+
|
|
53
|
+
## API Reference
|
|
54
|
+
|
|
55
|
+
### VybitOAuth2Client
|
|
56
|
+
|
|
57
|
+
#### Constructor
|
|
58
|
+
```typescript
|
|
59
|
+
new VybitOAuth2Client(config: OAuth2Config)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Methods
|
|
63
|
+
|
|
64
|
+
**`getAuthorizationUrl(options?: AuthorizationUrlOptions): string`**
|
|
65
|
+
- Generates OAuth2 authorization URL for user redirection
|
|
66
|
+
- Returns complete URL including all required parameters
|
|
67
|
+
|
|
68
|
+
**`exchangeCodeForToken(code: string): Promise<TokenResponse>`**
|
|
69
|
+
- Exchanges authorization code for access token
|
|
70
|
+
- Automatically stores token for subsequent API calls
|
|
71
|
+
|
|
72
|
+
**`verifyToken(accessToken?: string): Promise<boolean>`**
|
|
73
|
+
- Verifies if an access token is valid
|
|
74
|
+
- Uses stored token if none provided
|
|
75
|
+
|
|
76
|
+
**`getVybitList(accessToken?: string): Promise<Vybit[]>`**
|
|
77
|
+
- Fetches user's vybit notifications
|
|
78
|
+
- Requires valid access token
|
|
79
|
+
|
|
80
|
+
**`sendVybitNotification(triggerKey: string, options?: TriggerOptions, accessToken?: string): Promise<TriggerResponse>`**
|
|
81
|
+
- Triggers a vybit notification
|
|
82
|
+
- Supports custom message, images, and links
|
|
83
|
+
|
|
84
|
+
**`setAccessToken(token: string): void`**
|
|
85
|
+
- Manually set access token
|
|
86
|
+
|
|
87
|
+
**`getAccessToken(): string | undefined`**
|
|
88
|
+
- Get currently stored access token
|
|
89
|
+
|
|
90
|
+
## Error Handling
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { VybitAuthError, VybitAPIError, VybitValidationError } from '@vybit/oauth2-sdk';
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const token = await client.exchangeCodeForToken(code);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (error instanceof VybitAuthError) {
|
|
99
|
+
// Handle authentication errors
|
|
100
|
+
} else if (error instanceof VybitAPIError) {
|
|
101
|
+
// Handle API errors
|
|
102
|
+
} else if (error instanceof VybitValidationError) {
|
|
103
|
+
// Handle validation errors
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## TypeScript Support
|
|
109
|
+
|
|
110
|
+
Full TypeScript support with comprehensive type definitions:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface OAuth2Config {
|
|
114
|
+
clientId: string;
|
|
115
|
+
clientSecret: string;
|
|
116
|
+
redirectUri: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface TokenResponse {
|
|
120
|
+
access_token: string;
|
|
121
|
+
token_type: string;
|
|
122
|
+
expires_in?: number;
|
|
123
|
+
refresh_token?: string;
|
|
124
|
+
scope?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface TriggerOptions {
|
|
128
|
+
message?: string;
|
|
129
|
+
imageUrl?: string;
|
|
130
|
+
linkUrl?: string;
|
|
131
|
+
log?: string;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2-client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/oauth2-client.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OAuth2 Client Tests
|
|
4
|
+
*
|
|
5
|
+
* These tests mirror the exact functionality tested in the developer portal,
|
|
6
|
+
* covering all 6 steps of the OAuth flow.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const oauth2_client_1 = require("../oauth2-client");
|
|
10
|
+
const core_1 = require("@vybit/core");
|
|
11
|
+
// Mock fetch globally
|
|
12
|
+
const mockFetch = jest.fn();
|
|
13
|
+
global.fetch = mockFetch;
|
|
14
|
+
describe('VybitOAuth2Client', () => {
|
|
15
|
+
let client;
|
|
16
|
+
const validConfig = {
|
|
17
|
+
clientId: 'test-client-id',
|
|
18
|
+
clientSecret: 'test-client-secret',
|
|
19
|
+
redirectUri: 'https://example.com/callback'
|
|
20
|
+
};
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
client = new oauth2_client_1.VybitOAuth2Client(validConfig);
|
|
23
|
+
mockFetch.mockClear();
|
|
24
|
+
});
|
|
25
|
+
describe('Configuration Validation', () => {
|
|
26
|
+
it('should validate required configuration', () => {
|
|
27
|
+
expect(() => new oauth2_client_1.VybitOAuth2Client({
|
|
28
|
+
...validConfig,
|
|
29
|
+
clientId: ''
|
|
30
|
+
})).toThrow(core_1.VybitValidationError);
|
|
31
|
+
expect(() => new oauth2_client_1.VybitOAuth2Client({
|
|
32
|
+
...validConfig,
|
|
33
|
+
clientSecret: ''
|
|
34
|
+
})).toThrow(core_1.VybitValidationError);
|
|
35
|
+
expect(() => new oauth2_client_1.VybitOAuth2Client({
|
|
36
|
+
...validConfig,
|
|
37
|
+
redirectUri: ''
|
|
38
|
+
})).toThrow(core_1.VybitValidationError);
|
|
39
|
+
});
|
|
40
|
+
it('should validate redirect URI format', () => {
|
|
41
|
+
expect(() => new oauth2_client_1.VybitOAuth2Client({
|
|
42
|
+
...validConfig,
|
|
43
|
+
redirectUri: 'invalid-url'
|
|
44
|
+
})).toThrow(core_1.VybitValidationError);
|
|
45
|
+
});
|
|
46
|
+
it('should accept valid configuration', () => {
|
|
47
|
+
expect(() => new oauth2_client_1.VybitOAuth2Client(validConfig)).not.toThrow();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('Step 1: Authorization URL Generation', () => {
|
|
51
|
+
it('should generate correct authorization URL', () => {
|
|
52
|
+
const authUrl = client.getAuthorizationUrl();
|
|
53
|
+
expect(authUrl).toContain('https://app.vybit.net');
|
|
54
|
+
expect(authUrl).toContain('client_id=test-client-id');
|
|
55
|
+
expect(authUrl).toContain('redirect_uri=https%3A%2F%2Fexample.com%2Fcallback');
|
|
56
|
+
expect(authUrl).toContain('response_type=code');
|
|
57
|
+
expect(authUrl).toContain('state=');
|
|
58
|
+
});
|
|
59
|
+
it('should use custom state when provided', () => {
|
|
60
|
+
const customState = 'custom-state-123';
|
|
61
|
+
const authUrl = client.getAuthorizationUrl({ state: customState });
|
|
62
|
+
expect(authUrl).toContain(`state=${customState}`);
|
|
63
|
+
});
|
|
64
|
+
it('should include scope when provided', () => {
|
|
65
|
+
const authUrl = client.getAuthorizationUrl({ scope: 'read' });
|
|
66
|
+
expect(authUrl).toContain('scope=read');
|
|
67
|
+
});
|
|
68
|
+
it('should always use production domain', () => {
|
|
69
|
+
const authUrl = client.getAuthorizationUrl();
|
|
70
|
+
expect(authUrl).toContain('https://app.vybit.net');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('Step 3: Token Exchange', () => {
|
|
74
|
+
it('should successfully exchange code for token', async () => {
|
|
75
|
+
const mockTokenResponse = {
|
|
76
|
+
access_token: 'test-access-token',
|
|
77
|
+
token_type: 'Bearer'
|
|
78
|
+
};
|
|
79
|
+
mockFetch.mockResolvedValueOnce({
|
|
80
|
+
ok: true,
|
|
81
|
+
json: () => Promise.resolve(mockTokenResponse)
|
|
82
|
+
});
|
|
83
|
+
const result = await client.exchangeCodeForToken('test-auth-code');
|
|
84
|
+
expect(result).toEqual(mockTokenResponse);
|
|
85
|
+
expect(client.getAccessToken()).toBe('test-access-token');
|
|
86
|
+
// Verify correct API call
|
|
87
|
+
expect(mockFetch).toHaveBeenCalledWith('https://app.vybit.net/service/token', expect.objectContaining({
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
91
|
+
},
|
|
92
|
+
body: expect.any(URLSearchParams)
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
it('should handle token exchange errors', async () => {
|
|
96
|
+
mockFetch.mockResolvedValueOnce({
|
|
97
|
+
ok: false,
|
|
98
|
+
status: 400,
|
|
99
|
+
statusText: 'Bad Request'
|
|
100
|
+
});
|
|
101
|
+
await expect(client.exchangeCodeForToken('invalid-code')).rejects.toThrow(core_1.VybitAPIError);
|
|
102
|
+
});
|
|
103
|
+
it('should handle auth errors in response', async () => {
|
|
104
|
+
mockFetch.mockResolvedValueOnce({
|
|
105
|
+
ok: true,
|
|
106
|
+
json: () => Promise.resolve({ error: 'invalid_client' })
|
|
107
|
+
});
|
|
108
|
+
await expect(client.exchangeCodeForToken('test-code')).rejects.toThrow(core_1.VybitAuthError);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe('Step 4: Token Verification', () => {
|
|
112
|
+
beforeEach(() => {
|
|
113
|
+
client.setAccessToken('test-token');
|
|
114
|
+
});
|
|
115
|
+
it('should verify valid token', async () => {
|
|
116
|
+
mockFetch.mockResolvedValueOnce({
|
|
117
|
+
ok: true,
|
|
118
|
+
json: () => Promise.resolve({ status: 'ok' })
|
|
119
|
+
});
|
|
120
|
+
const isValid = await client.verifyToken();
|
|
121
|
+
expect(isValid).toBe(true);
|
|
122
|
+
expect(mockFetch).toHaveBeenCalledWith('https://vybit.net/service/test', {
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: 'Bearer test-token'
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
it('should handle invalid token', async () => {
|
|
129
|
+
mockFetch.mockResolvedValueOnce({
|
|
130
|
+
ok: false,
|
|
131
|
+
status: 401
|
|
132
|
+
});
|
|
133
|
+
const isValid = await client.verifyToken();
|
|
134
|
+
expect(isValid).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
it('should handle network errors gracefully', async () => {
|
|
137
|
+
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
|
138
|
+
const isValid = await client.verifyToken();
|
|
139
|
+
expect(isValid).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
it('should require access token', async () => {
|
|
142
|
+
const clientWithoutToken = new oauth2_client_1.VybitOAuth2Client(validConfig);
|
|
143
|
+
await expect(clientWithoutToken.verifyToken()).rejects.toThrow(core_1.VybitAuthError);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('Step 5: Get Vybit List', () => {
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
client.setAccessToken('test-token');
|
|
149
|
+
});
|
|
150
|
+
it('should fetch vybit list successfully', async () => {
|
|
151
|
+
const mockVybitResponse = {
|
|
152
|
+
'0': { name: 'My Alert', triggerKey: 'abc123def456' },
|
|
153
|
+
'1': { name: 'Notification Sound', triggerKey: 'def456ghi789' },
|
|
154
|
+
'2': { name: 'Status Update', triggerKey: 'ghi789jkl012' }
|
|
155
|
+
};
|
|
156
|
+
mockFetch.mockResolvedValueOnce({
|
|
157
|
+
ok: true,
|
|
158
|
+
json: () => Promise.resolve(mockVybitResponse)
|
|
159
|
+
});
|
|
160
|
+
const vybits = await client.getVybitList();
|
|
161
|
+
expect(vybits).toHaveLength(3);
|
|
162
|
+
expect(vybits[0]).toEqual({ name: 'My Alert', triggerKey: 'abc123def456' });
|
|
163
|
+
expect(vybits[1]).toEqual({ name: 'Notification Sound', triggerKey: 'def456ghi789' });
|
|
164
|
+
expect(vybits[2]).toEqual({ name: 'Status Update', triggerKey: 'ghi789jkl012' });
|
|
165
|
+
expect(mockFetch).toHaveBeenCalledWith('https://vybit.net/rest/vybit_list', {
|
|
166
|
+
headers: {
|
|
167
|
+
Authorization: 'Bearer test-token'
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
it('should handle API errors', async () => {
|
|
172
|
+
mockFetch.mockResolvedValueOnce({
|
|
173
|
+
ok: false,
|
|
174
|
+
status: 403,
|
|
175
|
+
statusText: 'Forbidden'
|
|
176
|
+
});
|
|
177
|
+
await expect(client.getVybitList()).rejects.toThrow(core_1.VybitAPIError);
|
|
178
|
+
});
|
|
179
|
+
it('should require access token', async () => {
|
|
180
|
+
const clientWithoutToken = new oauth2_client_1.VybitOAuth2Client(validConfig);
|
|
181
|
+
await expect(clientWithoutToken.getVybitList()).rejects.toThrow(core_1.VybitAuthError);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('Step 6: Send Vybit Notification', () => {
|
|
185
|
+
beforeEach(() => {
|
|
186
|
+
client.setAccessToken('test-token');
|
|
187
|
+
});
|
|
188
|
+
it('should send notification with all optional parameters', async () => {
|
|
189
|
+
const mockResponse = {
|
|
190
|
+
result: 1,
|
|
191
|
+
plk: 'bbxope6xhryminef'
|
|
192
|
+
};
|
|
193
|
+
mockFetch.mockResolvedValueOnce({
|
|
194
|
+
ok: true,
|
|
195
|
+
json: () => Promise.resolve(mockResponse)
|
|
196
|
+
});
|
|
197
|
+
const triggerOptions = {
|
|
198
|
+
message: 'Test notification',
|
|
199
|
+
imageUrl: 'https://example.com/image.jpg',
|
|
200
|
+
linkUrl: 'https://example.com/redirect',
|
|
201
|
+
log: 'Test log entry <a href="https://example.com">link</a>'
|
|
202
|
+
};
|
|
203
|
+
const result = await client.sendVybitNotification('test-trigger-key', triggerOptions);
|
|
204
|
+
expect(result).toEqual(mockResponse);
|
|
205
|
+
// Verify the API call
|
|
206
|
+
const [url, options] = mockFetch.mock.calls[0];
|
|
207
|
+
expect(url).toBe('https://vybit.net/fire/test-trigger-key');
|
|
208
|
+
expect(options.method).toBe('POST');
|
|
209
|
+
expect(options.headers['Authorization']).toBe('Bearer test-token');
|
|
210
|
+
expect(options.headers['Content-Type']).toBe('application/json');
|
|
211
|
+
const body = JSON.parse(options.body);
|
|
212
|
+
expect(body).toEqual(triggerOptions);
|
|
213
|
+
});
|
|
214
|
+
it('should send notification with minimal parameters', async () => {
|
|
215
|
+
const mockResponse = { result: 1, plk: 'test-plk' };
|
|
216
|
+
mockFetch.mockResolvedValueOnce({
|
|
217
|
+
ok: true,
|
|
218
|
+
json: () => Promise.resolve(mockResponse)
|
|
219
|
+
});
|
|
220
|
+
const result = await client.sendVybitNotification('test-trigger-key');
|
|
221
|
+
expect(result).toEqual(mockResponse);
|
|
222
|
+
const body = JSON.parse(mockFetch.mock.calls[0][1].body);
|
|
223
|
+
expect(body).toEqual({});
|
|
224
|
+
});
|
|
225
|
+
it('should validate URL parameters', async () => {
|
|
226
|
+
await expect(client.sendVybitNotification('test-key', {
|
|
227
|
+
imageUrl: 'invalid-url'
|
|
228
|
+
})).rejects.toThrow(core_1.VybitValidationError);
|
|
229
|
+
await expect(client.sendVybitNotification('test-key', {
|
|
230
|
+
linkUrl: 'also-invalid'
|
|
231
|
+
})).rejects.toThrow(core_1.VybitValidationError);
|
|
232
|
+
});
|
|
233
|
+
it('should handle API errors', async () => {
|
|
234
|
+
mockFetch.mockResolvedValueOnce({
|
|
235
|
+
ok: false,
|
|
236
|
+
status: 404,
|
|
237
|
+
statusText: 'Not Found'
|
|
238
|
+
});
|
|
239
|
+
await expect(client.sendVybitNotification('invalid-key')).rejects.toThrow(core_1.VybitAPIError);
|
|
240
|
+
});
|
|
241
|
+
it('should require access token', async () => {
|
|
242
|
+
const clientWithoutToken = new oauth2_client_1.VybitOAuth2Client(validConfig);
|
|
243
|
+
await expect(clientWithoutToken.sendVybitNotification('test-key')).rejects.toThrow(core_1.VybitAuthError);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
describe('Token Management', () => {
|
|
247
|
+
it('should set and get access token', () => {
|
|
248
|
+
expect(client.getAccessToken()).toBeUndefined();
|
|
249
|
+
client.setAccessToken('new-token');
|
|
250
|
+
expect(client.getAccessToken()).toBe('new-token');
|
|
251
|
+
});
|
|
252
|
+
it('should allow overriding token in API calls', async () => {
|
|
253
|
+
client.setAccessToken('default-token');
|
|
254
|
+
mockFetch.mockResolvedValueOnce({
|
|
255
|
+
ok: true,
|
|
256
|
+
json: () => Promise.resolve({ status: 'ok' })
|
|
257
|
+
});
|
|
258
|
+
await client.verifyToken('override-token');
|
|
259
|
+
expect(mockFetch).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
|
|
260
|
+
headers: expect.objectContaining({
|
|
261
|
+
Authorization: 'Bearer override-token'
|
|
262
|
+
})
|
|
263
|
+
}));
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
//# sourceMappingURL=oauth2-client.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2-client.test.js","sourceRoot":"","sources":["../../src/__tests__/oauth2-client.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,oDAAqD;AACrD,sCAAkF;AAElF,sBAAsB;AACtB,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAC5B,MAAM,CAAC,KAAK,GAAG,SAAgB,CAAC;AAEhC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,MAAyB,CAAC;IAE9B,MAAM,WAAW,GAAG;QAClB,QAAQ,EAAE,gBAAg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C,gBAAgB,CAAC,CAAC;YAE3C,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CACpC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAClB,MAAM,CAAC,gBAAgB,CAAC;gBACtB,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC;oBAC/B,aAAa,EAAE,uBAAuB;iBACvC,CAAC;aACH,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./oauth2-client"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,0CAAwB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Vybit } from '@vybit/core';
|
|
2
|
+
import { OAuth2Config, TokenResponse, AuthorizationUrlOptions, TriggerOptions, TriggerResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* OAuth2 client for Vybit authentication and API access
|
|
5
|
+
*
|
|
6
|
+
* This client handles the complete OAuth2 flow for Vybit authentication,
|
|
7
|
+
* including authorization URL generation, token exchange, and authenticated API calls.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const client = new VybitOAuth2Client({
|
|
12
|
+
* clientId: 'your-client-id',
|
|
13
|
+
* clientSecret: 'your-client-secret',
|
|
14
|
+
* redirectUri: 'https://yourapp.com/oauth/callback'
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Generate authorization URL
|
|
18
|
+
* const authUrl = client.getAuthorizationUrl();
|
|
19
|
+
*
|
|
20
|
+
* // Exchange authorization code for token
|
|
21
|
+
* const token = await client.exchangeCodeForToken(authCode);
|
|
22
|
+
*
|
|
23
|
+
* // Make authenticated API calls
|
|
24
|
+
* const vybits = await client.getVybitList();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class VybitOAuth2Client {
|
|
28
|
+
private config;
|
|
29
|
+
private accessToken?;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new Vybit OAuth2 client
|
|
32
|
+
* @param config - OAuth2 configuration including client credentials and redirect URI
|
|
33
|
+
* @throws {VybitValidationError} When configuration is invalid
|
|
34
|
+
*/
|
|
35
|
+
constructor(config: OAuth2Config);
|
|
36
|
+
private validateConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Generates an OAuth2 authorization URL for user authentication
|
|
39
|
+
*
|
|
40
|
+
* Direct users to this URL to begin the OAuth2 authorization flow.
|
|
41
|
+
* After authorization, users will be redirected to your configured redirect URI
|
|
42
|
+
* with an authorization code.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Optional parameters for the authorization URL
|
|
45
|
+
* @returns Complete authorization URL for user redirection
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const authUrl = client.getAuthorizationUrl({
|
|
50
|
+
* state: 'unique-state-value',
|
|
51
|
+
* scope: 'read write'
|
|
52
|
+
* });
|
|
53
|
+
* // Redirect user to authUrl
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getAuthorizationUrl(options?: AuthorizationUrlOptions): string;
|
|
57
|
+
/**
|
|
58
|
+
* Exchanges an authorization code for an access token
|
|
59
|
+
*
|
|
60
|
+
* Call this method with the authorization code received from the redirect URI
|
|
61
|
+
* after successful user authorization. The returned access token can be used
|
|
62
|
+
* for authenticated API calls.
|
|
63
|
+
*
|
|
64
|
+
* @param code - Authorization code from the OAuth2 callback
|
|
65
|
+
* @returns Promise resolving to token response with access token
|
|
66
|
+
* @throws {VybitAPIError} When token exchange fails
|
|
67
|
+
* @throws {VybitAuthError} When authorization is denied
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Handle OAuth2 callback
|
|
72
|
+
* const urlParams = new URLSearchParams(window.location.search);
|
|
73
|
+
* const code = urlParams.get('code');
|
|
74
|
+
*
|
|
75
|
+
* if (code) {
|
|
76
|
+
* const token = await client.exchangeCodeForToken(code);
|
|
77
|
+
* console.log('Access token:', token.access_token);
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
exchangeCodeForToken(code: string): Promise<TokenResponse>;
|
|
82
|
+
verifyToken(accessToken?: string): Promise<boolean>;
|
|
83
|
+
getVybitList(accessToken?: string): Promise<Vybit[]>;
|
|
84
|
+
sendVybitNotification(triggerKey: string, options?: TriggerOptions, accessToken?: string): Promise<TriggerResponse>;
|
|
85
|
+
setAccessToken(token: string): void;
|
|
86
|
+
getAccessToken(): string | undefined;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=oauth2-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2-client.d.ts","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,EACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B;;;;OAIG;gBACS,MAAM,EAAE,YAAY;IAKhC,OAAO,CAAC,cAAc;IAetB;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM;IAkBlE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA2C1D,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BnD,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAmCpD,qBAAqB,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,cAAmB,EAC5B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IAkD3B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC,cAAc,IAAI,MAAM,GAAG,SAAS;CAGrC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VybitOAuth2Client = void 0;
|
|
4
|
+
const core_1 = require("@vybit/core");
|
|
5
|
+
/**
|
|
6
|
+
* OAuth2 client for Vybit authentication and API access
|
|
7
|
+
*
|
|
8
|
+
* This client handles the complete OAuth2 flow for Vybit authentication,
|
|
9
|
+
* including authorization URL generation, token exchange, and authenticated API calls.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new VybitOAuth2Client({
|
|
14
|
+
* clientId: 'your-client-id',
|
|
15
|
+
* clientSecret: 'your-client-secret',
|
|
16
|
+
* redirectUri: 'https://yourapp.com/oauth/callback'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Generate authorization URL
|
|
20
|
+
* const authUrl = client.getAuthorizationUrl();
|
|
21
|
+
*
|
|
22
|
+
* // Exchange authorization code for token
|
|
23
|
+
* const token = await client.exchangeCodeForToken(authCode);
|
|
24
|
+
*
|
|
25
|
+
* // Make authenticated API calls
|
|
26
|
+
* const vybits = await client.getVybitList();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class VybitOAuth2Client {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new Vybit OAuth2 client
|
|
32
|
+
* @param config - OAuth2 configuration including client credentials and redirect URI
|
|
33
|
+
* @throws {VybitValidationError} When configuration is invalid
|
|
34
|
+
*/
|
|
35
|
+
constructor(config) {
|
|
36
|
+
this.validateConfig(config);
|
|
37
|
+
this.config = config;
|
|
38
|
+
}
|
|
39
|
+
validateConfig(config) {
|
|
40
|
+
if (!config.clientId) {
|
|
41
|
+
throw new core_1.VybitValidationError('Client ID is required');
|
|
42
|
+
}
|
|
43
|
+
if (!config.clientSecret) {
|
|
44
|
+
throw new core_1.VybitValidationError('Client Secret is required');
|
|
45
|
+
}
|
|
46
|
+
if (!config.redirectUri) {
|
|
47
|
+
throw new core_1.VybitValidationError('Redirect URI is required');
|
|
48
|
+
}
|
|
49
|
+
if (!(0, core_1.isValidUrl)(config.redirectUri)) {
|
|
50
|
+
throw new core_1.VybitValidationError('Redirect URI must be a valid URL');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Generates an OAuth2 authorization URL for user authentication
|
|
55
|
+
*
|
|
56
|
+
* Direct users to this URL to begin the OAuth2 authorization flow.
|
|
57
|
+
* After authorization, users will be redirected to your configured redirect URI
|
|
58
|
+
* with an authorization code.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Optional parameters for the authorization URL
|
|
61
|
+
* @returns Complete authorization URL for user redirection
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const authUrl = client.getAuthorizationUrl({
|
|
66
|
+
* state: 'unique-state-value',
|
|
67
|
+
* scope: 'read write'
|
|
68
|
+
* });
|
|
69
|
+
* // Redirect user to authUrl
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
getAuthorizationUrl(options = {}) {
|
|
73
|
+
const state = options.state || (0, core_1.generateRandomState)();
|
|
74
|
+
const authDomain = (0, core_1.getAuthDomain)();
|
|
75
|
+
const params = new URLSearchParams({
|
|
76
|
+
client_id: this.config.clientId,
|
|
77
|
+
redirect_uri: this.config.redirectUri,
|
|
78
|
+
response_type: 'code',
|
|
79
|
+
state,
|
|
80
|
+
});
|
|
81
|
+
if (options.scope) {
|
|
82
|
+
params.append('scope', options.scope);
|
|
83
|
+
}
|
|
84
|
+
return `${authDomain}?${params.toString()}`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Exchanges an authorization code for an access token
|
|
88
|
+
*
|
|
89
|
+
* Call this method with the authorization code received from the redirect URI
|
|
90
|
+
* after successful user authorization. The returned access token can be used
|
|
91
|
+
* for authenticated API calls.
|
|
92
|
+
*
|
|
93
|
+
* @param code - Authorization code from the OAuth2 callback
|
|
94
|
+
* @returns Promise resolving to token response with access token
|
|
95
|
+
* @throws {VybitAPIError} When token exchange fails
|
|
96
|
+
* @throws {VybitAuthError} When authorization is denied
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Handle OAuth2 callback
|
|
101
|
+
* const urlParams = new URLSearchParams(window.location.search);
|
|
102
|
+
* const code = urlParams.get('code');
|
|
103
|
+
*
|
|
104
|
+
* if (code) {
|
|
105
|
+
* const token = await client.exchangeCodeForToken(code);
|
|
106
|
+
* console.log('Access token:', token.access_token);
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
async exchangeCodeForToken(code) {
|
|
111
|
+
const authDomain = (0, core_1.getAuthDomain)();
|
|
112
|
+
const tokenUrl = `${authDomain}/service/token`;
|
|
113
|
+
const formData = new URLSearchParams({
|
|
114
|
+
grant_type: 'authorization_code',
|
|
115
|
+
code,
|
|
116
|
+
client_id: this.config.clientId,
|
|
117
|
+
client_secret: this.config.clientSecret,
|
|
118
|
+
});
|
|
119
|
+
try {
|
|
120
|
+
const response = await fetch(tokenUrl, {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: {
|
|
123
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
124
|
+
},
|
|
125
|
+
body: formData,
|
|
126
|
+
});
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
throw new core_1.VybitAPIError(`Token exchange failed: ${response.statusText}`, response.status);
|
|
129
|
+
}
|
|
130
|
+
const data = await response.json();
|
|
131
|
+
if (data.error) {
|
|
132
|
+
throw new core_1.VybitAuthError(`Token exchange error: ${data.error}`);
|
|
133
|
+
}
|
|
134
|
+
this.accessToken = data.access_token;
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof core_1.VybitAPIError || error instanceof core_1.VybitAuthError) {
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
throw new core_1.VybitAPIError(`Network error during token exchange: ${error}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async verifyToken(accessToken) {
|
|
145
|
+
const token = accessToken || this.accessToken;
|
|
146
|
+
if (!token) {
|
|
147
|
+
throw new core_1.VybitAuthError('No access token available');
|
|
148
|
+
}
|
|
149
|
+
const baseUrl = (0, core_1.getDefaultBaseUrl)();
|
|
150
|
+
const verifyUrl = `${baseUrl}/service/test`;
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetch(verifyUrl, {
|
|
153
|
+
headers: {
|
|
154
|
+
Authorization: `Bearer ${token}`,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const data = await response.json();
|
|
161
|
+
return data.status === 'ok';
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async getVybitList(accessToken) {
|
|
168
|
+
const token = accessToken || this.accessToken;
|
|
169
|
+
if (!token) {
|
|
170
|
+
throw new core_1.VybitAuthError('No access token available');
|
|
171
|
+
}
|
|
172
|
+
const baseUrl = (0, core_1.getDefaultBaseUrl)();
|
|
173
|
+
const listUrl = `${baseUrl}/rest/vybit_list`;
|
|
174
|
+
try {
|
|
175
|
+
const response = await fetch(listUrl, {
|
|
176
|
+
headers: {
|
|
177
|
+
Authorization: `Bearer ${token}`,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
if (!response.ok) {
|
|
181
|
+
throw new core_1.VybitAPIError(`Failed to fetch vybit list: ${response.statusText}`, response.status);
|
|
182
|
+
}
|
|
183
|
+
const data = await response.json();
|
|
184
|
+
// Convert object with numeric keys to array
|
|
185
|
+
return Object.values(data);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
if (error instanceof core_1.VybitAPIError) {
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
throw new core_1.VybitAPIError(`Network error fetching vybit list: ${error}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async sendVybitNotification(triggerKey, options = {}, accessToken) {
|
|
195
|
+
const token = accessToken || this.accessToken;
|
|
196
|
+
if (!token) {
|
|
197
|
+
throw new core_1.VybitAuthError('No access token available');
|
|
198
|
+
}
|
|
199
|
+
// Validate URL parameters
|
|
200
|
+
if (options.imageUrl && !(0, core_1.isValidUrl)(options.imageUrl)) {
|
|
201
|
+
throw new core_1.VybitValidationError('Image URL must be a valid URL');
|
|
202
|
+
}
|
|
203
|
+
if (options.linkUrl && !(0, core_1.isValidUrl)(options.linkUrl)) {
|
|
204
|
+
throw new core_1.VybitValidationError('Link URL must be a valid URL');
|
|
205
|
+
}
|
|
206
|
+
const baseUrl = (0, core_1.getDefaultBaseUrl)();
|
|
207
|
+
const triggerUrl = `${baseUrl}/fire/${triggerKey}`;
|
|
208
|
+
// Build payload
|
|
209
|
+
const payload = {};
|
|
210
|
+
if (options.message)
|
|
211
|
+
payload.message = options.message;
|
|
212
|
+
if (options.imageUrl)
|
|
213
|
+
payload.imageUrl = options.imageUrl;
|
|
214
|
+
if (options.linkUrl)
|
|
215
|
+
payload.linkUrl = options.linkUrl;
|
|
216
|
+
if (options.log)
|
|
217
|
+
payload.log = options.log;
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch(triggerUrl, {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
headers: {
|
|
222
|
+
Authorization: `Bearer ${token}`,
|
|
223
|
+
'Content-Type': 'application/json',
|
|
224
|
+
},
|
|
225
|
+
body: JSON.stringify(payload),
|
|
226
|
+
});
|
|
227
|
+
if (!response.ok) {
|
|
228
|
+
throw new core_1.VybitAPIError(`Failed to send vybit notification: ${response.statusText}`, response.status);
|
|
229
|
+
}
|
|
230
|
+
return await response.json();
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
if (error instanceof core_1.VybitAPIError) {
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
throw new core_1.VybitAPIError(`Network error sending notification: ${error}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
setAccessToken(token) {
|
|
240
|
+
this.accessToken = token;
|
|
241
|
+
}
|
|
242
|
+
getAccessToken() {
|
|
243
|
+
return this.accessToken;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.VybitOAuth2Client = VybitOAuth2Client;
|
|
247
|
+
//# sourceMappingURL=oauth2-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":";;;AAAA,sCASqB;AASrB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,iBAAiB;IAI5B;;;;OAIG;IACH,YAAY,MAAoB;QAC9B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEO,cAAc,CAAC,MAAoB;QACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,2BAAoB,CAAC,uBAAuB,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,MAAM,IAAI,2BAAoB,CAAC,2BAA2B,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,2BAAoB,CAAC,0BAA0B,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,IAAA,iBAAU,EAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,2BAAoB,CAAC,kCAAkC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,UAAmC,EAAE;QACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAA,0BAAmB,GAA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AAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,oBAAa,EAAE,CAAC;gBACnC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,oBAAa,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,cAAc,CAAC,KAAa;QAC1B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAhQD,8CAgQC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth2 configuration for Vybit authentication
|
|
3
|
+
*/
|
|
4
|
+
export interface OAuth2Config {
|
|
5
|
+
/** OAuth2 client ID from your Vybit developer account */
|
|
6
|
+
clientId: string;
|
|
7
|
+
/** OAuth2 client secret from your Vybit developer account */
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
/** Redirect URI that matches your Vybit app configuration */
|
|
10
|
+
redirectUri: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* OAuth2 token response from successful authentication
|
|
14
|
+
*/
|
|
15
|
+
export interface TokenResponse {
|
|
16
|
+
/** Access token for authenticated API calls */
|
|
17
|
+
access_token: string;
|
|
18
|
+
/** Token type (typically "Bearer") */
|
|
19
|
+
token_type: string;
|
|
20
|
+
/** Token expiration time in seconds (optional) */
|
|
21
|
+
expires_in?: number;
|
|
22
|
+
/** Refresh token for token renewal (optional) */
|
|
23
|
+
refresh_token?: string;
|
|
24
|
+
/** Granted scopes for this token (optional) */
|
|
25
|
+
scope?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for generating OAuth2 authorization URLs
|
|
29
|
+
*/
|
|
30
|
+
export interface AuthorizationUrlOptions {
|
|
31
|
+
/** Custom state parameter for security (auto-generated if not provided) */
|
|
32
|
+
state?: string;
|
|
33
|
+
/** Requested OAuth2 scopes (space-separated) */
|
|
34
|
+
scope?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for triggering vybit notifications
|
|
38
|
+
*/
|
|
39
|
+
export interface TriggerOptions {
|
|
40
|
+
/** Custom message text for the notification */
|
|
41
|
+
message?: string;
|
|
42
|
+
/** URL to an image to display with the notification */
|
|
43
|
+
imageUrl?: string;
|
|
44
|
+
/** URL to open when the notification is clicked */
|
|
45
|
+
linkUrl?: string;
|
|
46
|
+
/** Custom log message for debugging */
|
|
47
|
+
log?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Response from triggering a vybit notification
|
|
51
|
+
*/
|
|
52
|
+
export interface TriggerResponse {
|
|
53
|
+
/** Result code (0 = success) */
|
|
54
|
+
result: number;
|
|
55
|
+
/** Processing key for tracking the notification */
|
|
56
|
+
plk: string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;CACb"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vybit/oauth2-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OAuth 2.0 SDK for Vybit authentication and authorization",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"test": "jest --config ../../jest.config.js --rootDir ../.."
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vybit",
|
|
15
|
+
"oauth2",
|
|
16
|
+
"authentication",
|
|
17
|
+
"sdk"
|
|
18
|
+
],
|
|
19
|
+
"author": "Vybit Team",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/vybit/vybit-sdk.git",
|
|
24
|
+
"directory": "packages/oauth2"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/vybit/vybit-sdk#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/vybit/vybit-sdk/issues"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=16.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@vybit/core": "^1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"node-fetch": "^3.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"node-fetch": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|