@manaobot/kick 1.1.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manaobot/kick",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Minimal Typescript library for managing Kick.com bot",
5
5
  "main": "src/KickClient.ts",
6
6
  "private": false,
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
- return res.json() as Promise<KickTokenResponse>;
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(
@@ -52,9 +55,7 @@ export async function refreshToken(
52
55
  }
53
56
 
54
57
  const data = (await res.json()) as KickTokenResponse;
55
- if (typeof data.expires_in === "number") {
56
- data.expires_at = Date.now() + data.expires_in * 1000;
57
- }
58
+ data.expires_at = Date.now() + data.expires_in * 1000;
58
59
 
59
60
  return data;
60
61
  }
package/types/auth.d.ts CHANGED
@@ -11,16 +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] - (Optional) The duration in seconds until the access token expires.
15
- * @property {number} [expires_at] - (Optional) The timestamp (in milliseconds) when the access token expires.
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.
16
16
  * @property {string} [scope] - (Optional) The scopes granted to the access token.
17
17
  */
18
18
  export interface KickTokenResponse {
19
19
  access_token: string;
20
20
  refresh_token: string;
21
21
  token_type?: string;
22
- expires_in?: number;
23
- expires_at?: number;
22
+ expires_in: number;
23
+ expires_at: number;
24
24
  scope?: string;
25
25
  }
26
26