From 05c8048cbcbb8819772fe3b5757e12d17600a457 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 22:53:57 +0000 Subject: [PATCH 1/3] Document freighter-api disconnect method Add a disconnect section to the connecting guide and a playground page. The playground needs index.html to load a freighter-api release that includes disconnect. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01M6pbgqeBtJ7cL5biPuxBJ1 --- _sidebar.md | 1 + extension/connecting.md | 28 +++++++++++++++++++++++++- extension/playground/disconnect.md | 32 ++++++++++++++++++++++++++++++ playgrounds-home.md | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 extension/playground/disconnect.md diff --git a/_sidebar.md b/_sidebar.md index 6e4d84d..a4f7702 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -6,6 +6,7 @@ * [isAllowed](extension/playground/isAllowed.md) * [setAllowed](extension/playground/setAllowed.md) * [requestAccess](extension/playground/requestAccess.md) +* [disconnect](extension/playground/disconnect.md) * [getAddress](extension/playground/getAddress.md) * [getNetwork](extension/playground/getNetwork.md) * [getNetworkDetails](extension/playground/getNetworkDetails.md) diff --git a/extension/connecting.md b/extension/connecting.md index fa69097..0e8e524 100644 --- a/extension/connecting.md +++ b/extension/connecting.md @@ -1,6 +1,6 @@ # Connecting to Freighter -Detect whether a user has Freighter installed, check if your app is authorized, and request access to the user's public key. +Detect whether a user has Freighter installed, check if your app is authorized, request access to the user's public key, and disconnect. ## Detecting Freighter @@ -96,6 +96,32 @@ if (accessResult.error) { Always check `isConnected()` before calling `requestAccess()` to ensure the extension is available. {% endhint %} +## Disconnecting + +### `disconnect()` + +Revoke your app's access to the user's public key, for example from a "Disconnect" button in your app. Freighter removes your app from the Allow List without asking the user to confirm, so the next call to `requestAccess()` or `setAllowed()` prompts the user again. + +**Returns:** `Promise<{ error?: FreighterApiError }>` + +```typescript +import { disconnect } from "@stellar/freighter-api"; + +const result = await disconnect(); + +if (result.error) { + console.error("Disconnect failed:", result.error.message); +} else { + console.log("App removed from Allow List"); +} +``` + +Calling `disconnect()` when your app isn't on the Allow List succeeds without changing anything. It returns an error if the wallet is locked, or if the installed version of Freighter doesn't support `disconnect()`. + +{% hint style="warning" %} +Freighter authorizes apps per account and per network, and `disconnect()` only revokes access for the account and network that are active when you call it. If the user previously authorized your app on another account or network, your app will have access to that public key again, without a prompt, when the user switches to it. +{% endhint %} + ## Next steps Once connected, you can [read the user's address and network](reading-data.md) or [sign transactions](signing.md). diff --git a/extension/playground/disconnect.md b/extension/playground/disconnect.md new file mode 100644 index 0000000..d728007 --- /dev/null +++ b/extension/playground/disconnect.md @@ -0,0 +1,32 @@ +# disconnect + +`disconnect()` + +Test Freighter's `disconnect` method: + +**Remove this app from Freighter's Allow List for the active account and network.** + + + +
Click the button to test
+ + diff --git a/playgrounds-home.md b/playgrounds-home.md index 8647359..0d619f5 100644 --- a/playgrounds-home.md +++ b/playgrounds-home.md @@ -17,6 +17,7 @@ For docs and integration guides, see [docs.freighter.app](https://docs.freighter | [isAllowed](extension/playground/isAllowed.md) | Check if your app is authorized | | [setAllowed](extension/playground/setAllowed.md) | Request authorization for your app | | [requestAccess](extension/playground/requestAccess.md) | Request the user's public key | +| [disconnect](extension/playground/disconnect.md) | Revoke your app's access | | [getAddress](extension/playground/getAddress.md) | Get the user's wallet address | | [getNetwork](extension/playground/getNetwork.md) | Get the active network | | [getNetworkDetails](extension/playground/getNetworkDetails.md) | Get full network configuration | From dcfaee9fe7a03f27ebb4513695ec2858c0cac80f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 15:55:59 +0000 Subject: [PATCH 2/3] Clarify when disconnect returns a locked error An idle lock keeps the active account, so disconnect works then. It only fails before the first unlock after the browser starts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01M6pbgqeBtJ7cL5biPuxBJ1 --- extension/connecting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/connecting.md b/extension/connecting.md index 0e8e524..ecb9697 100644 --- a/extension/connecting.md +++ b/extension/connecting.md @@ -116,7 +116,7 @@ if (result.error) { } ``` -Calling `disconnect()` when your app isn't on the Allow List succeeds without changing anything. It returns an error if the wallet is locked, or if the installed version of Freighter doesn't support `disconnect()`. +Calling `disconnect()` when your app isn't on the Allow List succeeds without changing anything. It returns an error if the user hasn't unlocked Freighter since the browser started, or if the installed version of Freighter doesn't support `disconnect()`. {% hint style="warning" %} Freighter authorizes apps per account and per network, and `disconnect()` only revokes access for the account and network that are active when you call it. If the user previously authorized your app on another account or network, your app will have access to that public key again, without a prompt, when the user switches to it. From 186562a672afd46b40f9dfe5df0e2609235d8891 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 16:18:45 +0000 Subject: [PATCH 3/3] Show a clear error when disconnect isn't loaded index.html loads a freighter-api version without disconnect() until the next release. Show that cause instead of a TypeError. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01M6pbgqeBtJ7cL5biPuxBJ1 --- extension/playground/disconnect.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extension/playground/disconnect.md b/extension/playground/disconnect.md index d728007..0322717 100644 --- a/extension/playground/disconnect.md +++ b/extension/playground/disconnect.md @@ -15,6 +15,11 @@ document.getElementById('btn-disconnect').addEventListener('click', async functi var el = document.getElementById('result-disconnect'); el.className = 'playground-result'; el.textContent = 'Disconnecting...'; + if (typeof window.freighterApi.disconnect !== 'function') { + el.className = 'playground-result error'; + el.textContent = 'Error: the loaded version of @stellar/freighter-api does not include disconnect()'; + return; + } try { var res = await window.freighterApi.disconnect(); if (res.error) {