Skip to content

Commit

Permalink
Add discovery.authn.exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Aug 27, 2024
1 parent 5206275 commit 9530704
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .changeset/shiny-pumas-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@onflow/fcl-core": minor
---

Allow apps to exclude certain wallets from FCL Discovery.

```javascript
import { config } from "@onflow/fcl";

// Include supports discovery.wallet or discovery.authn.endpoint
config({
"discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn",
"discovery.authn.endpoint":
"https://fcl-discovery.onflow.org/api/testnet/authn",
"discovery.authn.exclude": ["0x123"], // Exclude a wallet by address
});
```
2 changes: 2 additions & 0 deletions packages/fcl-core/src/current-user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ async function getAccountProofData() {

const makeConfig = async ({
discoveryAuthnInclude,
discoveryAuthnExclude,
discoveryFeaturesSuggested,
}) => {
return {
client: {
discoveryAuthnInclude,
discoveryAuthnExclude,
discoveryFeaturesSuggested,
clientServices: await makeDiscoveryServices(),
supportedStrategies: getServiceRegistry().getStrategies(),
Expand Down
2 changes: 2 additions & 0 deletions packages/fcl-core/src/discovery/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function getServices({types}) {
)

const include = await config.get("discovery.authn.include", [])
const exclude = await config.get("discovery.authn.exclude", [])
const url = new URL(endpoint)

return fetch(url, {
Expand All @@ -25,6 +26,7 @@ export async function getServices({types}) {
type: types,
fclVersion: VERSION,
include,
exclude,
features: {
suggested: await config.get("discovery.features.suggested", []),
},
Expand Down
2 changes: 2 additions & 0 deletions packages/fcl-core/src/discovery/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const makeDiscoveryServices = async () => {

export async function getDiscoveryService(service) {
const discoveryAuthnInclude = await config.get("discovery.authn.include", [])
const discoveryAuthnExclude = await config.get("discovery.authn.exclude", [])
const discoveryFeaturesSuggested = await config.get(
"discovery.features.suggested",
[]
Expand Down Expand Up @@ -36,6 +37,7 @@ export async function getDiscoveryService(service) {
endpoint,
method,
discoveryAuthnInclude,
discoveryAuthnExclude,
discoveryFeaturesSuggested,
}
}

0 comments on commit 9530704

Please sign in to comment.