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
-
You build your app and zip it with a
.skrmanifestfile into a.skrmktpackage. -
An administrator uploads the package to the XR Center Marketplace.
-
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 |
|---|---|
|
|
The output of your build (for example the |
|
|
Describes the package for the Marketplace and tells XR Center where to mount it. |
The manifest
{
"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 |
|---|---|
|
|
Unique name of the package. |
|
|
Version of your app. Upload a higher version to update it. |
|
|
Always |
|
|
The XR Center version your app targets, as |
|
|
The |
|
|
The page served for every route of your app. Default: |
|
|
Set it to |
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:
-
Base path: build your app with
/apps/<mount>/as its base path, for exampleng build --base-href /apps/my-web-app/with Angular, orbasein Vite. -
env.js: load
env.jsbefore your app. XR Center generates this file for each extension. It setswindow.env.BASE_URL(the XR Center address, to use for the API and the sign-in) andwindow.env.CLIENT_ROOT(the address of your app, ending with/).
<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:
{
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:
{
"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, withBASE_URLset to the XR Center address andCLIENT_ROOTtohttp://localhost:4200/. -
Add
http://localhost:4200/signin-callbackandhttp://localhost:4200/logout-callbackto theRedirectUrisandLogoutRedirectUrisof your client. -
Your app is no longer on the same origin as the API: add
http://localhost:4200to the CORS origins of XR Center (Kestrel›CorsOrigins).
Deploy and update
-
Zip the content of your build folder, with the
.skrmanifestat the root, and name the archive<name> <version>.skrmkt. -
In the XR Center administration, open Marketplace and upload the file.
-
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).