Documentation Home
v1.22 v1.23
v1.22 v1.23

Web extensions

A web extension is a web app (HTML, JavaScript, CSS) that XR Center hosts for you. Users open it in their browser at https://<xrcenter>/apps/<mount>/, sign in with their XR Center account, and the app works with XR Center data through its API. Any framework that builds to static files works: Angular, React, Vue or plain JavaScript.

How it works

Web extension lifecycle
  1. You build your app and zip it with a .skrmanifest file into a .skrmkt package.

  2. An administrator uploads the package to the XR Center Marketplace.

  3. XR Center extracts it and serves it under /apps/<mount>/. Your app is on the same origin as the API: no CORS setup is needed.

Anatomy of a package

A .skrmkt file is a zip archive. Its root holds:

File

Role

index.html and your built assets

The output of your build (for example the dist folder).

<name>.skrmanifest

Describes the package for the Marketplace and tells XR Center where to mount it.

The manifest

JSON
{
  "Name": "my-web-app",
  "DisplayName": "My Web App",
  "Description": "Dashboard of my workspaces",
  "Version": "1.0.0",
  "Author": "My company",
  "TargetPlatform": "WebExtension",
  "PlatformVersion": "1.24",
  "PackageDependencies": {},
  "PackageMetadatas": {
    "LoadMountPoint": "my-web-app",
    "EntryPoint": "index.html"
  }
}

Field

Role

Name

Unique name of the package.

Version

Version of your app. Upload a higher version to update it.

TargetPlatform

Always WebExtension.

PlatformVersion

The XR Center version your app targets, as major.minor. XR Center only mounts packages whose major and minor versions match its own.

LoadMountPoint

The <mount> part of the URL: one path segment, without /. Each mount point can only be used by one extension. Without it, the package is not mounted.

EntryPoint (optional)

The page served for every route of your app. Default: index.html.

IsEnabledByDefault (optional)

Set it to false in PackageMetadatas to upload the package without mounting it.

Build your app for XR Center

Your app is served under /apps/<mount>/, and it does not know the address of the XR Center it runs on. Two things handle this:

  1. Base path: build your app with /apps/<mount>/ as its base path, for example ng build --base-href /apps/my-web-app/ with Angular, or base in Vite.

  2. env.js: load env.js before your app. XR Center generates this file for each extension. It sets window.env.BASE_URL (the XR Center address, to use for the API and the sign-in) and window.env.CLIENT_ROOT (the address of your app, ending with /).

HTML
<head>
  <base href="/apps/my-web-app/">
  <script src="env.js"></script>
</head>

XR Center serves your routes too: any URL under /apps/<mount>/ that is not a file returns your entry point, so client-side routing works on reload.

XR Center never caches .html files, but caches the other files for one year. Use hashed file names for your assets (the default of most build tools) so that users get the new files after an update.

Sign users in

XR Center is an OpenID Connect provider. Use any OIDC library (for example angular-auth-oidc-client or oidc-client-ts) with the authorization code flow and PKCE:

JavaScript
{
  authority: window.env.BASE_URL,
  clientId: 'my-web-app',
  redirectUrl: window.env.CLIENT_ROOT + 'signin-callback',
  postLogoutRedirectUri: window.env.CLIENT_ROOT + 'logout-callback',
  responseType: 'code',
  scope: 'openid profile roles xrcenter offline_access'
}

The client ID must be declared in the XR Center configuration (xrcenter.json, section IdentityFederation › ClientApplications). Ask your XR Center administrator to add it, then restart XR Center:

JSON
{
  "ClientId": "my-web-app",
  "GrantTypes": [ "authorization_code" ],
  "RequirePkce": true,
  "AllowOfflineAccess": true,
  "RedirectUris": [],
  "LogoutRedirectUris": []
}

You don't need to list the redirect URLs of your extension: XR Center accepts /apps/<mount>/signin-callback and /apps/<mount>/logout-callback for every mounted extension.

Call the XR Center API

Send the access token in the Authorization: Bearer <token> header of your requests to window.env.BASE_URL. The API only returns what the signed-in user is allowed to see. To browse the API and generate a typed client, see XR Center Swagger.

Develop locally

Run your dev server (for example http://localhost:4200) against a test XR Center:

  • Your dev server doesn't receive the generated env.js: serve your own, with BASE_URL set to the XR Center address and CLIENT_ROOT to http://localhost:4200/.

  • Add http://localhost:4200/signin-callback and http://localhost:4200/logout-callback to the RedirectUris and LogoutRedirectUris of your client.

  • Your app is no longer on the same origin as the API: add http://localhost:4200 to the CORS origins of XR Center (Kestrel › CorsOrigins).

Deploy and update

  1. Zip the content of your build folder, with the .skrmanifest at the root, and name the archive <name> <version>.skrmkt.

  2. In the XR Center administration, open Marketplace and upload the file.

  3. XR Center mounts the latest compatible version of your package right away. Open https://<xrcenter>/apps/<mount>/.

To update, upload a higher version: XR Center switches to it without interruption and deletes the old files. To remove the extension, delete the package from the Marketplace. If your app doesn't show up, check the XR Center logs for a message about your package (incompatible version, missing mount point, mount point already in use).