@vybit/oauth2-sdk 1.0.4 → 1.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/README.md +20 -28
- package/dist/oauth2-client.d.ts +37 -23
- package/dist/oauth2-client.d.ts.map +1 -1
- package/dist/oauth2-client.js +36 -91
- package/dist/oauth2-client.js.map +1 -1
- package/dist/types.d.ts +3 -55
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@ OAuth 2.0 authentication SDK for Vybit.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The OAuth2 SDK handles the authorization flow for user-facing applications. It provides authorization URL generation, token exchange, and token verification.
|
|
8
|
+
|
|
9
|
+
Once you have an access token, use `VybitAPIClient` from `@vybit/api-sdk` with `{ accessToken }` to make API calls on behalf of the user.
|
|
8
10
|
|
|
9
11
|
## Setup
|
|
10
12
|
|
|
@@ -15,23 +17,24 @@ Complete OAuth2 implementation for Vybit authentication, including authorization
|
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
|
-
npm install @vybit/oauth2-sdk
|
|
20
|
+
npm install @vybit/oauth2-sdk @vybit/api-sdk
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
## Quick Start
|
|
22
24
|
|
|
23
25
|
```typescript
|
|
24
26
|
import { VybitOAuth2Client } from '@vybit/oauth2-sdk';
|
|
27
|
+
import { VybitAPIClient } from '@vybit/api-sdk';
|
|
25
28
|
|
|
26
29
|
// Create client with your OAuth2 credentials
|
|
27
|
-
const
|
|
30
|
+
const oauthClient = new VybitOAuth2Client({
|
|
28
31
|
clientId: 'your-client-id',
|
|
29
32
|
clientSecret: 'your-client-secret',
|
|
30
33
|
redirectUri: 'https://yourapp.com/oauth/callback'
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
// Step 1: Generate authorization URL
|
|
34
|
-
const authUrl =
|
|
37
|
+
const authUrl = oauthClient.getAuthorizationUrl({
|
|
35
38
|
state: 'unique-state-value',
|
|
36
39
|
scope: 'read write'
|
|
37
40
|
});
|
|
@@ -39,20 +42,24 @@ const authUrl = client.getAuthorizationUrl({
|
|
|
39
42
|
// Redirect user to authUrl...
|
|
40
43
|
|
|
41
44
|
// Step 2: Exchange authorization code for token
|
|
42
|
-
const token = await
|
|
45
|
+
const token = await oauthClient.exchangeCodeForToken('auth-code-from-callback');
|
|
46
|
+
|
|
47
|
+
// Step 3: Use the token with the API SDK
|
|
48
|
+
const apiClient = new VybitAPIClient({
|
|
49
|
+
accessToken: token.access_token
|
|
50
|
+
});
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await client.sendVybitNotification('trigger-key', {
|
|
52
|
+
const vybits = await apiClient.listVybits();
|
|
53
|
+
await apiClient.triggerVybit('vybit-key', {
|
|
47
54
|
message: 'Hello from your app!'
|
|
48
55
|
});
|
|
49
56
|
```
|
|
50
57
|
|
|
51
58
|
## Environment Management
|
|
52
59
|
|
|
53
|
-
The SDK
|
|
60
|
+
The SDK uses production Vybit endpoints:
|
|
54
61
|
- **Authentication**: `https://app.vybit.net`
|
|
55
|
-
- **API
|
|
62
|
+
- **API** (via `@vybit/api-sdk`): `https://api.vybit.net/v1`
|
|
56
63
|
|
|
57
64
|
For different environments (dev/staging/prod), create separate Vybit accounts with their own OAuth credentials.
|
|
58
65
|
|
|
@@ -73,20 +80,12 @@ new VybitOAuth2Client(config: OAuth2Config)
|
|
|
73
80
|
|
|
74
81
|
**`exchangeCodeForToken(code: string): Promise<TokenResponse>`**
|
|
75
82
|
- Exchanges authorization code for access token
|
|
76
|
-
- Automatically stores token for subsequent
|
|
83
|
+
- Automatically stores token for subsequent `verifyToken()` calls
|
|
77
84
|
|
|
78
85
|
**`verifyToken(accessToken?: string): Promise<boolean>`**
|
|
79
86
|
- Verifies if an access token is valid
|
|
80
87
|
- Uses stored token if none provided
|
|
81
88
|
|
|
82
|
-
**`getVybitList(accessToken?: string): Promise<Vybit[]>`**
|
|
83
|
-
- Fetches user's vybit notifications
|
|
84
|
-
- Requires valid access token
|
|
85
|
-
|
|
86
|
-
**`sendVybitNotification(triggerKey: string, options?: TriggerOptions, accessToken?: string): Promise<TriggerResponse>`**
|
|
87
|
-
- Triggers a vybit notification
|
|
88
|
-
- Supports custom message, images, and links
|
|
89
|
-
|
|
90
89
|
**`setAccessToken(token: string): void`**
|
|
91
90
|
- Manually set access token
|
|
92
91
|
|
|
@@ -99,7 +98,7 @@ new VybitOAuth2Client(config: OAuth2Config)
|
|
|
99
98
|
import { VybitAuthError, VybitAPIError, VybitValidationError } from '@vybit/oauth2-sdk';
|
|
100
99
|
|
|
101
100
|
try {
|
|
102
|
-
const token = await
|
|
101
|
+
const token = await oauthClient.exchangeCodeForToken(code);
|
|
103
102
|
} catch (error) {
|
|
104
103
|
if (error instanceof VybitAuthError) {
|
|
105
104
|
// Handle authentication errors
|
|
@@ -129,15 +128,8 @@ interface TokenResponse {
|
|
|
129
128
|
refresh_token?: string;
|
|
130
129
|
scope?: string;
|
|
131
130
|
}
|
|
132
|
-
|
|
133
|
-
interface TriggerOptions {
|
|
134
|
-
message?: string;
|
|
135
|
-
imageUrl?: string; // Must be a direct link to a JPG, PNG, or GIF image
|
|
136
|
-
linkUrl?: string;
|
|
137
|
-
log?: string;
|
|
138
|
-
}
|
|
139
131
|
```
|
|
140
132
|
|
|
141
133
|
## License
|
|
142
134
|
|
|
143
|
-
MIT
|
|
135
|
+
MIT
|
package/dist/oauth2-client.d.ts
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OAuth2Config, TokenResponse, AuthorizationUrlOptions, TriggerOptions, TriggerResponse } from './types';
|
|
1
|
+
import { OAuth2Config, TokenResponse, AuthorizationUrlOptions } from '@vybit/core';
|
|
3
2
|
/**
|
|
4
|
-
* OAuth2 client for Vybit authentication
|
|
3
|
+
* OAuth2 client for Vybit authentication
|
|
5
4
|
*
|
|
6
|
-
* This client handles the
|
|
7
|
-
*
|
|
5
|
+
* This client handles the OAuth2 authorization flow for Vybit, including
|
|
6
|
+
* authorization URL generation, token exchange, and token verification.
|
|
7
|
+
*
|
|
8
|
+
* Once you have obtained an access token, use {@link VybitAPIClient} from
|
|
9
|
+
* `@vybit/api-sdk` with the `accessToken` option for full Developer API access.
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
10
12
|
* ```typescript
|
|
11
|
-
*
|
|
13
|
+
* import { VybitOAuth2Client } from '@vybit/oauth2-sdk';
|
|
14
|
+
* import { VybitAPIClient } from '@vybit/api-sdk';
|
|
15
|
+
*
|
|
16
|
+
* // 1. Set up OAuth2 client
|
|
17
|
+
* const oauth = new VybitOAuth2Client({
|
|
12
18
|
* clientId: 'your-client-id',
|
|
13
19
|
* clientSecret: 'your-client-secret',
|
|
14
20
|
* redirectUri: 'https://yourapp.com/oauth/callback'
|
|
15
21
|
* });
|
|
16
22
|
*
|
|
17
|
-
* // Generate authorization URL
|
|
18
|
-
* const authUrl =
|
|
23
|
+
* // 2. Generate authorization URL and redirect user
|
|
24
|
+
* const authUrl = oauth.getAuthorizationUrl();
|
|
19
25
|
*
|
|
20
|
-
* // Exchange authorization code for token
|
|
21
|
-
* const token = await
|
|
26
|
+
* // 3. Exchange authorization code for token (in callback handler)
|
|
27
|
+
* const token = await oauth.exchangeCodeForToken(authCode);
|
|
22
28
|
*
|
|
23
|
-
* //
|
|
24
|
-
* const
|
|
29
|
+
* // 4. Use token with API client for full Developer API access
|
|
30
|
+
* const api = new VybitAPIClient({ accessToken: token.access_token });
|
|
31
|
+
* const vybits = await api.listVybits();
|
|
25
32
|
* ```
|
|
26
33
|
*/
|
|
27
34
|
export declare class VybitOAuth2Client {
|
|
@@ -59,7 +66,7 @@ export declare class VybitOAuth2Client {
|
|
|
59
66
|
*
|
|
60
67
|
* Call this method with the authorization code received from the redirect URI
|
|
61
68
|
* after successful user authorization. The returned access token can be used
|
|
62
|
-
* for
|
|
69
|
+
* with {@link VybitAPIClient} for full Developer API access.
|
|
63
70
|
*
|
|
64
71
|
* @param code - Authorization code from the OAuth2 callback
|
|
65
72
|
* @returns Promise resolving to token response with access token
|
|
@@ -68,21 +75,28 @@ export declare class VybitOAuth2Client {
|
|
|
68
75
|
*
|
|
69
76
|
* @example
|
|
70
77
|
* ```typescript
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* const
|
|
74
|
-
*
|
|
75
|
-
* if (code) {
|
|
76
|
-
* const token = await client.exchangeCodeForToken(code);
|
|
77
|
-
* console.log('Access token:', token.access_token);
|
|
78
|
-
* }
|
|
78
|
+
* const token = await client.exchangeCodeForToken(authCode);
|
|
79
|
+
* // Use token with API client
|
|
80
|
+
* const api = new VybitAPIClient({ accessToken: token.access_token });
|
|
79
81
|
* ```
|
|
80
82
|
*/
|
|
81
83
|
exchangeCodeForToken(code: string): Promise<TokenResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Verifies that an access token is valid
|
|
86
|
+
* @param accessToken - Token to verify (uses stored token if not provided)
|
|
87
|
+
* @returns True if the token is valid
|
|
88
|
+
* @throws {VybitAuthError} When no token is available
|
|
89
|
+
*/
|
|
82
90
|
verifyToken(accessToken?: string): Promise<boolean>;
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Manually sets the access token
|
|
93
|
+
* @param token - The access token to store
|
|
94
|
+
*/
|
|
85
95
|
setAccessToken(token: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the currently stored access token
|
|
98
|
+
* @returns The stored access token, or undefined if not set
|
|
99
|
+
*/
|
|
86
100
|
getAccessToken(): string | undefined;
|
|
87
101
|
}
|
|
88
102
|
//# sourceMappingURL=oauth2-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-client.d.ts","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,
|
|
1
|
+
{"version":3,"file":"oauth2-client.d.ts","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,YAAY,EACZ,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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;;;;;;;;;;;;;;;;;;OAkBG;IACG,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA2ChE;;;;;OAKG;IACG,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BzD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,SAAS;CAGrC"}
|
package/dist/oauth2-client.js
CHANGED
|
@@ -3,27 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VybitOAuth2Client = void 0;
|
|
4
4
|
const core_1 = require("@vybit/core");
|
|
5
5
|
/**
|
|
6
|
-
* OAuth2 client for Vybit authentication
|
|
6
|
+
* OAuth2 client for Vybit authentication
|
|
7
7
|
*
|
|
8
|
-
* This client handles the
|
|
9
|
-
*
|
|
8
|
+
* This client handles the OAuth2 authorization flow for Vybit, including
|
|
9
|
+
* authorization URL generation, token exchange, and token verification.
|
|
10
|
+
*
|
|
11
|
+
* Once you have obtained an access token, use {@link VybitAPIClient} from
|
|
12
|
+
* `@vybit/api-sdk` with the `accessToken` option for full Developer API access.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```typescript
|
|
13
|
-
*
|
|
16
|
+
* import { VybitOAuth2Client } from '@vybit/oauth2-sdk';
|
|
17
|
+
* import { VybitAPIClient } from '@vybit/api-sdk';
|
|
18
|
+
*
|
|
19
|
+
* // 1. Set up OAuth2 client
|
|
20
|
+
* const oauth = new VybitOAuth2Client({
|
|
14
21
|
* clientId: 'your-client-id',
|
|
15
22
|
* clientSecret: 'your-client-secret',
|
|
16
23
|
* redirectUri: 'https://yourapp.com/oauth/callback'
|
|
17
24
|
* });
|
|
18
25
|
*
|
|
19
|
-
* // Generate authorization URL
|
|
20
|
-
* const authUrl =
|
|
26
|
+
* // 2. Generate authorization URL and redirect user
|
|
27
|
+
* const authUrl = oauth.getAuthorizationUrl();
|
|
21
28
|
*
|
|
22
|
-
* // Exchange authorization code for token
|
|
23
|
-
* const token = await
|
|
29
|
+
* // 3. Exchange authorization code for token (in callback handler)
|
|
30
|
+
* const token = await oauth.exchangeCodeForToken(authCode);
|
|
24
31
|
*
|
|
25
|
-
* //
|
|
26
|
-
* const
|
|
32
|
+
* // 4. Use token with API client for full Developer API access
|
|
33
|
+
* const api = new VybitAPIClient({ accessToken: token.access_token });
|
|
34
|
+
* const vybits = await api.listVybits();
|
|
27
35
|
* ```
|
|
28
36
|
*/
|
|
29
37
|
class VybitOAuth2Client {
|
|
@@ -88,7 +96,7 @@ class VybitOAuth2Client {
|
|
|
88
96
|
*
|
|
89
97
|
* Call this method with the authorization code received from the redirect URI
|
|
90
98
|
* after successful user authorization. The returned access token can be used
|
|
91
|
-
* for
|
|
99
|
+
* with {@link VybitAPIClient} for full Developer API access.
|
|
92
100
|
*
|
|
93
101
|
* @param code - Authorization code from the OAuth2 callback
|
|
94
102
|
* @returns Promise resolving to token response with access token
|
|
@@ -97,14 +105,9 @@ class VybitOAuth2Client {
|
|
|
97
105
|
*
|
|
98
106
|
* @example
|
|
99
107
|
* ```typescript
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* const
|
|
103
|
-
*
|
|
104
|
-
* if (code) {
|
|
105
|
-
* const token = await client.exchangeCodeForToken(code);
|
|
106
|
-
* console.log('Access token:', token.access_token);
|
|
107
|
-
* }
|
|
108
|
+
* const token = await client.exchangeCodeForToken(authCode);
|
|
109
|
+
* // Use token with API client
|
|
110
|
+
* const api = new VybitAPIClient({ accessToken: token.access_token });
|
|
108
111
|
* ```
|
|
109
112
|
*/
|
|
110
113
|
async exchangeCodeForToken(code) {
|
|
@@ -141,6 +144,12 @@ class VybitOAuth2Client {
|
|
|
141
144
|
throw new core_1.VybitAPIError(`Network error during token exchange: ${error}`);
|
|
142
145
|
}
|
|
143
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Verifies that an access token is valid
|
|
149
|
+
* @param accessToken - Token to verify (uses stored token if not provided)
|
|
150
|
+
* @returns True if the token is valid
|
|
151
|
+
* @throws {VybitAuthError} When no token is available
|
|
152
|
+
*/
|
|
144
153
|
async verifyToken(accessToken) {
|
|
145
154
|
const token = accessToken || this.accessToken;
|
|
146
155
|
if (!token) {
|
|
@@ -164,81 +173,17 @@ class VybitOAuth2Client {
|
|
|
164
173
|
return false;
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
}
|
|
176
|
+
/**
|
|
177
|
+
* Manually sets the access token
|
|
178
|
+
* @param token - The access token to store
|
|
179
|
+
*/
|
|
239
180
|
setAccessToken(token) {
|
|
240
181
|
this.accessToken = token;
|
|
241
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Gets the currently stored access token
|
|
185
|
+
* @returns The stored access token, or undefined if not set
|
|
186
|
+
*/
|
|
242
187
|
getAccessToken() {
|
|
243
188
|
return this.accessToken;
|
|
244
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"oauth2-client.js","sourceRoot":"","sources":["../src/oauth2-client.ts"],"names":[],"mappings":";;;AAAA,sCAWqB;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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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,EAAE,UAAU,KAAK,EAAE;iBACjC;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,KAAa;QAC1B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAhLD,8CAgLC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,58 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Re-export all types from @vybit/core for backward compatibility.
|
|
3
|
+
* Types are maintained in the core package as the single source of truth.
|
|
3
4
|
*/
|
|
4
|
-
export
|
|
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 (must be a direct link to a JPG, PNG, or GIF image) */
|
|
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 (1 = success) */
|
|
54
|
-
result: number;
|
|
55
|
-
/** Processing key for tracking the notification */
|
|
56
|
-
plk: string;
|
|
57
|
-
}
|
|
5
|
+
export * from '@vybit/core';
|
|
58
6
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,aAAa,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
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
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Re-export all types from @vybit/core for backward compatibility.
|
|
19
|
+
* Types are maintained in the core package as the single source of truth.
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("@vybit/core"), exports);
|
|
3
22
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,8CAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vybit/oauth2-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "OAuth 2.0 SDK for Vybit authentication and authorization",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=16.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@vybit/core": "^1.
|
|
42
|
+
"@vybit/core": "^1.2.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"node-fetch": "^3.0.0"
|