Sessions
The functions that open and close a user's private account, and the stores that keep its unlock signature.
A session is the user's private account, opened on this device. Sessions walks through opening one, switching wallets and signing out.
openNimbusSession
Use it after the wallet connects, to unlock the user's private account.
function openNimbusSession(
sdk: NimbusSdk,
args: { readonly connectedWallet: WalletStandardSigner },
options?: OpenNimbusSessionOptions,
): Promise<OpenNimbusSessionResult>;Types used: NimbusSdk, WalletStandardSigner, OpenNimbusSessionOptions, OpenNimbusSessionResult
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSdk, WalletStandardSigner } from "@umbra/nimbus-solana-web";
declare const : NimbusSdk;
declare const : WalletStandardSigner;
declare const : (: string) => <string>;
const = await (
,
{ },
{ : async () => (..) },
);
if (. === "opened" && ... === "unregistered") {
// register before the first deposit
}Parameters
Prop
Type
Returns
Promise<OpenNimbusSessionResult>
opened with the session, or declined when the user refused to sign.
NimbusSdkError with reason "wallet-unsupported" when the wallet lacks
solana:signMessage or the cluster's chain, its account's address is not its public key's,
or it fails while signing, signs other bytes than the unlock message, or answers a signature
that does not verify; "misconfigured" when accountIndex is not an integer in [0, 2^31) or
gatewayToken is a string that is not an RFC 6750 bearer token;
"unsupported-browser" when the browser refuses the signature secret store's storage or the
note store's database; "unreadable" when the note store holds another deployment's rows or a
newer schema, or the context API answers what cannot be read; "service-unavailable" when the
context API cannot be reached or refuses.
Opens a session for the connected wallet on the SDK's cluster: reads the signature secret from the signature secret store or asks the wallet to sign the unlock message once, derives the seed, the platform wallet, the identity and its keys, reads its registration standing, and opens its note store in IndexedDB.
The wallet signs only when the store holds no secret for this wallet, cluster and chain; what its
signature yields is written to the store before anything else, so a reload opens without asking
again. The same wallet always opens the same identity on the same cluster, on any device. A
secret the store returns is trusted: a store an attacker can write to can open another identity
under this wallet's name. The note store is named by buildNoteStoreBackendName, one database
per deployment and identity. A registered identity's store keeps the birthday it has, or starts
at slot 0 on a device that has none, so every note is read; an unregistered identity's store is
left without one, for registering to set.
Opening reaches only the context API, which takes no gateway token, so a session opens whether or not it has one; the token is first sent when a flow reaches a gateway service.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/session.ts.
closeNimbusSession
Use it when the user signs out, switches wallets, or the wallet disconnects.
function closeNimbusSession(session: NimbusSession): void;Types used: NimbusSession
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
();Parameters
Prop
Type
Returns
void
Closes a session: zeroes its wallet seed and the keys a sync holds, drops a held gateway token, and closes its note store.
The signature secret store is left as it is, so the next open needs no signature; call its
wipeSignatureSecret as well to sign the user out. Every later use of the session fails. Closing
twice does nothing more.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/session.ts.
createMemorySignatureSecretStore
Use it when no secret may touch the browser's storage, and a signature after every reload is acceptable.
function createMemorySignatureSecretStore(): SignatureSecretStore;Types used: SignatureSecretStore
Example
import { } from "@umbra/nimbus-solana-web";
const = ();Returns
The store's read, write and wipe functions.
Creates a signature secret store that keeps secrets in this page's memory only, so the wallet signs again after every reload.
Nothing reaches Web Storage. A wiped secret's bytes are zeroed.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/signature-secret-store.ts.
createTabSignatureSecretStore
Use it for the default: one signature per tab, kept until the tab closes.
function createTabSignatureSecretStore(
options?: SignatureSecretStoreOptions,
): SignatureSecretStore;Types used: SignatureSecretStoreOptions, SignatureSecretStore
Example
import {
,
,
} from "@umbra/nimbus-solana-web";
import type { NimbusSdk, WalletStandardSigner } from "@umbra/nimbus-solana-web";
declare const : NimbusSdk;
declare const : WalletStandardSigner;
const = await (
,
{ },
{ : ({ : "my-app/" }) },
);Parameters
Prop
Type
Returns
The store's read, write and wipe functions.
Nothing itself; its functions throw NimbusSdkError with reason
"unsupported-browser" when the browser has no sessionStorage, refuses access to it or
refuses a write, as a full quota does.
Creates the default signature secret store, over the browser's sessionStorage: the secret lasts
as long as the tab, survives a reload, and is gone when the tab closes.
The secret is kept base64-encoded and unencrypted; any script running on the page's origin can
read it while the tab is open. The store touches sessionStorage only when one of its functions
is called.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/signature-secret-store.ts.
createPersistentSignatureSecretStore
Use it when users should sign once per device, and you accept the secret staying in localStorage.
function createPersistentSignatureSecretStore(
options?: SignatureSecretStoreOptions,
): SignatureSecretStore;Types used: SignatureSecretStoreOptions, SignatureSecretStore
Example
import { } from "@umbra/nimbus-solana-web";
const = ();Parameters
Prop
Type
Returns
The store's read, write and wipe functions.
Nothing itself; its functions throw NimbusSdkError with reason
"unsupported-browser" when the browser has no localStorage, refuses access to it or refuses
a write, as a full quota does.
Creates a signature secret store over the browser's localStorage: the secret survives closing
the browser, so the wallet signs once per device until the secret is wiped.
The secret is kept base64-encoded and unencrypted, indefinitely: any script that ever runs on the
page's origin can read it, and anyone with access to the browser profile can copy it from disk.
The store touches localStorage only when one of its functions is called.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/signature-secret-store.ts.
Last updated