Skip to content

Commit

Permalink
final lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jul 30, 2024
1 parent ac32e66 commit 2f51f67
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 374 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/authservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ jobs:
TWITTER_EMAIL: ${{ secrets.TWITTER_EMAIL }}
CI: true
CI_MODE: ${{ secrets.CI_MODE }}
MAILOSAUR_API_KEY: ${{ secrets.MAILOSAUR_API_KEY }}
MAILOSAUR_SERVER_ID: ${{ secrets.MAILOSAUR_SERVER_ID }}
MAILOSAUR_SERVER_DOMAIN: ${{ secrets.MAILOSAUR_SERVER_DOMAIN }}
PLATFORM: ${{ matrix.env.PLATFORM }}
APP_VERSION: "v3"
GITHUB_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/demowalletservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
TWITTER_EMAIL: ${{ secrets.TWITTER_EMAIL }}
CI: true
CI_MODE: ${{ secrets.CI_MODE }}
MAILOSAUR_API_KEY: ${{ secrets.MAILOSAUR_API_KEY }}
MAILOSAUR_SERVER_ID: ${{ secrets.MAILOSAUR_SERVER_ID }}
MAILOSAUR_SERVER_DOMAIN: ${{ secrets.MAILOSAUR_SERVER_DOMAIN }}
PLATFORM: ${{ matrix.env.PLATFORM }}
APP_VERSION: "v3"
GITHUB_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/walletservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
TWITTER_EMAIL: ${{ secrets.TWITTER_EMAIL }}
CI: true
CI_MODE: ${{ secrets.CI_MODE }}
MAILOSAUR_API_KEY: ${{ secrets.MAILOSAUR_API_KEY }}
MAILOSAUR_SERVER_ID: ${{ secrets.MAILOSAUR_SERVER_ID }}
MAILOSAUR_SERVER_DOMAIN: ${{ secrets.MAILOSAUR_SERVER_DOMAIN }}
PLATFORM: ${{ matrix.env.PLATFORM }}
APP_VERSION: "v3"
GITHUB_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"gmail",
"isrefinement",
"jakejarvis",
"Mailosaur",
"mkdir",
"networkidle",
"noreport",
Expand Down
10 changes: 0 additions & 10 deletions authservice/login-with-passwordless/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Client } from "@opensearch-project/opensearch";
import { expect, test } from "@playwright/test";

import { AccountsPage } from "../openlogin-account-page/AccountsPage";
Expand All @@ -16,16 +15,7 @@ import {
} from "../utils";
const demoAppUrl = env_map.demo;
const demoAppUrlV4 = env_map.demoV6;
const eventPostURL =
process.env.ES_ENDPOINT === undefined
? "search-sapphire-latency-stats-7n6qd4g6m3au5fpre3gwvwo6vm.eu-west-1.es.amazonaws.com"
: process.env.ES_ENDPOINT;
const region = process.env.REGION === undefined ? "singapore" : process.env.REGION;
const username = "devops";
const platform = process.env.PLATFORM || "";
const password = process.env.PASSWORD;
const version = process.env.APP_VERSION;
const ci_mode = process.env.CI_MODE;
const openloginURL = env_map[process.env.PLATFORM || "prod"];
const user = {
mobileNumberForLogin: process.env.LOGIN_MOBILE_NUMBER || "",
Expand Down
21 changes: 0 additions & 21 deletions authservice/openlogin-account-page/AccountsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,6 @@ export class AccountsPage {
let seedArray: string[];
let seedEmail;
let seedString = "";
if (process.env.MAIL_APP === "mailosaur") {
const seedEmail = await mailosaur.messages.get(
process.env.MAILOSAUR_SERVER_ID || "",
{
sentTo: backupEmail,
},
{ timeout: 30 * 1000 }
);
seedArray =
seedEmail.html?.body
?.toString()
.replace(/(\r\n|\n|\r)/gm, "")
.slice(11084)
.split("<")[0]
.split(" ") || [];
for (let i = 0; i < 23; i++) {
seedString += `${seedArray[i]} `;
}
seedString += seedArray[23];
await mailosaur.messages.del(seedEmail?.id || "");
}
if (process.env.MAIL_APP === "testmail") {
// Setup our JSON API endpoint
const ENDPOINT = `https://api.testmail.app/api/json?apikey=${testEmailAppApiKey}&namespace=kelg8`;
Expand Down
100 changes: 1 addition & 99 deletions authservice/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* eslint-disable no-unmodified-loop-condition */
import { Browser, expect, Page } from "@playwright/test";
import { generate } from "generate-password";
import Mailosaur from "mailosaur";
import { Link } from "mailosaur/lib/models";

import confirmEmail from "./confirmEmail";
process.env.APP_VERSION = "v4";
Expand All @@ -27,25 +24,13 @@ const env_map: { [key: string]: string } = {
demoV4: "https://demo-openlogin-v4.web3auth.io/",
demoV6: "https://demo-openlogin-v6.web3auth.io/",
};
const randomEmail = generate({
length: 20,
lowercase: true,
});

function delay(time: number | undefined) {
return new Promise(function (resolve) {
setTimeout(resolve, time);
});
}

function findLink(links: Link[], text: string) {
for (const link of links) {
if (link.text === text) return link;
}

return null;
}

export async function slowOperation<T>(op: () => Promise<T>, timeout?: number): Promise<T> {
if (timeout) {
return new Promise<T>((resolve, reject) => {
Expand Down Expand Up @@ -257,38 +242,6 @@ async function signInWithGoogle({
}
}

async function signInWithEmailIntoTorusWallet(page: Page, email: string, browser: Browser): Promise<boolean> {
try {
await page.fill('[placeholder="Enter your email"]', email);
await delay(5000);
await page.click('div:has-text("Continue with Email")');
//await page.waitForSelector("text=Verify your email");
await delay(3000);
const mailosaur = new Mailosaur(process.env.MAILOSAUR_API_KEY || "");
const mailBox = await mailosaur.messages.get(process.env.MAILOSAUR_SERVER_ID || "", {
sentTo: email,
});
let link = findLink(mailBox.html?.links || [], "Approve login request");
if (!link) {
link = findLink(mailBox.html?.links || [], "Verify my email");
}
await mailosaur.messages.del(mailBox?.id || "");
const href = link?.href || "";

const context2 = await browser.newContext();
const page2 = await context2.newPage();
await page2.goto(href);
await page2.waitForSelector("text=Close this and return to your previous window", {
timeout: 10000,
});
await page2.close();
return true;
} catch (err) {
console.error(err);
return false;
}
}

async function signInWithGitHub({
page,
github,
Expand Down Expand Up @@ -551,18 +504,6 @@ async function signInWithEmail(page: Page, email: string, browser: Browser): Pro
await page.waitForSelector("text=Verify your email");
await delay(3000);
let href;
if (process.env.MAIL_APP === "mailosaur") {
const mailosaur = new Mailosaur(process.env.MAILOSAUR_API_KEY || "");
const mailBox = await mailosaur.messages.get(process.env.MAILOSAUR_SERVER_ID || "", {
sentTo: email,
});
let link = findLink(mailBox.html?.links || [], "Approve login request");
if (!link) {
link = findLink(mailBox.html?.links || [], "Verify my email");
}
await mailosaur.messages.del(mailBox?.id || "");
href = link?.href || "";
}
if (process.env.MAIL_APP === "testmail") {
// Setup our JSON API endpoint
const ENDPOINT = `https://api.testmail.app/api/json?apikey=${testEmailAppApiKey}&namespace=kelg8`;
Expand Down Expand Up @@ -741,40 +682,6 @@ async function signInWithMobileNumber({
await page.locator("xpath=.//input[@aria-label='Please enter verification code. Digit 1']").fill(otp);
}

async function signInWithDapps({ page, browser, testEmail }: { page: Page; browser: Browser; testEmail: string }) {
const context3 = await browser.newContext();
await page.goto("https://demo-openlogin.web3auth.io/");
await page.locator("select.select").last().selectOption("email_passwordless");
await page.fill('[placeholder="Enter an email"]', testEmail);
await page.click('button:has-text("Login with email passwordless")');
const newEmail = await mailosaur.messages.get(
process.env.MAILOSAUR_SERVER_ID || "",
{
sentTo: testEmail,
},
{
timeout: 20 * 1000,
}
);
expect(newEmail.subject).toContain("Verify your email");
let link = findLink(newEmail.html?.links || [], "Approve login request");
if (!link) {
link = findLink(newEmail.html?.links || [], "Verify my email");
}
expect(link?.text).toContain("Approve login request");
const href = link?.href || "";
const page3 = await context3.newPage();
await page3.goto(href);
await page3.waitForSelector("text=Close this and return to your previous window", {
timeout: 10000,
});
await page3.close();
await delay(3000);
await page.getByLabel("Set up 2FA").waitFor();
await page.locator("xpath=.//button[text()='Skip for Now']").first().click();
await delay(5000);
}

function generateEmailWithTag() {
// Randomly generating the tag...
const chance = new ChanceJS();
Expand All @@ -786,9 +693,6 @@ function generateEmailWithTag() {
}

function generateRandomEmail() {
if (process.env.MAIL_APP === "mailosaur") {
return `${randomEmail}${Date.now()}@${process.env.MAILOSAUR_SERVER_DOMAIN}`;
}
if (process.env.MAIL_APP === "testmail") {
return generateEmailWithTag();
}
Expand Down Expand Up @@ -816,14 +720,12 @@ export {
delay,
deleteCurrentDeviceShare,
env_map,
findLink,
generateEmailWithTag,
generateRandomEmail,
getBackUpPhrase,
signInWithDapps,
// signInWithDapps,
signInWithDiscord,
signInWithEmail,
signInWithEmailIntoTorusWallet,
signInWithEmailWithTestEmailApp,
signInWithEmailWithTestEmailOnDemoApp,
signInWithEmailWithTestEmailOnDemoAppV4,
Expand Down
Loading

0 comments on commit 2f51f67

Please sign in to comment.