Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongsahil committed May 7, 2024
2 parents e667b7c + e908700 commit 575b572
Show file tree
Hide file tree
Showing 19 changed files with 501 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</a>
</p>

<h3 align="center">⚡ Build, Test & Debug web and mobile apps 10x faster </h2>
<h3 align="center">⚡ HTTP Interceptor for browsers </h2>

**Bring the power of Charles Proxy, Fiddler & Postman together** with beautiful, modern UI & collaboration features. Available as a browser extension on all major browsers & desktop apps on all platforms. [Install Requestly](https://requestly.com/downloads)
**Requestly was built to save developers time by intercepting and modifying HTTP Requests. It has now developed into an open-source alternative to Charles Proxy and Telerik Fiddler that works directly in browsers without VPN and proxy Issues. It is used by more than 200,000+ front-end developers and 11,000+ companies worldwide.**



Expand Down
15 changes: 13 additions & 2 deletions app/src/actions/FirebaseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,19 @@ export async function updateUserInFirebaseAuthUser(data) {
});
}

export const loginWithSSO = async (providerId) => {
export const loginWithSSO = async (providerId, email) => {
const provider = new SAMLAuthProvider(providerId);

const auth = getAuth(firebaseApp);

return signInWithPopup(auth, provider)
.then((result) => {
// console.log({ result });
trackLoginSuccessEvent({
auth_provider: AUTH_PROVIDERS.SSO,
email: result?.user?.email,
uid: result?.user?.uid,
});

result.user
.getIdToken()
.then((tokenValue) => {
Expand All @@ -698,6 +703,12 @@ export const loginWithSSO = async (providerId) => {
// as an object in the firebase.sign_in_attributes custom claim.
})
.catch((error) => {
trackLoginFailedEvent({
auth_provider: AUTH_PROVIDERS.SSO,
email,
place: window.location.href,
error_message: error?.message || "SSO Login Failed",
});
console.log(error);
// Handle error.
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Logger from "lib/logger";
import { MdOutlineWarningAmber } from "@react-icons/all-files/md/MdOutlineWarningAmber";
import { getDomainFromEmail, getEmailType, isEmailValid } from "utils/FormattingHelper";
import { toast } from "utils/Toast";
import { trackLoginAttemptedEvent } from "modules/analytics/events/common/auth/login";
import { trackLoginAttemptedEvent, trackLoginFailedEvent } from "modules/analytics/events/common/auth/login";
import { AUTH_PROVIDERS } from "modules/analytics/constants";
import "./index.scss";
import { getSSOProviderId } from "backend/auth/sso";
Expand Down Expand Up @@ -52,9 +52,16 @@ export const SSOSignInForm: React.FC<Props> = ({ setAuthMode, email, setEmail, s
setIsNoConnectionFoundCardVisible(false);

if (providerId) {
await loginWithSSO(providerId);
await loginWithSSO(providerId, email);
} else {
setIsNoConnectionFoundCardVisible(true);
trackLoginFailedEvent({
auth_provider: AUTH_PROVIDERS.SSO,
email,
place: window.location.href,
source,
error_message: "SSO connection not found",
});
const captureSSOInterest = httpsCallable(getFunctions(), "auth-captureSSOInterest");

captureSSOInterest({ email })
Expand Down
11 changes: 9 additions & 2 deletions browser-extension/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const EXTENSION_MESSAGES = {
CACHE_RECORDED_SESSION_ON_PAGE_UNLOAD: "cacheRecordedSessionOnPageUnload",
INIT_SESSION_RECORDER: "initSessionRecorder",
CLIENT_PAGE_LOADED: "clientPageLoaded",
SAVE_TEST_RULE_RESULT: "saveTestRuleResult",
NOTIFY_TEST_RULE_REPORT_UPDATED: "notifyTestRuleReportUpdated",
TEST_RULE_ON_URL: "testRuleOnUrl",
};

export const CLIENT_MESSAGES = {
Expand All @@ -36,14 +39,16 @@ export const CLIENT_MESSAGES = {
NOTIFY_SESSION_RECORDING_STOPPED: "notifySessionRecordingStopped",
IS_RECORDING_SESSION: "isRecordingSession",
GET_TAB_SESSION: "getTabSession",
GET_APPLIED_REQUEST_RESPONSE_RULES: "getAppliedRequestResponseRules",
GET_APPLIED_SCRIPT_RULES: "getAppliedScriptRules",
GET_APPLIED_RULES: "getAppliedRules",
UPDATE_APPLIED_SCRIPT_RULES: "updateAppliedScriptRules",
START_RECORDING: "startRecording",
STOP_RECORDING: "stopRecording",
IS_EXPLICIT_RECORDING_SESSION: "isExplicitRecordingSession",
NOTIFY_RECORD_UPDATED_IN_POPUP: "notifyRecordUpdatedInPopup",
NOTIFY_PAGE_LOADED_FROM_CACHE: "notifyPageLoadedFromCache",
START_EXPLICIT_RULE_TESTING: "startExplicitRuleTesting",
START_IMPLICIT_RULE_TESTING: "startImplicitRuleTesting",
SYNC_APPLIED_RULES: "syncAppliedRules",
};

export const STORAGE_TYPE = "local";
Expand All @@ -66,6 +71,8 @@ export const RULE_TITLES = {
export const STORAGE_KEYS = {
LAST_SYNCED_TS: "last-synced-ts",
LAST_UPDATED_TS: "last-updated-ts",
TEST_REPORTS: "testReports",
IMPLICIT_RULE_TESTING_WIDGET_CONFIG: "implicit_rule_testing_widget_config",
};

export const LINKS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RQImplicitTestRuleWidget extends RQTestRuleWidget {
return `
<div class="applied-rule-list-item">
<div class="applied-rule-item-details">
<span class="applied-rule-icon">${getRuleTypeIcon(rule.ruleType)}</span>
<span class="applied-rule-icon">${getRuleTypeIcon(rule.ruleType)}</span>
<span class="applied-rule-name">${rule.ruleName}</span>
</div>
<span class="applied-rule-arrow-icon">${arrowRightIcon}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from "react";
import { EXTENSION_MESSAGES, LINKS } from "../../../constants";
import React, { useCallback } from "react";
import { LINKS } from "../../../constants";
import { Rule } from "../../../types";
import RuleItem from "../common/RuleItem";
import { updateItemInCollection } from "../../utils";
Expand All @@ -8,27 +8,11 @@ import { PrimaryActionButton } from "../common/PrimaryActionButton";
import { EmptyPopupTab } from "../PopupTabs/EmptyPopupTab";

interface ExecutedRulesProps {
setExecutedRulesCount: (count: number) => void;
executedRules: Rule[];
setExecutedRules: React.Dispatch<React.SetStateAction<Rule[]>>;
}

const ExecutedRules: React.FC<ExecutedRulesProps> = ({ setExecutedRulesCount }) => {
const [executedRules, setExecutedRules] = useState<Rule[]>([]);

useEffect(() => {
chrome.tabs.query({ currentWindow: true, active: true }, ([activeTab]) => {
chrome.runtime.sendMessage(
{
tabId: activeTab.id,
action: EXTENSION_MESSAGES.GET_EXECUTED_RULES,
},
(rules) => {
setExecutedRules(rules);
setExecutedRulesCount(rules.length);
}
);
});
}, []);

const ExecutedRules: React.FC<ExecutedRulesProps> = ({ executedRules, setExecutedRules }) => {
const updateExecutedRule = useCallback((updatedRule: Rule) => {
setExecutedRules((executedRules) => updateItemInCollection<Rule>(executedRules, updatedRule));
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ExternalLinkIcon from "../../../../resources/icons/externalLink.svg";
import ArrowIcon from "../../../../resources/icons/arrowDown.svg";
import { PushpinOutlined, CheckCircleOutlined, ClockCircleOutlined } from "@ant-design/icons";
import { icons } from "../../ruleTypeIcons";
import { RuleType } from "../../../types";
import { Rule, RuleType } from "../../../types";
import { EVENT, sendEvent } from "../../events";
import config from "../../../config";
import "./popupTabs.css";
Expand All @@ -21,8 +21,8 @@ export enum PopupTabKey {
}

const PopupTabs: React.FC = () => {
const [executedRulesCount, setExecutedRulesCount] = useState(0);
const [isRuleDropdownOpen, setIsRuleDropdownOpen] = useState(false);
const [executedRules, setExecutedRules] = useState<Rule[]>([]);
const [activeTabKey, setActiveTabKey] = useState(PopupTabKey.PINNED_RULES);

useEffect(() => {
Expand All @@ -33,9 +33,9 @@ const PopupTabs: React.FC = () => {
action: EXTENSION_MESSAGES.GET_EXECUTED_RULES,
},
(rules) => {
setExecutedRulesCount(rules.length);
if (rules.length) {
setActiveTabKey(PopupTabKey.EXECUTED_RULES);
setExecutedRules(rules);
}
}
);
Expand Down Expand Up @@ -70,13 +70,13 @@ const PopupTabs: React.FC = () => {
<span>
<CheckCircleOutlined />
Executed rules
<Badge size="small" count={executedRulesCount} overflowCount={20} className="popup-tab-badge" />
<Badge size="small" count={executedRules.length} overflowCount={20} className="popup-tab-badge" />
</span>
),
children: <ExecutedRules setExecutedRulesCount={setExecutedRulesCount} />,
children: <ExecutedRules executedRules={executedRules} setExecutedRules={setExecutedRules} />,
},
];
}, [executedRulesCount]);
}, [executedRules]);

const handleRulesDropdownItemClick = (url: string, ruleType?: RuleType) => {
if (ruleType) {
Expand Down
2 changes: 2 additions & 0 deletions browser-extension/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export interface SessionRecordingConfig {
}

export interface RulePair {
id: string;
source: UrlSource;
modifications?: any;
}

export interface Rule extends Record<string, unknown> {
Expand Down
74 changes: 74 additions & 0 deletions browser-extension/mv3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions browser-extension/mv3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"devDependencies": {
"@requestly/web-sdk": "0.14.2",
"@rollup/plugin-json": "^5.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.0.0",
"@types/chrome": "^0.0.266",
"archiver": "^5.3.1",
Expand Down
2 changes: 2 additions & 0 deletions browser-extension/mv3/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import json from "@rollup/plugin-json";
import typescript from "@rollup/plugin-typescript";
import copy from "rollup-plugin-copy";
import { terser } from "rollup-plugin-terser";
import nodeResolve from "@rollup/plugin-node-resolve";
import { version } from "./package.json";
import { browser, WEB_URL, OTHER_WEB_URLS } from "../config/dist/config.build.json";

Expand Down Expand Up @@ -60,6 +61,7 @@ export default [
format: "iife",
},
plugins: [
nodeResolve(),
...commonPlugins,
copy({
targets: [
Expand Down
3 changes: 2 additions & 1 deletion browser-extension/mv3/src/content-scripts/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initMessageHandler } from "./messageHandler";
import { initMessageHandler, initExtensionMessageListener } from "./messageHandler";

document.documentElement.setAttribute("rq-ext-version", chrome.runtime.getManifest()["version"]);

Expand All @@ -9,3 +9,4 @@ document.documentElement.setAttribute("rq-ext-mv", "3");
document.documentElement.setAttribute("rq-ext-id", chrome.runtime.id);

initMessageHandler();
initExtensionMessageListener();
11 changes: 11 additions & 0 deletions browser-extension/mv3/src/content-scripts/app/messageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,20 @@ export const initMessageHandler = () => {
case EXTENSION_MESSAGES.GET_TAB_SESSION:
case EXTENSION_MESSAGES.GET_API_RESPONSE:
case EXTENSION_MESSAGES.START_RECORDING_ON_URL:
case EXTENSION_MESSAGES.TEST_RULE_ON_URL:
delegateMessageToBackground(event.data);
}
}
}
);
};

export const initExtensionMessageListener = () => {
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
switch (message.action) {
case EXTENSION_MESSAGES.NOTIFY_TEST_RULE_REPORT_UPDATED:
sendExtensionMessage(message);
break;
}
});
};

0 comments on commit 575b572

Please sign in to comment.