Repository navigation
feat: open protected conversation files in the app (open-protected-file) - #67
Merged
Merged
Conversation
Projects with authenticated conversation files serve them from
files.gleap.io/af/<id> (files.us.gleap.ai in the US), readable only with the
session's file session. A browser does not have it, so a protected file could
not be opened or saved from the app.
- session-update announces capabilities.openProtectedFile; the Messenger sends
open-protected-file {url, name} only to SDKs that announce it.
- GleapProtectedFiles downloads the file on a thread of its own with
X-File-Session as the only credential (no redirect, no cache), only from the
files host of the configured API region (or the local API's own origin),
keeps it in cache/gleap-files and hands it to the app that views its type
through io.gleap.GleapFileProvider (<applicationId>.gleap.files, read-only
grant); the share sheet when no app views it. Only the latest file is kept;
a logout deletes it and drops a download on its way.
- Without a valid file session the file waits for the renewal (the usual
foreground refresh) and opens with the next session update.
- open-url and tapped links to a protected file go the same way instead of to
the browser (403). blob: is a blocked scheme: as an app link it closed the
widget.
Tests: ProtectedFilesTest (unit) and ProtectedFilesE2ETest (emulator, fake
server + widget page: the bridge message and the open-url link start a VIEW
intent with a readable content URI; a blob: link keeps the widget open).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LucaB01
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Projects with authenticated conversation files serve new files from
https://files.gleap.io/af/<id>(files.us.gleap.aiin the US). Only the session's short-lived file session (X-File-Session) can read them. The SDK already holds and refreshes it (GleapFileAccess), but nothing in the app could open such a file:open-urlwith an/af/URL went toACTION_VIEW→ the browser → 403;open-urlwith ablob:URL was handled as an app link and closed the widget.What
session-updateannouncescapabilities.openProtectedFile: true(next toadoptSession). The Messenger sends the newopen-protected-file{ url, name }only to SDKs that announce it, so older SDKs keep today's behaviour.GleapProtectedFiles(new):files.gleap.ioorfiles.us.gleap.aifor the US API, no port/userinfo,/af/<id>or/files/af/<id>; or the local API's own origin in development). The file session is never sent anywhere else;X-File-Session; no redirect is followed and nothing is cached;cache/gleap-files/<uuid>/<name>. The name is the attachment's name, elseContent-Disposition; the extension comes from the type when the name has none;ACTION_VIEWthroughio.gleap.GleapFileProvider(authority${applicationId}.gleap.files, read-only grant, its own subclass so it never clashes with an app'sFileProvider). If no app views the type, it opens theACTION_SENDshare sheet instead (save to Files or Drive, send);clearIdentitydeletes it and drops a download on its way;session-update.open-urland links tapped in the widget page that point to a protected file take the same path instead of the browser.blob:is now a blocked scheme (GleapExternalLinks): never opened, never closes the widget.Apps without protected files see no change: no
/af/URLs exist for them. The only addition they get is the new capability flag, which the Messenger ignores unless a file is protected.Tests
ProtectedFilesTest(unit, 11 tests): region/host rules, the request headers (token only, no redirects), names and types, waiting for a file session, other URLs never get the token, a 403 shows nothing and keeps nothing, only the latest file is shown, logout drops files, the capability flag,blob:blocked.ProtectedFilesE2ETest(emulator, Pixel 6 Pro API 34, fake server and widget page from the existing e2e harness):open-protected-filedownloads with the file session and starts aVIEWintent whosecontent://<pkg>.gleap.files/...URI is readable, has the read grant and has the right type and name;open-urlto the file does the same and never reaches the browser;open-urlwithblob:keeps the widget open../gradlew :gleap:testDebugUnitTest :gleap:assembleRelease: 271 tests, all pass.connectedDebugAndroidTest(ProtectedFilesE2ETest + WidgetLifecycleE2ETest): 4 of 4 pass.Not verified: a real third-party viewer app opening the file (the e2e test catches the intent instead of launching one), and the share-sheet fallback (no device without a viewer was tried).
Rollout
🤖 Generated with Claude Code