Creating a Webnative session


A session is an authenticated interaction between a user and a Webnative program. Sessions are typically long-lived and are based on a user controlling a key pair.

Webnative authenticates and authorizes a user who controls a key pair through:

  • WebCrypto. The browser WebCrypto API which supports non-exportable private keys.

  • WalletAuth. A browser extension that supports blockchain wallets through the Webnative WalletAuth plugin.

  • Requesting capabilities. Uses a WebCrypto key pair, but authorization must be requested from another app with equal or greater authority.

Creating a session

A session can be created through an Authentication Strategy or by Requesting Capabilities. We'll look at each of these approaches in upcoming sections, but for now here is the Session class they create:

export class Session {
  #crypto: Crypto.Implementation
  #storage: Storage.Implementation

  fs?: FileSystem
  type: string
  username: string

A session includes a session type, username, and an optional filesystem.

The private crypto and storage fields are internal and can be ignored, but they give us an early hint of the Webnative component system described in the Components section.

Session Type

The session type indicates how the session was created. The possible types include webCrypto and capabilities.

WalletAuth uses a blockchain wallet but delegates to a WebCrypto key pair. As a result, the session type when using WalletAuth is webCrypto.


A username selected by the user at registration. When requesting capabilities, the user will already have a username from the app where they originally registered.

The username is a wallet address when using WalletAuth.


A WNFS instance. A filesystem is provided by default, but Webnative can be configured without WNFS through the Components API.

Last updated