Skip to main content
Version: Dev (main)

Remote App on Another PC

What You Will Learn​

When to Use It​

Your application already spans two PCs (a simulation server on the QAROS PC and its clients on other PCs) and the part on the other PC should stream into the same QAROS session, without an operator walking over to pair it. The other PC needs QAROS installed; its hub becomes a member of the primary hub. Windows only.

An app cannot obtain a pairing code or an unbound invite for another PC: the grant is the only app-issued way in, and it admits exactly one app.

Build and Run​

 cmake --build --preset x64-windows-debug --target remote_app_onboarding
 # On the primary hub's PC (the app's approval needs "May bring in member hubs"):
 remote_app_onboarding.exe issue | <your encrypted, authenticated channel>
 # On the other PC, first start:
 <your channel> | remote_app_onboarding.exe join
 # On the other PC, every later start:
 remote_app_onboarding.exe start

issue writes the invitation to stdout and refuses to print it on a console, so it never lands on screen or in a terminal log; its messages go to stderr. To try it out by hand, redirect it to a file you delete right after join read it.

Step 1: Issue the Invitation on the Primary's PC​

  init.label = "Remote app example"; /* shown to the primary's operator */
  /* Defaults: valid 24 h, one hub. Keep both as small as your flow allows. */
  grant.app_tag = GRANT_TAG;
  init.header.next = &grant.header;
 
  QarMemberHubInvitation* invitation = NULL;
  QarResult created = qar_runtime_create_member_hub_invitation(runtime, &init, NULL, &invitation);
  report("qar_runtime_create_member_hub_invitation", created);
  {
  fprintf(stderr, "Ask the operator to allow this app to bring in member hubs.\n");
  }
 
  size_t size = 0;
  uint8_t* bytes = NULL;
  if(qar_result_is_success(created))
  {
  if(qar_result_is_success(sized) && size > 0 && size <= MAX_INVITATION_BYTES)
  {
  bytes = (uint8_t*)calloc(1, size);
  }
  else
  {
  report("qar_member_hub_invitation_serialized_size", sized);
  }
  }
  size_t written = 0;
  if(bytes != NULL)
  {
  QarResult serialized =
  qar_member_hub_invitation_serialize(invitation, bytes, size, &written);
  report("qar_member_hub_invitation_serialize", serialized); /* never the bytes */
  /* stdout stands in for your channel to the other PC. */
  if(qar_result_is_success(serialized) && set_binary(stdout)
  && fwrite(bytes, 1, written, stdout) == written && fflush(stdout) == 0)
  {
  exit_code = 0;
  }
  else
  {
  fprintf(stderr, "The invitation was not handed over.\n");
  }
  memset(bytes, 0, size); /* clear the secret before freeing it */
  free(bytes);
  }
  qar_member_hub_invitation_handle_destroy(invitation); /* NULL is ignored */

What the primary hub checks:

  • The calling process is an app it approved (the hub identifies it from Windows, as for a local app: Local App Onboarding). This example joins as a local app first so the user can approve it. Unknown: QAR_STATUS_ONBOARDING_APPROVAL_DENIED.
  • The operator gave that approval the right to bring in member hubs, with quota left: otherwise QAR_STATUS_MEMBER_SPONSOR_NOT_ALLOWED or QAR_STATUS_MEMBER_SPONSOR_QUOTA_EXCEEDED.
  • The hub on this PC is a primary, not a member itself (QAR_STATUS_SESSION_WIDE_ACTION_ON_MEMBER).
  • The grant's tag follows the app tag rules (QAR_STATUS_ARGUMENT_NOT_SUPPORTED otherwise).

The invitation is signed by the primary hub, valid 24 h and for one hub by default (QarMemberHubInvitationInit), and listed in the primary's visualizer, where the operator can revoke it. It is a bearer secret: whoever holds it can join a hub until it expires or is used up. Send it only over an encrypted, authenticated channel, never log it, never put it on a command line.

Step 2: Join the Other PC's Hub as a Member​

  join_init.invitation = invitation; /* borrowed for the call */
  QarResult joined_hub =
  qar_runtime_join_hub_as_member(runtime, &join_init, on_progress, NULL, NULL);
  report("qar_runtime_join_hub_as_member", joined_hub);
  {
  fprintf(stderr, "The join is committed; run join again once the hub is back.\n");
  }
  • This joins the hub of that PC, not the app. The call starts the installed hub when none runs, checks the invitation's signature and expiry, checks that this PC trusts the primary (an administrator's allow-list, else the primary this hub joined first), joins and waits through the hub's restart into the primary's session.
  • Typical failures: QAR_STATUS_MEMBER_INVITATION_EXPIRED, _USED_UP, _REVOKED (ask for a new invitation), _PRIMARY_NOT_ALLOWED (this PC does not trust that primary), QAR_STATUS_PRIMARY_UNREACHABLE, QAR_STATUS_TIMEOUT (the join is committed; calling again succeeds once the hub is back).
  • Called again for the primary it already belongs to, it succeeds at once.

Step 3: Onboard, Redeeming the Grant​

  QarSession* session = NULL;
  QarResult joined = onboard_local(runtime, NULL, invitation, &session);
  report("qar_runtime_onboard (remote app)", joined);
  {
  fprintf(stderr, "The grant already admitted another app, or it was revoked.\n");
  }
  • The first executable that redeems the grant is approved on the primary without a prompt and recorded by its publisher (signed) or file hash (unsigned). A different executable is refused afterwards (QAR_STATUS_ONBOARDING_APPROVAL_DENIED), also with a later invitation of the same app and tag.
  • The primary picks the peer id and remembers it under the grant's tag; no QarOnboardLocalAppTagExt is needed.
  • With a grant, the issuing app's own approval is not extended to the member hub: the grant admits this one app only.

Step 4: Every Later Start​

  QarSession* session = NULL;
  /* No tag needed: the primary remembers a granted app under the grant's
  * tag, whatever tag the app sends. */
  QarResult joined = onboard_local(runtime, NULL, NULL, &session);
  report("qar_runtime_onboard (remote app)", joined);

A plain local onboard: the app is approved now, so no invitation and no prompt are needed, and the primary gives it the same peer id while no other live process holds it.

What Is Stored, and for How Long​

  • Either app: nothing; onboarding ids stay zero.
  • The channel: the invitation, until used up or expired (default one hub, 24 h).
  • The remote app's memory: key and a 30-minute certificate, renewed while it runs, as for any local app.
  • The primary hub: the granted approval (until revoked) and the remembered peer id (until unused for 30 days).

Revoking the issuing app's approval, or the granted one, on the primary revokes the remote app and forgets its peer id.


Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.9.8.