Skip to content

Commit

Permalink
Recognize know dapps by authOrigins (#1669)
Browse files Browse the repository at this point in the history
This extends the matching logic for known dapps to take into account the
newly added field `authOrigins` from the portal's showcase.

dfinity/portal#1533
  • Loading branch information
nmattia authored Jun 6, 2023
1 parent 9ae0748 commit ef55a29
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/update-dapps
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function update() {
| with_entries(
select(
[.key]
| inside(["name", "website", "oneLiner", "logo"])
| inside(["name", "website", "oneLiner", "logo", "authOrigins"])
)
)
]' \
Expand Down
10 changes: 9 additions & 1 deletion src/frontend/src/flows/authorize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ export const authFlowAuthorize = async (
derivationOrigin: authContext.authRequest.derivationOrigin,
i18n,
knownDapp: getDapps().find(
(dapp) => new URL(dapp.website).origin === authContext.requestOrigin
// It's a known dapp if, for any known dapp, the request origin matches
// * the website
// * any (some) of the authOrigins
(dapp) =>
authContext.requestOrigin === new URL(dapp.website).origin ||
(dapp.authOrigins ?? []).some(
(authOrigin) =>
authContext.requestOrigin === new URL(authOrigin).origin
)
),
})
);
Expand Down
13 changes: 11 additions & 2 deletions src/frontend/src/flows/dappsExplorer/dapps.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
{
"name": "distrikt",
"oneLiner": "Censorship-resistant fully on-chain social media platform",
"website": "https://az5sd-cqaaa-aaaae-aaarq-cai.ic0.app/",
"website": "https://distrikt.app",
"authOrigins": [
"https://distrikt.app",
"https://az5sd-cqaaa-aaaae-aaarq-cai.ic0.app/"
],
"logo": "distrikt_logo.webp"
},
{
Expand All @@ -21,6 +25,7 @@
"name": "Juno",
"oneLiner": "Build Web3 Apps Like It's Web2",
"website": "https://juno.build",
"authOrigins": ["https://console.juno.build"],
"logo": "juno_logo.svg"
},
{
Expand Down Expand Up @@ -48,7 +53,11 @@
},
{
"name": "TAGGR",
"website": "https://6qfxa-ryaaa-aaaai-qbhsq-cai.ic0.app/#/",
"website": "https://taggr.link",
"authOrigins": [
"https://taggr.link",
"https://6qfxa-ryaaa-aaaai-qbhsq-cai.ic0.app"
],
"logo": "taggr_logo.webp",
"oneLiner": "Blending forums and blogs - controlled by a DAO"
},
Expand Down

0 comments on commit ef55a29

Please sign in to comment.