Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

69 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flowsta SDK

Official JavaScript SDK for Flowsta Authentication - Zero-knowledge, OAuth-based Single Sign-On for web applications.

npm version License: MIT

New to Flowsta? Create a developer account to get your Client ID.

πŸ“¦ Packages

Package Version Description
@flowsta/auth ⭐ 2.3.2 Core OAuth SDK + Sign It (file signing & verification)
@flowsta/login-button 0.1.6 Pre-built button components
@flowsta/holochain 2.6.0 Vault agent linking, backups, Sign It document signing, rich link status

πŸš€ Getting Started

Prerequisites

  1. Get your Client ID: Sign up at dev.flowsta.com
  2. Add redirect URI: Configure https://yoursite.com/auth/callback in your app settings

Choose Your Integration Method

Option 1: NPM Package (Recommended)

Install the SDK for modern web apps:

npm install @flowsta/auth

Option 2: Pre-built Buttons

For quick integration with UI components:

npm install @flowsta/login-button

Supports: React, Vue, Qwik, Vanilla JS

Option 3: No Build Tools?

Use vanilla JavaScript without npm:

Core SDK Features

OAuth 2.0 authentication with PKCE - no client secrets needed.

Features:

  • βœ… OAuth 2.0 + PKCE (Proof Key for Code Exchange)
  • βœ… Zero-knowledge architecture - user data stays encrypted
  • βœ… React bindings included (@flowsta/auth/react)
  • βœ… TypeScript-first with full type safety
  • βœ… Zero dependencies - lightweight (< 10kb)
  • βœ… Works in any JavaScript environment

Pre-built "Sign in with Flowsta" button components.

Features:

  • βœ… Multiple frameworks: React, Vue, Qwik, Vanilla JS
  • βœ… 6 button variants (dark/light/neutral Γ— pill/rectangle)
  • βœ… Automatic PKCE generation and state management
  • βœ… Customizable styling and behavior
  • βœ… Inline SVG assets - works with any bundler

Link your Holochain app's agent key with the user's Flowsta Vault identity.

Features:

  • βœ… Agent identity linking via Vault IPC
  • βœ… Auto-backups to Vault's encrypted storage
  • βœ… Link status checks and revocation
  • βœ… TypeScript-first with full type safety
  • βœ… Zero dependencies

πŸ’‘ Quick Start Examples

Vanilla JavaScript (No Build Tools)

Perfect for static HTML sites or simple projects:

<!DOCTYPE html>
<html>
<head>
  <title>Sign in with Flowsta</title>
</head>
<body>
  <a href="#" id="login-btn">
    <img src="https://docs.flowsta.com/buttons/svg/flowsta_signin_web_dark_pill.svg" 
         alt="Sign in with Flowsta" 
         width="175" height="40">
  </a>

  <script type="module">
    import { FlowstaAuth } from 'https://unpkg.com/@flowsta/auth';

    const auth = new FlowstaAuth({
      clientId: 'your-client-id',
      redirectUri: window.location.origin + '/callback.html'
    });

    document.getElementById('login-btn').addEventListener('click', (e) => {
      e.preventDefault();
      auth.login();
    });
  </script>
</body>
</html>

View Complete Vanilla JS Guide β†’

React with Hooks

Using the built-in React bindings:

import { FlowstaAuthProvider, useFlowstaAuth } from '@flowsta/auth/react';
import { FlowstaLoginButton } from '@flowsta/login-button/react';

function App() {
  return (
    <FlowstaAuthProvider
      clientId="your-client-id"
      redirectUri="https://yoursite.com/auth/callback"
    >
      <Dashboard />
    </FlowstaAuthProvider>
  );
}

function Dashboard() {
  const { isAuthenticated, user, login, logout } = useFlowstaAuth();
  
  if (!isAuthenticated) {
    return <FlowstaLoginButton onClick={login} variant="dark-pill" />;
  }
  
  return (
    <div>
      <h1>Welcome, {user?.displayName}!</h1>
      <p>@{user?.username}</p>
      <button onClick={logout}>Logout</button>
    </div>
  );
}

Vue 3 with Composition API

<script setup>
import { FlowstaAuth } from '@flowsta/auth';
import { FlowstaLoginButton } from '@flowsta/login-button/vue';
import { ref, onMounted } from 'vue';

const auth = new FlowstaAuth({
  clientId: 'your-client-id',
  redirectUri: 'https://yoursite.com/callback'
});

const user = ref(null);
const isAuthenticated = ref(false);

onMounted(() => {
  isAuthenticated.value = auth.isAuthenticated();
  user.value = auth.getUser();
});

const login = () => auth.login();
const logout = () => {
  auth.logout();
  isAuthenticated.value = false;
  user.value = null;
};
</script>

<template>
  <div v-if="!isAuthenticated">
    <FlowstaLoginButton
      client-id="your-client-id"
      redirect-uri="https://yoursite.com/callback"
      variant="dark-pill"
    />
  </div>
  <div v-else>
    <h1>Welcome, {{ user?.displayName }}!</h1>
    <button @click="logout">Logout</button>
  </div>
</template>

Core SDK (TypeScript)

For maximum control and flexibility:

import { FlowstaAuth } from '@flowsta/auth';

const auth = new FlowstaAuth({
  clientId: 'your-client-id',
  redirectUri: 'https://yoursite.com/auth/callback',
  scopes: ['openid', 'email', 'display_name', 'username']
});

// Redirect to Flowsta login
auth.login();

// On your callback page
try {
  const user = await auth.handleCallback();
  console.log('Authenticated:', user.displayName, user.username);
  // Redirect to dashboard
  window.location.href = '/dashboard';
} catch (error) {
  console.error('Authentication failed:', error);
  window.location.href = '/login?error=auth_failed';
}

🎨 Button Variants

The @flowsta/login-button package includes 6 official button styles:

Variant Best For Preview
dark-pill Light backgrounds (recommended) Dark Pill
dark-rectangle Light backgrounds, square style Dark Rectangle
light-pill Dark backgrounds Light Pill
light-rectangle Dark backgrounds, square style Light Rectangle
neutral-pill Any background Neutral Pill
neutral-rectangle Any background, square style Neutral Rectangle

Download all button assets β†’

πŸ‘€ User Data & Scopes

After authentication, you'll receive a FlowstaUser object with the requested scopes:

interface FlowstaUser {
  sub: string;              // Unique user ID (always available)
  display_name?: string;    // Display name (if 'display_name' scope)
  username?: string;        // Username (if 'username' scope)
  email?: string;           // Email (if 'email' scope)
  email_verified?: boolean; // Email verification status
  profile_picture?: string; // Profile picture URL (if 'profile_picture' scope)
  agent_pub_key?: string;   // Holochain agent key (if 'public_key' scope)
  did?: string;             // Decentralized ID (if 'did' scope)
}

Available Scopes:

  • openid - Required, provides user ID
  • email - User's email address
  • display_name - User's display name
  • username - User's @username
  • profile_picture - Profile picture URL
  • public_key - Holochain agent public key
  • did - W3C Decentralized Identifier

πŸ” What is Flowsta?

Flowsta provides zero-knowledge authentication powered by Holochain:

  • πŸ” Zero-Knowledge: Your data is encrypted end-to-end - only you can decrypt it
  • 🌐 Single Sign-On: One login works across all Flowsta-enabled applications
  • πŸ”‘ Decentralized Identity: Built on Holochain's DHT for censorship resistance
  • ⚑ Easy Integration: Standard OAuth 2.0 with PKCE security
  • πŸ›‘οΈ Privacy-First: No tracking, no data mining, no selling your information

How It Works

  1. User logs in via login.flowsta.com
  2. Data is encrypted with user's password (zero-knowledge)
  3. Stored on Holochain DHT (decentralized, censorship-resistant)
  4. Your app receives an access token via OAuth
  5. Fetch user data from the Auth API (decrypted on-demand)

πŸ“š Documentation

Official Docs

Package READMEs

Developer Resources

πŸ› οΈ Development

Setup

# Clone the repository
git clone https://github.com/WeAreFlowsta/flowsta-sdk.git
cd flowsta-sdk

# Install dependencies
npm install

# Build all packages
npm run build

Available Scripts

npm run build       # Build all packages
npm run dev         # Watch mode for development
npm run test        # Run tests (coming soon)
npm run lint        # Lint code (coming soon)

Package Structure

sdk-monorepo/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ auth/              # Core OAuth SDK with React bindings
β”‚   β”œβ”€β”€ holochain/         # Vault agent linking & backup SDK
β”‚   └── login-button/      # Pre-built button components
└── README.md

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

MIT Β© Flowsta

πŸ”— Links


Questions? Join our Discord community or check out the documentation.

About

Official JavaScript SDK for Flowsta

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages