Skip to content

Commit

Permalink
Adding allowlist check to SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Dec 20, 2022
1 parent 3e89eb2 commit f6ea042
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Empty file added src/session/allowlist.ts
Empty file.
1 change: 1 addition & 0 deletions src/session/index.ts
Expand Up @@ -3,3 +3,4 @@ export * from "./get-session";
export * from "./login";
export * from "./logout";
export * from "./session";
export * from "./allowlist"
2 changes: 2 additions & 0 deletions src/session/session.ts
Expand Up @@ -3,11 +3,13 @@ import { login } from "./login";
import { logout } from "./logout";
import Masa from "../masa";
import { getSession } from "./get-session";
import { checkAllowlist } from "./allowlist";

export const session = (masa: Masa) => ({
checkLogin: () => checkLogin(masa),
sessionLogout: () => masa.client.sessionLogout(),
login: () => login(masa),
logout: () => logout(masa),
getSession: () => getSession(masa),
checkAllowlist: () => checkAllowlist(masa),
});
17 changes: 17 additions & 0 deletions src/utils/clients/middleware.ts
Expand Up @@ -47,6 +47,23 @@ export class MasaClient {
return checkData;
}
};
allowlistCheck = async (): Promise<ISession | undefined> => {
const checkResponse = await this._middlewareClient
.get(`/session/allowlist`, {
headers: {
cookie: this.cookie ? [this.cookie] : undefined,
},
})
.catch(() => {
// ignore
});

if (checkResponse) {
const { data: checkData } = checkResponse;

return checkData.success;
}
};

getMetadata = async (
uri: string
Expand Down

0 comments on commit f6ea042

Please sign in to comment.