@manaobot/kick 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/auth/OAuth.ts +8 -2
- package/src/auth/TokenManager.ts +1 -6
- package/types/api.d.ts +18 -0
- package/types/auth.d.ts +4 -2
package/package.json
CHANGED
package/src/auth/OAuth.ts
CHANGED
|
@@ -26,7 +26,10 @@ export async function exchangeCode(
|
|
|
26
26
|
throw new Error(`Code exchange failed (${res.status})`);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const data = (await res.json()) as KickTokenResponse;
|
|
30
|
+
data.expires_at = Date.now() + data.expires_in * 1000;
|
|
31
|
+
|
|
32
|
+
return data;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export async function refreshToken(
|
|
@@ -51,5 +54,8 @@ export async function refreshToken(
|
|
|
51
54
|
throw new Error(`Token refresh failed (${res.status})`);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
const data = (await res.json()) as KickTokenResponse;
|
|
58
|
+
data.expires_at = Date.now() + data.expires_in * 1000;
|
|
59
|
+
|
|
60
|
+
return data;
|
|
55
61
|
}
|
package/src/auth/TokenManager.ts
CHANGED
|
@@ -21,12 +21,7 @@ export class TokenManager {
|
|
|
21
21
|
setTokens(token: KickTokenResponse) {
|
|
22
22
|
this.accessToken = token.access_token;
|
|
23
23
|
this.refreshToken = token.refresh_token;
|
|
24
|
-
|
|
25
|
-
if (token.expires_in) {
|
|
26
|
-
this.expiresAt = Date.now() + token.expires_in * 1000;
|
|
27
|
-
} else {
|
|
28
|
-
this.expiresAt = Date.now();
|
|
29
|
-
}
|
|
24
|
+
this.expiresAt = token.expires_at;
|
|
30
25
|
|
|
31
26
|
this.onUpdate?.(token);
|
|
32
27
|
}
|
package/types/api.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { CategoriesAPI } from "../src/api/CategoriesAPI.ts";
|
|
2
|
+
import { UsersAPI } from "../src/api/UsersAPI.ts";
|
|
3
|
+
import { ChannelsAPI } from "../src/api/ChannelsAPI.ts";
|
|
4
|
+
import { ChannelRewardsAPI } from "../src/api/ChannelRewardsAPI.ts";
|
|
5
|
+
import { LivestreamsAPI } from "../src/api/LivestreamsAPI.ts";
|
|
6
|
+
import { ModerationAPI } from "../src/api/ModerationAPI.ts";
|
|
7
|
+
import { KicksAPI } from "../src/api/KicksAPI.ts";
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* @type GetCategoriesParams
|
|
3
11
|
* @property {number?} [cursor] - The cursor for pagination. (Minimum: 4, Maximum: 28)
|
|
@@ -156,3 +164,13 @@ export type KickLeaderboardResponse = {
|
|
|
156
164
|
};
|
|
157
165
|
message: string;
|
|
158
166
|
};
|
|
167
|
+
|
|
168
|
+
export interface KickAPIClient {
|
|
169
|
+
categories: CategoriesAPI;
|
|
170
|
+
users: UsersAPI;
|
|
171
|
+
channels: ChannelsAPI;
|
|
172
|
+
rewards: ChannelRewardsAPI;
|
|
173
|
+
livestreams: LivestreamsAPI;
|
|
174
|
+
moderation: ModerationAPI;
|
|
175
|
+
kicks: KicksAPI;
|
|
176
|
+
}
|
package/types/auth.d.ts
CHANGED
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
* @property {string} access_token - The access token used for authentication.
|
|
12
12
|
* @property {string} refresh_token - The refresh token used to obtain new access tokens.
|
|
13
13
|
* @property {string} [token_type] - (Optional) The type of the token, typically "Bearer".
|
|
14
|
-
* @property {number} [expires_in] -
|
|
14
|
+
* @property {number} [expires_in] - The duration in seconds until the access token expires.
|
|
15
|
+
* @property {number} [expires_at] - The timestamp (in milliseconds) when the access token expires.
|
|
15
16
|
* @property {string} [scope] - (Optional) The scopes granted to the access token.
|
|
16
17
|
*/
|
|
17
18
|
export interface KickTokenResponse {
|
|
18
19
|
access_token: string;
|
|
19
20
|
refresh_token: string;
|
|
20
21
|
token_type?: string;
|
|
21
|
-
expires_in
|
|
22
|
+
expires_in: number;
|
|
23
|
+
expires_at: number;
|
|
22
24
|
scope?: string;
|
|
23
25
|
}
|
|
24
26
|
|