Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/extension-base/src/background/handlers/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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;
});

Expand All @@ -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 => {
Expand Down
11 changes: 8 additions & 3 deletions packages/extension-base/src/background/handlers/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props extends ThemeProps {
url: string;
}

function WebsiteEntry ({ className = '', info: { authorizedAccounts }, removeAuth, url }: Props): React.ReactElement<Props> {
function WebsiteEntry ({ className = '', info: { authorizedAccounts, isAllowed }, removeAuth, url }: Props): React.ReactElement<Props> {
const { t } = useTranslation();

const _removeAuth = useCallback(
Expand All @@ -42,7 +42,9 @@ function WebsiteEntry ({ className = '', info: { authorizedAccounts }, removeAut
total: authorizedAccounts.length
}
})
: t('no accounts')
: isAllowed
? t('all accounts')
: t('no accounts')
}</Link>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@
"Account connection request": "",
"Understood": "",
"Ask again later": "",
"no accounts": ""
"no accounts": "",
"all accounts": ""
}