Share your package

Publish under an organization, and link a second server so it can install the package.

Chapter 4 of 4 · about 4 minutes

In this chapter we will make an organization, publish our application under it, and link a second server so it can install the package too. By the end, exampleco-hello will install on that server, and on no one else's.

A package we publish as a developer installs only on our own license. An organization's packages install on the licenses of its members and of the servers linked to it.

Make an organization

From the shell in the nextweb-tour folder:

At the nextweb prompt
pkg org create exampleco
You should see
Created organization exampleco; you are its owner.
Build for it with "owner": "exampleco" in .nextwebrc; its packages are named exampleco-<name>.

An organization's handle comes from the same pool as developer handles, so it has to differ from ours.

Build for it

Add an owner line at the top of hello/.nextwebrc:

hello/.nextwebrc
{
  "owner": "exampleco",
  "type": "application",

Then open the shell from the hello folder again, and build and publish under the organization's name:

At the nextweb prompt
pkg create exampleco-hello 0.1.0
You should see
Building exampleco-hello 0.1.0 for exampleco (internal)...
Built and registered dist/exampleco-hello_0.1.0_all.zip.enc
  owner        exampleco (organization, you are owner)
  files        1; source not encrypted
  package key  akek-47e612454fee
  sha256       c96f81d411d5f4edbe862e984bc58441714b1f164f257a4ac61a0de59ee089f2
  size         1453 bytes
Next: pkg validate, then pkg publish.
At the nextweb prompt
pkg publish
You should see
note: no VM check report for this file (optional: pkg validate --vm)
Publishing exampleco-hello-0.1.0-all to https://cdn.nextwebjs.com...
Published: exampleco-hello-0.1.0-all (1453 bytes, sha256 c96f81d411d5f4edbe862e984bc58441714b1f164f257a4ac61a0de59ee089f2)
It installs on the licenses of exampleco's members and its linked servers: pkg install exampleco-hello

The package key is the organization's now, not ours. The last line names who can install it.

Invite a server

A server joins with a one-time token. We make one here:

At the nextweb prompt
pkg org license invite exampleco
You should see
A one-time token for exampleco, valid until 2026-10-20 (shown once):
  nwj_jNNDFug0agb-NXavQHx3owvrs0jQeNjC
On the server to link, run: pkg org join <token> -y

Copy the token now: it is shown once, and it works once.

Join from the other server

On the second server, Nextweb is installed and started as in Open Nextweb, with a license of its own. Before it joins, our package doesn't install there:

At the nextweb prompt
pkg install exampleco-hello
You should see
...
Installing exampleco-hello...
Installation failed: exampleco-hello 0.1.0 cannot be installed on this license: key release refused (NOT_AUTHORIZED): This package is internal to exampleco: it installs only on licenses of its members and linked servers.

Joining is a command from the packaging tools, so the server installs them first:

At the nextweb prompt
pkg install nextweb-dev
You should see
...
nextweb-dev 0.1.3 installed successfully

Then it joins with the token:

At the nextweb prompt
pkg org join nwj_jNNDFug0agb-NXavQHx3owvrs0jQeNjC
You should see
Joining links this server's license to the organization: its internal packages will install
here, and they run as the user Nextweb runs as (often root under systemd).
Run again with -y to join.

Read that before saying yes: a linked server runs whatever the organization publishes for it, with the same rights as Nextweb itself.

At the nextweb prompt
pkg org join nwj_jNNDFug0agb-NXavQHx3owvrs0jQeNjC -y
You should see
This license (98dd7737de88) is linked to exampleco; its internal packages install here.
At the nextweb prompt
pkg install exampleco-hello
You should see
Resolving dependencies...
   Architecture: x64 (auto-detected)
Installation order: exampleco-hello


Installing 1 package(s)...

Installing exampleco-hello...
exampleco-hello 0.1.0 installed successfully

From here, the server deploys it exactly as we did in Deploy your application.

When a server should stop receiving the organization's packages, its owner unlinks it by the fingerprint the join printed. Back in the nextweb-tour shell:

At the nextweb prompt
pkg org license remove exampleco 98dd7737de88
You should see
Unlinked 98dd7737de88 from exampleco. Its cached keys run out within 7 days; nothing new installs there.

What the server already installed stays there. Nothing of the organization's installs there from now on.

What we have now

An organization that owns our package, and a way to let a server install it and to take that back. People join an organization the same way, with pkg org invite, each as an owner, a publisher, or a member.