buzzk 2.0.0 → 2.0.1
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/lib/oauth.js +27 -0
- package/package.json +1 -1
package/lib/oauth.js
CHANGED
|
@@ -11,6 +11,25 @@ class chzzkToken {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} chzzkChannel
|
|
16
|
+
* @property {string} channelID
|
|
17
|
+
* @property {string} name
|
|
18
|
+
* @property {string} follower
|
|
19
|
+
* @property {string} imageURL
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} chzzkTokenData
|
|
24
|
+
* @property {string} access
|
|
25
|
+
* @property {string} refresh
|
|
26
|
+
* @property {string} expireIn
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} code
|
|
31
|
+
* @returns {Promise<chzzkTokenData>}
|
|
32
|
+
*/
|
|
14
33
|
async function get (code) {
|
|
15
34
|
return new Promise(async (resolve, reject) => {
|
|
16
35
|
let options = {
|
|
@@ -34,6 +53,10 @@ async function get (code) {
|
|
|
34
53
|
});
|
|
35
54
|
}
|
|
36
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @param {string} refreshToken
|
|
58
|
+
* @returns {Promise<chzzkTokenData>}
|
|
59
|
+
*/
|
|
37
60
|
async function refresh (refreshToken) {
|
|
38
61
|
return new Promise(async (resolve, reject) => {
|
|
39
62
|
let options = {
|
|
@@ -56,6 +79,10 @@ async function refresh (refreshToken) {
|
|
|
56
79
|
});
|
|
57
80
|
}
|
|
58
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @param {string} accessToken
|
|
84
|
+
* @returns {Promise<chzzkChannel>}
|
|
85
|
+
*/
|
|
59
86
|
async function resolve (accessToken) {
|
|
60
87
|
return new Promise(async (resolve, reject) => {
|
|
61
88
|
|