-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
751 additions
and
519 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.yarn/patches/@amplitude-plugin-autocapture-browser-npm-1.0.3-edb25bef55.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/lib/cjs/constants.js b/lib/cjs/constants.js | ||
index 5772226ef895bff7a6f7fa291fc1138b10049dab..c65a57bf3535e6c6d4d894657da9b571d7f40d8a 100644 | ||
--- a/lib/cjs/constants.js | ||
+++ b/lib/cjs/constants.js | ||
@@ -29,7 +29,7 @@ exports.AMPLITUDE_ORIGINS_MAP = { | ||
EU: exports.AMPLITUDE_ORIGIN_EU, | ||
STAGING: exports.AMPLITUDE_ORIGIN_STAGING, | ||
}; | ||
-exports.AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz'; | ||
+exports.AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = ''; | ||
// This is the class name used by the visual tagging selector to highlight the selected element. | ||
// Should not use this class in the selector. | ||
exports.AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight'; | ||
diff --git a/lib/esm/constants.js b/lib/esm/constants.js | ||
index 17e665c05e62e488032673d312a69432297cb6fd..7d75951a29fad79ba49c83c076785294166dd0bf 100644 | ||
--- a/lib/esm/constants.js | ||
+++ b/lib/esm/constants.js | ||
@@ -27,7 +27,7 @@ export var AMPLITUDE_ORIGINS_MAP = { | ||
EU: AMPLITUDE_ORIGIN_EU, | ||
STAGING: AMPLITUDE_ORIGIN_STAGING, | ||
}; | ||
-export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz'; | ||
+export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = ''; | ||
// This is the class name used by the visual tagging selector to highlight the selected element. | ||
// Should not use this class in the selector. | ||
export var AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
export enum StorageKeys { | ||
lastTimestamp = "last-time-stamp", | ||
allTokens = "all-tokens", | ||
fiatInfo = "fiat-info", | ||
lastTimestamp = 'last-time-stamp', | ||
allTokens = 'all-tokens', | ||
fiatInfo = 'fiat-info', | ||
} | ||
|
||
export interface CoingeckPlatforms { | ||
[key: string]: any; | ||
ethereum?: string; | ||
"ethereum-classic"?: string; | ||
"binance-smart-chain"?: string; | ||
gochain?: string; | ||
"polygon-pos"?: string; | ||
moonbeam?: string; | ||
rootstock?: string; | ||
[key: string]: any | ||
ethereum?: string | ||
'ethereum-classic'?: string | ||
'binance-smart-chain'?: string | ||
gochain?: string | ||
'polygon-pos'?: string | ||
moonbeam?: string | ||
rootstock?: string | ||
} | ||
export interface CoinGeckoToken { | ||
id: string; | ||
symbol: string; | ||
name: string; | ||
platforms: CoingeckPlatforms; | ||
id: string | ||
symbol: string | ||
name: string | ||
platforms: CoingeckPlatforms | ||
} | ||
export interface CoinGeckoTokenMarket { | ||
id: string; | ||
symbol: string; | ||
name: string; | ||
image: string; | ||
current_price: null | number; | ||
market_cap: number; | ||
market_cap_rank: number; | ||
high_24h: number; | ||
low_24h: number; | ||
price_change_24h: number; | ||
price_change_percentage_24h: number; | ||
sparkline_in_7d: { price: number[] }; | ||
price_change_percentage_7d_in_currency: number; | ||
id: string | ||
symbol: string | ||
name: string | ||
image: string | ||
current_price: null | number | ||
market_cap: number | ||
market_cap_rank: number | ||
high_24h: number | ||
low_24h: number | ||
price_change_24h: number | ||
price_change_percentage_24h: number | ||
sparkline_in_24h: { price: number[] } | ||
price_change_percentage_24h_in_currency: number | ||
} | ||
export interface FiatMarket { | ||
fiat_currency: string; | ||
exchange_rate: string; | ||
fiat_currency: string | ||
exchange_rate: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,139 @@ | ||
import { | ||
sendToBackgroundFromBackground, | ||
sendToNewWindowFromBackground, | ||
} from "@/libs/messenger/extension"; | ||
import { ProviderName } from "@/types/provider"; | ||
import Browser from "webextension-polyfill"; | ||
import { InternalMethods, InternalOnMessageResponse } from "@/types/messenger"; | ||
import { getCustomError, getError } from "../error"; | ||
import getUiPath from "../utils/get-ui-path"; | ||
import UIRoutes from "@/ui/provider-pages/enkrypt/routes/names"; | ||
import { ErrorCodes } from "@/providers/ethereum/types"; | ||
} from '@/libs/messenger/extension' | ||
import { ProviderName } from '@/types/provider' | ||
import Browser from 'webextension-polyfill' | ||
import { InternalMethods, InternalOnMessageResponse } from '@/types/messenger' | ||
import { getCustomError, getError } from '../error' | ||
import getUiPath from '../utils/get-ui-path' | ||
import UIRoutes from '@/ui/provider-pages/enkrypt/routes/names' | ||
import { ErrorCodes } from '@/providers/ethereum/types' | ||
|
||
const UNLOCK_PATH = getUiPath(UIRoutes.unlock.path, ProviderName.enkrypt); | ||
const UNLOCK_PATH = getUiPath(UIRoutes.unlock.path, ProviderName.enkrypt) | ||
class WindowPromise { | ||
private async getRawResponse( | ||
url: string, | ||
msg: string, | ||
tabId: number | ||
tabInfo: { tabId: number }, | ||
): Promise<InternalOnMessageResponse> { | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
Browser.tabs.onUpdated.addListener(function listener(_tabId, info, tab) { | ||
if (info.status === "complete" && _tabId === tabId && tab.url === url) { | ||
if ( | ||
info.status === 'complete' && | ||
_tabId === tabInfo.tabId && | ||
tab.url === url | ||
) { | ||
resolve( | ||
sendToNewWindowFromBackground( | ||
{ | ||
provider: ProviderName.enkrypt, | ||
message: msg, | ||
}, | ||
tabId | ||
) | ||
); | ||
Browser.tabs.onUpdated.removeListener(listener); | ||
tabInfo.tabId, | ||
), | ||
) | ||
Browser.tabs.onUpdated.removeListener(listener) | ||
} | ||
}); | ||
Browser.tabs.update(tabId, { url }); | ||
}); | ||
}) | ||
Browser.tabs.update(tabInfo.tabId, { url }) | ||
}) | ||
} | ||
|
||
private removeTab(tabId: number) { | ||
Browser.tabs.get(tabId).then((info) => { | ||
Browser.windows.remove(info.windowId!); | ||
}); | ||
Browser.tabs.get(tabId).then(info => { | ||
Browser.windows.remove(info.windowId!) | ||
}) | ||
} | ||
|
||
async getResponse( | ||
url: string, | ||
msg: string, | ||
unlockKeyring = false | ||
unlockKeyring = false, | ||
): Promise<InternalOnMessageResponse> { | ||
const loadingURL = '/index.html#/enkrypt/loading' | ||
const tabInfo = { | ||
tabId: -1, | ||
} | ||
const windowInfo = await Browser.windows.create({ | ||
url: "/index.html#/enkrypt/loading", | ||
type: "popup", | ||
url: loadingURL, | ||
type: 'popup', | ||
focused: true, | ||
height: 600, | ||
width: 460, | ||
}); | ||
const tabId: number | undefined = windowInfo.tabs?.length | ||
? windowInfo.tabs[0].id | ||
: 0; | ||
if (typeof tabId === "undefined") { | ||
}) | ||
const validTabs = await Browser.tabs.query({ | ||
windowId: windowInfo.id, | ||
}) | ||
tabInfo.tabId = validTabs.length && validTabs[0].id ? validTabs[0].id : -1 | ||
if (typeof tabInfo.tabId === 'undefined' || tabInfo.tabId === -1) { | ||
return Promise.resolve({ | ||
error: getCustomError("unknown error, no tabId"), | ||
}); | ||
error: getCustomError('unknown error, no tabId'), | ||
}) | ||
} | ||
const waitForWindow = async (): Promise<void> => { | ||
while ((await Browser.tabs.get(tabId)).status !== "complete") {} | ||
}; | ||
await waitForWindow(); | ||
// eslint-disable-next-line no-empty | ||
while ((await Browser.tabs.get(tabInfo.tabId)).status !== 'complete') {} | ||
} | ||
await waitForWindow() | ||
const monitorTabs = (): Promise<InternalOnMessageResponse> => { | ||
return new Promise((resolve) => { | ||
Browser.tabs.onRemoved.addListener(function tabListener(_tabId) { | ||
if (_tabId === tabId) { | ||
Browser.tabs.onRemoved.removeListener(tabListener); | ||
return new Promise(resolve => { | ||
const tabReplacedListener = (addedId: number, replacedId: number) => { | ||
if (replacedId === tabInfo.tabId) { | ||
tabInfo.tabId = addedId | ||
} | ||
} | ||
const tabListener = (_tabId: number) => { | ||
if (_tabId === tabInfo.tabId) { | ||
Browser.tabs.onRemoved.removeListener(tabListener) | ||
Browser.tabs.onReplaced.removeListener(tabReplacedListener) | ||
resolve({ | ||
error: getError(ErrorCodes.userRejected), | ||
}); | ||
}) | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
Browser.tabs.onRemoved.addListener(tabListener) | ||
Browser.tabs.onReplaced.addListener(tabReplacedListener) | ||
}) | ||
} | ||
const executePromise = async (): Promise<InternalOnMessageResponse> => { | ||
const isKeyRingLocked = await sendToBackgroundFromBackground({ | ||
provider: ProviderName.enkrypt, | ||
message: JSON.stringify({ | ||
method: InternalMethods.isLocked, | ||
params: [], | ||
}), | ||
}).then((res) => JSON.parse(res.result as string)); | ||
}).then(res => JSON.parse(res.result as string)) | ||
if (unlockKeyring && isKeyRingLocked) { | ||
const unlockKeyring = await this.getRawResponse( | ||
Browser.runtime.getURL(UNLOCK_PATH), | ||
msg, | ||
tabId | ||
); | ||
tabInfo, | ||
) | ||
if (unlockKeyring.error) { | ||
this.removeTab(tabId); | ||
return unlockKeyring; | ||
this.removeTab(tabInfo.tabId) | ||
return unlockKeyring | ||
} else { | ||
return await this.getRawResponse( | ||
Browser.runtime.getURL(url), | ||
msg, | ||
tabId | ||
).then((res) => { | ||
this.removeTab(tabId); | ||
return res; | ||
}); | ||
tabInfo, | ||
).then(res => { | ||
this.removeTab(tabInfo.tabId) | ||
return res | ||
}) | ||
} | ||
} | ||
return await this.getRawResponse( | ||
Browser.runtime.getURL(url), | ||
msg, | ||
tabId | ||
).then((res) => { | ||
this.removeTab(tabId); | ||
return res; | ||
}); | ||
}; | ||
return Promise.race([monitorTabs(), executePromise()]); | ||
tabInfo, | ||
).then(res => { | ||
this.removeTab(tabInfo.tabId) | ||
return res | ||
}) | ||
} | ||
return Promise.race([monitorTabs(), executePromise()]) | ||
} | ||
} | ||
export default WindowPromise; | ||
export default WindowPromise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ded605f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virus total analysis
chrome:
https://www.virustotal.com/gui/file/0fef292bc383e5409415b5cd1daedcda01d52c62b29b431ce9eb1c381cca5520
firefox:
https://www.virustotal.com/gui/file/f858177d17460c3376308ec9bda1c8f919a0f885178177fac29570a7e80798ea