Skip to content

Commit

Permalink
feat: support new check token schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sosweetham committed Jul 7, 2024
1 parent 580ebd4 commit b5f5670
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { URLSearchParams } from "url";
import { GuildedUser, IGetToken, Alias, UserStatus, Content, Document, CustomReaction, AboutInfo } from "./types";
import {
GuildedUser,
IGetToken,
Alias,
UserStatus,
Content,
Document,
CustomReaction,
AboutInfo,
} from "./types";

export { GuildedUser, IGetToken, Alias, UserStatus, Content, Document, CustomReaction, AboutInfo };
export {
GuildedUser,
IGetToken,
Alias,
UserStatus,
Content,
Document,
CustomReaction,
AboutInfo,
};

/**
* The main class for the cardboard api
Expand Down Expand Up @@ -29,8 +47,8 @@ export class Cardboard {

/**
* @param code The code recieved from cardboard redirect according to the oauth2 flow
* @returns The token object
*
* @returns The token object
*
* ```ts
* app.get("/login", async (req, res) => {
* const code = req.query.code as string
Expand Down Expand Up @@ -82,9 +100,9 @@ export class Cardboard {
* @returns The token object
* ```ts
* app.get("/logout", async (req, res) => {
* // remove session on cardboard's end
* // remove session on cardboard's end
* const logout = await cb.revokeToken(at)
* // your logic to remove session in your app
* // your logic to remove session in your app
* at = ""
* res.send(logout)
* return
Expand Down Expand Up @@ -113,7 +131,11 @@ export class Cardboard {
const response = await fetch(`${this._baseurl}token/check`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ token: access_token }).toString(),
body: new URLSearchParams({
token: access_token,
client_id: this.client_id,
client_secret: this.client_secret,
}).toString(),
});
return response.json();
}
Expand All @@ -140,4 +162,3 @@ export class Cardboard {
return response.json() as Promise<GuildedUser>;
}
}

0 comments on commit b5f5670

Please sign in to comment.