Repository navigation
feat(deeplink): look up only links on the workspace's link hosts, and name the app on every request - #16
Merged
Conversation
…app token With an appToken, every request carries X-LinkForty-App-Token, and initialize() fetches the workspace's link domains in the background (GET /api/sdk/v1/link-domains), storing them on the device: a 200 replaces the list, a 400 or 404 clears it, any other failure keeps it. handleDeepLink(uri) returns whether it looks the URI up. A web URI on a link domain or on the baseURL host is resolved on the server, as is any web URI while the domains are unknown. A custom-scheme URI, and a web URI on another host once the domains are known, make no request; onDeepLink receives the URI's own parameters. A link held before initialize() waits up to 3 seconds for the first domain fetch on a launch with no stored list.
…space's link is not resolved Shared harness: a URL on a host that is not a link host and a custom-scheme URL make no lookup and reach onDeepLink with their own parameters; another workspace's link is not resolved for this app; a link opened while the app runs reports handled = true.
Merged
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.
Summary
Pass every URI that opens the app to
handleDeepLink; the SDK now decides which are LinkForty links.appToken, every request carriesX-LinkForty-App-Token, so a server that supports it answers with the app's own workspace's links only.appToken,initialize()fetches the workspace's link hosts fromGET /api/sdk/v1/link-domainsin the background (not blocking the install report) and stores them on the device (com.linkforty.sdk.linkDomains). A 200 replaces the list, a 400/404 clears it, any other failure keeps it. A stored list is used at once on later launches.handleDeepLink(uri): Boolean.truewhen the URI is looked up as a LinkForty link:http/https) URI whose host (case-insensitive, port ignored) is thebaseURLhost or a known link domain → resolved on the server, as before;myapp://…) → no request;onDeepLinkreceives the URI's own parameters (nolinkId), the same data a failed lookup delivered.initialize()is held as before. On a launch with no stored domain list it waits up to 3 seconds for the domain fetch, then is decided against what is known; with a stored list (or no app token) it is decided at once. A held URI returnstruefor a web URI.Behavior change
https://acme.com/settings/abc) could match another link's short code and receive its data.handleDeepLink's return type changed fromUnittoBoolean. Kotlin and Java callers compile unchanged; a library compiled against 1.5.x that calls it must be recompiled.Both are listed under Changed in the CHANGELOG.
Server
Uses the resolve endpoint's app-token scoping (
X-LinkForty-App-Token,@linkforty/corewith header scoping) and the link-domains endpoint on LinkForty Cloud. Against a server without them, the header is ignored and the domain fetch fails, so the domains stay unknown and every web URI is looked up, as before; custom-scheme URIs still make no request.Tests
LinkDomainsTest(14): the host rule (known domains,baseURLhost, other hosts, unknown domains, custom schemes, case and port); the fetched list lower-cased and stored; a stored list used before any fetch; 404/400 clear it, a network error or 5xx keeps it; the header present only with anappToken; the handler resolves a link with one request and makes none for another web URI or a custom scheme, delivering the local parse.LinkDomainsFlowTest: after the domain fetch,https://acme.com/…andmyapp://…returnfalsewith no resolve request andhttps://links.acme.com/abc123returnstrueand resolves, every request carrying the token; a link held beforeinitialize()with a slow (1 s) domain fetch is decided against the fetched list.e2e/run.mjs, emulator + Chrome, local server with the scoping and link-domains endpoints): 86 passed, 0 failed. New shared scenarios: a URL on another host is not looked up; a custom-scheme URL is not looked up; another workspace's link is not resolved for this app; a link opened while the app runs reportshandled = true.Decisions
appToken: no domain fetch, held links are decided at once, and every web URI is looked up as before.clearData()keeps the stored domain list: it describes the workspace, not the user.