A wallet approval is a one-time event. The signed result has to reach a process that may not be listening when the user clicks approve, and the wallet should not have to retry until that process appears.
Glyph Relay is a short-lived mailbox between the two. The app creates a session, gives the wallet only a callback URL, and reads the result from a separate URL. The read capability stays inside the app.
The session model
- A Durable Object per session
- Read and callback capabilities are separate
- One accepted result per session
- SSE streaming or polling
Each session runs in its own Durable Object. prepareRelaySession() registers the callback and read capabilities with the official relay before the wallet opens. The callback capability goes into the request envelope. The read capability stays in the dApp and is used by the subscription or the polling call.
A result is accepted once. The relay stores it for up to ten minutes, the SSE wait is five minutes, and a session supports at most five listeners. A second callback for the same session is rejected.
Prepare, subscribe, launch
import {
createEnvelope,
launchGlyphRequest,
prepareRelaySession,
subscribeViaRelayV2,
} from "@glyph-oss/connect";
const session = await prepareRelaySession();
const envelope = createEnvelope(request, { callback: session.callbackUrl });
const resultPromise = subscribeViaRelayV2(request, session, {
requestHash: envelope.request_hash,
verification: {
requireSigned: true,
verifySignature: schnorrqVerify,
},
});
launchGlyphRequest(envelope);
const result = await resultPromise;
The subscription uses session.streamUrl. The wallet receives session.callbackUrl, which carries a different capability. Pass a Qubic SchnorrQ verifier as verifySignature; the SDK checks the envelope binding before it calls that function.
Read without SSE
A server can poll session.resultUrl when a stream does not fit the deployment. Before a result arrives, the relay returns 404 with a pending status. After delivery, it returns the result.
const response = await fetch(session.resultUrl);
if (response.status === 404) {
return { status: "pending" };
}
return response.json();
Polling does not remove the signature check. The result still has to pass the same envelope and binding verification as an SSE result.
One session per request
- 1Create the request with a Connect builder.
- 2Prepare a relay session and put callbackUrl into the envelope.
- 3Subscribe with the session before you launch the wallet.
- 4Consume one result, store what the app needs, and create a fresh session for the next request.
The relay is a delivery mechanism, not a queue and not a database. A result that arrives after the window is gone cannot be recovered. Write the result to the app’s own storage as soon as it is read.
Relay v2 guideThe session lifecycle, capabilities, and transport details. Glyph Relay sourceThe Durable Object service on GitHub.