Skip to content

Commit

Permalink
PKG -- [fcl] Respect service method for discovery (#1375)
Browse files Browse the repository at this point in the history
* PKG -- [fcl] Respect service method for discovery

Addresses: #1374

* PKG -- [fcl] Add changeset

Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
  • Loading branch information
2 people authored and huyndo committed Sep 24, 2022
1 parent 8f55114 commit cb75c23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-bears-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/fcl": patch
---

Fix issue where authenticating a Discovery API service would not respect service method.
8 changes: 2 additions & 6 deletions packages/fcl/src/discovery/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ export const makeDiscoveryServices = async () => {
return [...extensionServices, ...serviceRegistry.getServices()]
}

// Certain method types cannot be overridden to use other methods like POP/RCP
const isServiceMethodUnchangable = method =>
["EXT/RPC", "WC/RPC"].includes(method)

export async function getDiscoveryService(service) {
const discoveryAuthnInclude = await config.get("discovery.authn.include", [])
const discoveryWalletMethod = await config.first([
"discovery.wallet.method",
"discovery.wallet.method.default",
])
const method = isServiceMethodUnchangable(service?.method)
const method = service?.method
? service.method
: discoveryWalletMethod || service.method
: discoveryWalletMethod
const endpoint =
service?.endpoint ??
(await config.first(["discovery.wallet", "challenge.handshake"]))
Expand Down

0 comments on commit cb75c23

Please sign in to comment.