Skip to content

Commit

Permalink
Allowlist improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Jan 4, 2023
1 parent af0f5e1 commit d3a7e36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/session/allowlist.ts
@@ -1,16 +1,15 @@
import Masa from "../masa";

export const checkAllowlist = async (masa: Masa): Promise<boolean> => {
let loggedIn = false;
export const checkAllowlist = async (masa: Masa): Promise<any> => {
const checkAllowlistResponse = await masa.client.allowlistCheck();
if (checkAllowlistResponse) {
console.log(`Allowlist enabled: ${checkAllowlistResponse.isActive}`);
console.log(`Allowlist enabled until: ${checkAllowlistResponse.endDate}`);

const checkSessionResponse = await masa.client.sessionCheck();
if (checkSessionResponse) {
console.log(`User ID: '${checkSessionResponse.user.userId}'`);
console.log(`Signer Address: '${await masa.config.wallet.getAddress()}'`);
console.log("\n");

loggedIn = true;
return checkAllowlistResponse;
}

return loggedIn;
return null;
};
7 changes: 5 additions & 2 deletions src/utils/clients/middleware.ts
Expand Up @@ -47,7 +47,10 @@ export class MasaClient {
return checkData;
}
};
allowlistCheck = async (): Promise<ISession | undefined> => {
allowlistCheck = async (): Promise<
| { isActive: boolean; success: boolean; wallet: string; endDate: string }
| undefined
> => {
const checkResponse = await this._middlewareClient
.get(`/session/allowlist`, {
headers: {
Expand All @@ -61,7 +64,7 @@ export class MasaClient {
if (checkResponse) {
const { data: checkData } = checkResponse;

return checkData.success;
return checkData;
}
};

Expand Down

0 comments on commit d3a7e36

Please sign in to comment.