Skip to content

Commit

Permalink
fix: make refresh token optional in revokeToken
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritanand committed Nov 25, 2023
1 parent 9ea98a6 commit 3ad86b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trustauthx",
"version": "1.0.34",
"version": "1.0.35",
"description": "",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
19 changes: 7 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export class AuthLiteClient {
const headers = { accept: "application/json" };

try {
// const response = await fetch(url + "?" + params.toString(), {
// method: "GET",
// headers: headers,
// });
const response = await makeRequest(url + "?" + params.toString(), {
headers,
});
Expand Down Expand Up @@ -186,24 +182,23 @@ export class AuthLiteClient {
}

async revokeToken(
AccessToken: string | null = null,
RefreshToken: string | null = null,
accessToken: string,
refreshToken: string | null = null,
revokeAllTokens: boolean = false
): Promise<boolean> {
const url = "https://api.trustauthx.com/api/user/me/token/";
const headers = { accept: "application/json" };

if (!AccessToken && !RefreshToken) {
if (!accessToken)
throw new Error("Must provide either AccessToken or RefreshToken");
}

const tt = !!AccessToken;
const t = AccessToken ?? RefreshToken;
const isAccessToken = !!accessToken;
const t = accessToken ?? refreshToken;
const params = new URLSearchParams({
Token: t!, //Todo can i add ! to t
Token: t!,
api_key: this.apiKey,
signed_key: this.signedKey,
AccessToken: tt.toString(),
AccessToken: isAccessToken.toString(),
SpecificTokenOnly: (!revokeAllTokens).toString(),
});

Expand Down

0 comments on commit 3ad86b1

Please sign in to comment.