Rivisk

Integrate

Authentication

Public reads need nothing. Account-scoped actions take an API key for server-to-server calls, or a wallet-signature session when a person is signing in.

What each credential can do#

CredentialPortfolios, risk, simulations, policies, alert listsCreate and change alerts and webhooksAPI keys and profile
None✓——
API key rv_live_… / rv_test_…✓✓—
Wallet session✓✓✓

Both credentials are sent the same way, as a bearer token:

http
Authorization: Bearer rv_live_3f9a…

Ownership#

Alerts belong to an address, and writing one requires that the credential's account controls that address, meaning it has signed in with it. A wallet row existing because someone scanned the address proves nothing, so an unclaimed address cannot be claimed through the alerts API. Writing to an address you do not control returns 403.

Wallet sessions#

Rivisk never sees a private key. The wallet signs a one-time challenge and the API checks that the signature came from the public key that hashes to the claimed address.

  1. Request a challenge

    ts
    const { message } = await rivisk.auth.challenge(address);

    The message expires after 300 seconds and authenticates exactly one sign-in; it is deleted the moment it is used.

  2. Sign it in the wallet

    ts
    import { request } from '@stacks/connect'; const { signature, publicKey } = await request('stx_signMessage', { message });

    It is a message signature, not a transaction: it moves no funds and costs nothing.

  3. Exchange it for tokens

    ts
    const session = await rivisk.auth.verify({ address, publicKey, signature });// { userId, address, accessToken, refreshToken, expiresIn }

    From here the SDK holds the session and refreshes it on its own: a 401 triggers one refresh and the original request is replayed with the new token.

Token lifetimes#

TokenLifetimeNotes
Challenge300 secondsSingle use
Access token15 minutesSent as the bearer token
Refresh token30 daysOnly accepted by POST /auth/refresh; rejected as an access token

Persisting a session#

ts
const rivisk = new RiviskClient({  baseUrl,  session: JSON.parse(localStorage.getItem('rivisk_session') ?? 'null'),  onSession: (session) => {    if (session) localStorage.setItem('rivisk_session', JSON.stringify(session));    else localStorage.removeItem('rivisk_session');  },});

onSession fires on sign-in, on every refresh, and with null when the refresh token is rejected, so storage never holds a session the server has already refused.

API keys#

Create keys from a wallet session, either on the Developers page of the dashboard or over the API:

ts
const key = await rivisk.apiKeys.create('production backend', true);  // live: truekey.token;   // rv_live_… shown once, never again. Store it now.
PrefixUse
rv_live_Production
rv_test_Development and CI

Keys are stored only as a peppered SHA-256 hash and compared in constant time, so a database leak does not hand out working credentials. The first 16 characters are kept in clear so you can tell your keys apart in the dashboard. Revoke with rivisk.apiKeys.revoke(id); it takes effect on the next request.

ts
const server = new RiviskClient({ baseUrl, apiKey: process.env.RIVISK_API_KEY });await server.webhooks.create('https://example.com/rivisk', ['alert.triggered']);

Endpoint by endpoint, the credential each one takes is listed on REST API.