Use this file to discover all available pages before exploring further.
TinyCloud uses Sign-In with Ethereum (SIWE) for authentication. Users prove wallet ownership to establish sessions that authorize access to their space.OpenKey can supply the signer for this SIWE flow in TinyCloud, but OpenKey OAuth is a separate token-based integration. If you are connecting OpenKey to TinyCloud, see TinyCloud Integration.
The authentication flow follows three steps regardless of which SDK you use:
1
Connect wallet
The user connects their Ethereum wallet. In the browser, this triggers a popup (MetaMask, WalletConnect, etc.). In Node.js, the SDK derives the address from the provided private key.
2
Sign SIWE message
The SDK constructs a SIWE message containing the domain, address, chain ID, and requested capabilities (via ReCap). The user (or private key) signs this message to prove ownership.
3
Session established
TinyCloud verifies the signature, creates the user’s space if needed, and issues a session. The session key can perform operations on behalf of the user until it expires.
TinyCloud’s default nonce behavior is sufficient when no relying-party challenge is needed. If you need to verify a nonce in your own auth flow, issue a one-time nonce from your server and pass that through the request. Do not generate nonces in the browser.
import { TinyCloudWeb } from '@tinycloud/web-sdk';// Create an instance with full configurationconst tc = new TinyCloudWeb({ // TinyCloud node(s) to connect to tinycloudHosts: ['https://node.tinycloud.xyz'], // Prefix for space isolation (different prefixes = different spaces) spacePrefix: 'my-app', // Automatically create the space on first sign-in autoCreateSpace: true, // Prefix for all KV keys (optional, for further key isolation) kvPrefix: '', // Show popup notifications for sign-in events notifications: { popups: true }, // Automatically resume sessions on page reload persistence: { autoResumeSession: true },});// Triggers the wallet popup:// 1. Wallet connection prompt (select account)// 2. SIWE message signature promptconst session = await tc.signIn();console.log('Signed in as:', session.address);
You can create a TinyCloudNode instance without a private key. This creates a session-only client that cannot sign in on its own but can receive delegations from other users.
import { TinyCloudNode } from '@tinycloud/node-sdk';// No privateKey -- session-only modeconst tc = new TinyCloudNode({ host: 'https://node.tinycloud.xyz',});// tc.signIn() would fail -- no private key to sign with// But this client can receive and use delegationsconst access = await tc.useDelegation(portableDelegation);const result = await access.kv.get('shared/document');
Session-only mode is useful for services that only need to read delegated data, such as a read-only dashboard or a webhook consumer.
Sessions can be persisted so users do not need to re-authenticate on every page reload or process restart.
Web SDK
Node SDK
The Web SDK supports three storage backends:
const tc = new TinyCloudWeb({ persistence: { autoResumeSession: true, }, sessionConfig: { // 'localStorage' - persists across tabs and browser sessions // 'sessionStorage' - clears when the tab closes // 'memory' - clears on page reload (default) storageType: 'localStorage', },});// On subsequent page loads, the session is automatically restored// if autoResumeSession is true and a valid session exists
You can also manually check for an existing session:
The Node SDK provides two session storage implementations:
import { TinyCloudNode, FileSessionStorage } from '@tinycloud/node-sdk';// Persists session to disk -- survives process restartsconst tc = new TinyCloudNode({ privateKey: process.env.WALLET_PRIVATE_KEY, sessionStorage: new FileSessionStorage('./session.json'),});await tc.signIn();// Session saved to ./session.json// On next startup, signIn() reuses the persisted session if still valid
FileSessionStorage is recommended for production services. MemorySessionStorage is the default if no storage is specified.
Sessions have a limited lifetime. When a session expires, operations will fail and the user must re-authenticate.
// Configure expiry durationconst tc = new TinyCloudWeb({ sessionConfig: { storageType: 'localStorage', expirationTime: '24h', // Session duration },});// Check if the current session is still validif (tc.isSessionExpired()) { await tc.signIn(); // Re-authenticate}
For long-running Node.js services, use FileSessionStorage combined with a try/catch around operations to automatically re-authenticate when the session expires.