You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validating activity sessions are via a Discord client before adding them to an instance's session.
92
+
</Card>
90
93
</Container>
91
94
92
95
## Assets & Metadata
@@ -828,6 +831,29 @@ This example is being done entirely on the client, however, a more common patter
828
831
829
832
---
830
833
834
+
### Preventing unwanted activity sessions
835
+
836
+
Activities are surfaced through iframes in the Discord app. The activity website itself is publicly reachable at `<application_id>.discordsays.com`. Activities will expect to be able to communicate with Discord's web or mobile client via the Discord SDK's RPC protocol. If a user loads the activity's website in a normal browser, the Discord RPC server will not be present, and the activity will likely fail in some way.
837
+
838
+
It is theoretically possible for a malicious client to mock Discord's RPC protocol or load one activity website when launching another. Because the activity is loaded inside Discord, the RPC protocol is active, and the activity is none the wiser.
839
+
840
+
To enable an activity to "lock down" activity access, we encourage utilizing the `activity instances` API, found at `discord.com/api/applications/<application_id>/instances/<channel_id>`. The route requires a Bot token of the application. It returns a list of active activity instances for the given application in the given channel (at the moment, the list will always either be of length 0 or length 1, as we do not allow multiple instances of the same activity). Here are two example responses:
With this API, the activity's backend can verify that a client is in fact in an instance of that activity, in a specific channel, before allowing the client to participate in any meaningful gameplay. How an activity implement's "session verification" is up to them. The solution can be as granular as gating specific features or as binary as not returning the activity HTML except for valid sessions.
851
+
852
+
In the below flow diagram, we show how server can deliver the activity website, only for valid users in a valid activity session
0 commit comments