oberknecht-api
Advanced tools
Comparing version 1.4.6 to 1.4.7
@@ -30,2 +30,4 @@ import { jsonsplitter } from "oberknecht-jsonsplitter"; | ||
_refreshRefreshToken: (refreshToken: string, clientID: string, clientSecret: string) => Promise<import("../types/endpoints/refreshRefreshToken").refreshRefreshTokenResponse>; | ||
_getDataForRefreshToken: (refreshToken: string) => any; | ||
_getValidAccessTokenForRT: (refreshToken: string) => import("../types/endpoints/refreshRefreshToken").refreshRefreshTokenResponse; | ||
_revoketoken: (token: string, clientID?: string) => Promise<void>; | ||
@@ -32,0 +34,0 @@ _getUsers: (logins: string | string[] | undefined, ids?: string | string[] | undefined, noautofilterids?: Boolean, customToken?: string, refreshCache?: boolean) => Promise<import("../types/_getUsers")._getUsersResponse>; |
@@ -61,2 +61,3 @@ "use strict"; | ||
const getChannelModerators_1 = require("../endpoints/getChannelModerators"); | ||
const getValidAccessTokenForRT_1 = require("../functions/getValidAccessTokenForRT"); | ||
let clientSymNum = 0; | ||
@@ -197,2 +198,8 @@ (0, oberknecht_request_1.request)(null, null, null, { | ||
}; | ||
_getDataForRefreshToken = (refreshToken) => { | ||
return this.tokenSplitter.getKeySync(["refreshToken", refreshToken]); | ||
}; | ||
_getValidAccessTokenForRT = (refreshToken) => { | ||
return (0, getValidAccessTokenForRT_1.getValidAccessTokenForRT)(this.symbol, refreshToken); | ||
}; | ||
_revoketoken = (token, clientID) => { | ||
@@ -199,0 +206,0 @@ return (0, _revoketoken_1._revoketoken)(this.symbol, token, clientID); |
@@ -54,2 +54,14 @@ "use strict"; | ||
tokenSplitter.addKeySync(["accessToken", accessToken], accessTokenData); | ||
if ((0, oberknecht_utils_1.isNullUndefined)(tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokenNum", | ||
]))) | ||
tokenSplitter.addKeySync(["refreshToken", refreshToken, "accessTokenNum"], Object.keys(tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokens", | ||
])).length); | ||
else | ||
tokenSplitter.editKeyAddSync(["refreshToken", refreshToken, "accessTokenNum"], 1); | ||
return resolve(accessTokenDataR); | ||
@@ -56,0 +68,0 @@ }) |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (e || r.status !== 200) | ||
return reject(Error(e.stack ?? r.data)); | ||
return reject(Error(e?.stack ?? r?.data ?? e)); | ||
let refreshToken = r.data.refresh_token; | ||
@@ -66,2 +66,14 @@ let accessToken = r.data.access_token; | ||
tokenSplitter.addKeySync(["accessToken", accessToken], accessTokenData); | ||
if ((0, oberknecht_utils_1.isNullUndefined)(tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokenNum", | ||
]))) | ||
tokenSplitter.addKeySync(["refreshToken", refreshToken, "accessTokenNum"], Object.keys(tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokens", | ||
])).length); | ||
else | ||
tokenSplitter.editKeyAddSync(["refreshToken", refreshToken, "accessTokenNum"], 1); | ||
return resolve(re); | ||
@@ -68,0 +80,0 @@ }) |
@@ -73,2 +73,3 @@ import { i } from "../index"; | ||
import { getChannelModerators } from "../endpoints/getChannelModerators"; | ||
import { getValidAccessTokenForRT } from "../functions/getValidAccessTokenForRT"; | ||
let clientSymNum = 0; | ||
@@ -275,2 +276,10 @@ | ||
_getDataForRefreshToken = (refreshToken: string) => { | ||
return this.tokenSplitter.getKeySync(["refreshToken", refreshToken]); | ||
}; | ||
_getValidAccessTokenForRT = (refreshToken: string) => { | ||
return getValidAccessTokenForRT(this.symbol, refreshToken); | ||
}; | ||
_revoketoken = (token: string, clientID?: string) => { | ||
@@ -277,0 +286,0 @@ return _revoketoken(this.symbol, token, clientID); |
import { request } from "oberknecht-request"; | ||
import { i } from ".."; | ||
import { jsonsplitter } from "oberknecht-jsonsplitter"; | ||
import { getKeyFromObject } from "oberknecht-utils"; | ||
import { getKeyFromObject, isNullUndefined } from "oberknecht-utils"; | ||
import { _validatetoken } from "./_validatetoken"; | ||
@@ -15,3 +15,3 @@ import { refreshRefreshTokenResponse } from "../types/endpoints/refreshRefreshToken"; | ||
) { | ||
checkThrowMissingParams([sym,refreshToken], ["sym", "refreshToken"]); | ||
checkThrowMissingParams([sym, refreshToken], ["sym", "refreshToken"]); | ||
@@ -98,2 +98,27 @@ return new Promise<refreshRefreshTokenResponse>((resolve, reject) => { | ||
if ( | ||
isNullUndefined( | ||
tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokenNum", | ||
]) | ||
) | ||
) | ||
tokenSplitter.addKeySync( | ||
["refreshToken", refreshToken, "accessTokenNum"], | ||
Object.keys( | ||
tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokens", | ||
]) | ||
).length | ||
); | ||
else | ||
tokenSplitter.editKeyAddSync( | ||
["refreshToken", refreshToken, "accessTokenNum"], | ||
1 | ||
); | ||
return resolve(accessTokenDataR); | ||
@@ -100,0 +125,0 @@ }) |
@@ -5,3 +5,7 @@ import { request } from "oberknecht-request"; | ||
import { jsonsplitter } from "oberknecht-jsonsplitter"; | ||
import { filterByKeys, getKeyFromObject } from "oberknecht-utils"; | ||
import { | ||
filterByKeys, | ||
getKeyFromObject, | ||
isNullUndefined, | ||
} from "oberknecht-utils"; | ||
import { _validatetoken } from "./_validatetoken"; | ||
@@ -41,3 +45,4 @@ import { checkThrowMissingParams } from "../functions/checkThrowMissingParams"; | ||
async (e, r) => { | ||
if (e || r.status !== 200) return reject(Error(e.stack ?? r.data)); | ||
if (e || r.status !== 200) | ||
return reject(Error(e?.stack ?? r?.data ?? e)); | ||
@@ -116,2 +121,27 @@ let refreshToken = r.data.refresh_token; | ||
if ( | ||
isNullUndefined( | ||
tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokenNum", | ||
]) | ||
) | ||
) | ||
tokenSplitter.addKeySync( | ||
["refreshToken", refreshToken, "accessTokenNum"], | ||
Object.keys( | ||
tokenSplitter.getKeySync([ | ||
"refreshToken", | ||
refreshToken, | ||
"accessTokens", | ||
]) | ||
).length | ||
); | ||
else | ||
tokenSplitter.editKeyAddSync( | ||
["refreshToken", refreshToken, "accessTokenNum"], | ||
1 | ||
); | ||
return resolve(re); | ||
@@ -118,0 +148,0 @@ }) |
{ | ||
"name": "oberknecht-api", | ||
"version": "1.4.6", | ||
"version": "1.4.7", | ||
"description": "A client for easy usage of the Twitch API (Helix)", | ||
@@ -5,0 +5,0 @@ "main": "./export", |
356592
8230