diff --git a/packages/extension-base/src/background/handlers/State.ts b/packages/extension-base/src/background/handlers/State.ts index 8f74dca5dc2..b7b1696a612 100644 --- a/packages/extension-base/src/background/handlers/State.ts +++ b/packages/extension-base/src/background/handlers/State.ts @@ -35,6 +35,8 @@ export type AuthorizedAccountsDiff = [url: string, authorizedAccounts: AuthUrlIn export interface AuthUrlInfo { count: number; id: string; + // this is from pre-0.44.1 + isAllowed?: boolean; origin: string; url: string; authorizedAccounts: string[]; @@ -355,9 +357,6 @@ export default class State { public updateAuthorizedAccounts (authorizedAccountDiff: AuthorizedAccountsDiff): void { authorizedAccountDiff.forEach(([url, authorizedAccountDiff]) => { - // this url was never seen in the past - assert(this.#authUrls[url].authorizedAccounts, `The source ${url} has never been authorized to interact with this extension`); - this.#authUrls[url].authorizedAccounts = authorizedAccountDiff; }); @@ -368,19 +367,20 @@ export default class State { const idStr = this.stripUrl(url); // Do not enqueue duplicate authorization requests. - const isDuplicate = Object.values(this.#authRequests) + const isDuplicate = Object + .values(this.#authRequests) .some((request) => request.idStr === idStr); assert(!isDuplicate, `The source ${url} has a pending authorization request`); if (this.#authUrls[idStr]) { // this url was seen in the past - assert(this.#authUrls[idStr].authorizedAccounts, `The source ${url} is not allowed to interact with this extension`); + assert(this.#authUrls[idStr].authorizedAccounts || this.#authUrls[idStr].isAllowed, `The source ${url} is not allowed to interact with this extension`); - return ({ + return { authorizedAccounts: [], result: false - }); + }; } return new Promise((resolve, reject): void => { diff --git a/packages/extension-base/src/background/handlers/Tabs.ts b/packages/extension-base/src/background/handlers/Tabs.ts index ad145703b53..4932ba59b23 100644 --- a/packages/extension-base/src/background/handlers/Tabs.ts +++ b/packages/extension-base/src/background/handlers/Tabs.ts @@ -43,10 +43,15 @@ export default class Tabs { } private filterForAuthorizedAccounts (accounts: InjectedAccount[], url: string): InjectedAccount[] { + const auth = this.#state.authUrls[this.#state.stripUrl(url)]; + return accounts.filter( - (allAcc) => this.#state.authUrls[this.#state.stripUrl(url)] - .authorizedAccounts - .includes(allAcc.address) + (allAcc) => + auth.authorizedAccounts + // we have a list, use it + ? auth.authorizedAccounts.includes(allAcc.address) + // if no authorizedAccounts and isAllowed return all - these are old converted urls + : auth.isAllowed ); } diff --git a/packages/extension-ui/src/Popup/AuthManagement/WebsiteEntry.tsx b/packages/extension-ui/src/Popup/AuthManagement/WebsiteEntry.tsx index 1e5c264d38e..6b7b260dd02 100644 --- a/packages/extension-ui/src/Popup/AuthManagement/WebsiteEntry.tsx +++ b/packages/extension-ui/src/Popup/AuthManagement/WebsiteEntry.tsx @@ -18,7 +18,7 @@ interface Props extends ThemeProps { url: string; } -function WebsiteEntry ({ className = '', info: { authorizedAccounts }, removeAuth, url }: Props): React.ReactElement { +function WebsiteEntry ({ className = '', info: { authorizedAccounts, isAllowed }, removeAuth, url }: Props): React.ReactElement { const { t } = useTranslation(); const _removeAuth = useCallback( @@ -42,7 +42,9 @@ function WebsiteEntry ({ className = '', info: { authorizedAccounts }, removeAut total: authorizedAccounts.length } }) - : t('no accounts') + : isAllowed + ? t('all accounts') + : t('no accounts') } ); diff --git a/packages/extension/public/locales/en/translation.json b/packages/extension/public/locales/en/translation.json index 4b355e804b2..5e8aa67dabc 100644 --- a/packages/extension/public/locales/en/translation.json +++ b/packages/extension/public/locales/en/translation.json @@ -172,5 +172,6 @@ "Account connection request": "", "Understood": "", "Ask again later": "", - "no accounts": "" + "no accounts": "", + "all accounts": "" }