open-index/open-npm huggingface dataset:
npm package: @flexar/sdk
Description: Flexar subscriptions platform SDK
Latest version: 0.0.3

# flexar-sdk
Flexar React SDK

## Subscriptions SDK

[Basic usage](#basic-usage)  
[Types](#types):  
- [Pass](#pass)
- [Tier](#tier)
- [useSSP params](#hook-params)
- [useSSP return](#hook-return)

### Basic usage

Install:
```sh
$ npm i @flexar/sdk
```

In your client component:
```ts
import { useSSP } from "@flexar/sdk"
import { useWallet } from "@solana/wallet-adapter-react"

export default function MyComponent() {
  // @solana/wallet-adapter-react wallet component
  const wallet = useWallet();

  // Flexar SSP hook
  const { isLoading, passes, refreshPasses, subscribe } = useSSP({ wallet, apiKey: "Your SSP API KEY" });

  // ...
}
```

The hook will auto-load available passes for the API provided and update them once a wallet is connected.  

Alternatively you can supply and API key via `NEXT_PUBLIC_SSP_APIKEY` environment variable.

### Types

#### Pass
```ts
type SSPPass = {
    id: string;
    name: string;
    description: string;
    symbol: string;
    imageUrl: string;
    /** Total number of passes */
    minted: number;
    /** Number of available passes */
    available: number;
    /** If the connected wallet is already subscribed to this pass */
    isSubscribed?: boolean;
    /** If the connected wallet is already subscribed to this pass, when the subscription ends */
    subscribedEndDate?: number;
    /** If the connected wallet can extend the subscription to this pass */
    canExtend?: boolean;
    tiers: SSPTier[];
};
```

#### Tier

```ts
type SSPTier = {
    id: string;
    description: string;
    /** duration as ISO 8601 format, eg. "P1Y2M3DT4H5M6S". @see https://www.digi.com/resources/documentation/digidocs/90001488-13/reference/r_iso_8601_duration_format.htm */
    duration: string;
    /** Price in token (lamports for SOL) */
    price: number;
    /** SOL only at the moment */
    token: string;
    /** If the connected wallet can subscribe to this tier */
    canSubscribe?: boolean;
};
```

#### Hook params

```ts
type UseSSPProps = {
    /** Solana Wallet Adapter Wallet */
    wallet?: WalletContextState;
    /** FLEXAR SSP API key */
    apiKey?: string;
    /** FLEXAR SSP endpoint override */
    apiEndpoint?: string;
};
```

#### Hook return

```ts
type UseSSPContext = {
    /** Loading passes */
    isLoading: boolean;
    /**
     * Available subscription passes.
     * Undefined: Passes were never loaded
     * Null: Loading error
     */
    passes?: SSPPass[] | null;
    /** Use to manually refresh passes */
    refreshPasses: () => Promise<void>;
    /** Subscribe to a tier */
    subscribe: (tierId: string, statusCallback?: SSPStatusCallback) => Promise<boolean>;
};
```
npm package: @flexauth/core
Description: Core FlexAuth RBAC SDK - Flexible Role-Based Access Control
Latest version: 1.0.11

# @flexauth/core

The core logic for FlexAuth, a flexible Role-Based Access Control (RBAC) system. This package handles permission checks, role management, and condition evaluation.

## Installation

```bash
npm install @flexauth/core
# or
bun add @flexauth/core
```

## Usage

```typescript
import { FlexAuth } from "@flexauth/core";
import { MemoryAdapter } from "@flexauth/core/adapters";

const auth = new FlexAuth({
  adapter: new MemoryAdapter()
});

// Check permissions
const allowed = await auth.can("user_123", "read", "document");
```
npm package: @flexauth/drizzle
Description: FlexAuth Drizzle ORM Integration - Database schema and migrations
Latest version: 1.0.5

# @flexauth/drizzle

Drizzle ORM schemas and integration for FlexAuth.

## Installation

```bash
npm install @flexauth/drizzle drizzle-orm
# or
bun add @flexauth/drizzle drizzle-orm
```

## Usage

```typescript
import { drizzle } from "drizzle-orm/postgres-js";
import * as schema from "@flexauth/drizzle/schema";

const db = drizzle(client, { schema });

// Use the schema in your migrations and queries
```
npm package: @flexauth/express
Description: FlexAuth Express.js Integration - Middleware and helpers for Express
Latest version: 1.0.4

# @flexauth/express

Express.js middleware for FlexAuth RBAC.

## Installation

```bash
npm install @flexauth/express
# or
bun add @flexauth/express
```

## Usage

```typescript
import express from "express";
import { requirePermission } from "@flexauth/express";

const app = express();

app.get(
  "/documents",
  requirePermission("read", "document"),
  (req, res) => {
    res.send("You have access!");
  }
);
```
npm package: @flexauth/hono
Description: Hono middleware for FlexAuth RBAC
Latest version: 1.0.14

# @flexauth/hono

Hono middleware for FlexAuth RBAC.

## Installation

```bash
npm install @flexauth/hono
# or
bun add @flexauth/hono
```

## Usage

```typescript
import { Hono } from "hono";
import { requirePermission } from "@flexauth/hono";

const app = new Hono();

app.get(
  "/api/resource",
  requirePermission("read", "resource"),
  (c) => c.text("Allowed")
);
```
npm package: @flexauth/react
Description: FlexAuth React Integration - Provider, hooks, and components for React
Latest version: 1.0.4

# @flexauth/react

React hooks and components for FlexAuth.

## Installation

```bash
npm install @flexauth/react
# or
bun add @flexauth/react
```

## Usage

```tsx
import { FlexAuthProvider, useCan, Can } from "@flexauth/react";

// Wrap your app
<FlexAuthProvider>
  <App />
</FlexAuthProvider>

// Component
function MyButton() {
  const canDelete = useCan("delete", "post");

  if (!canDelete) return null;
  return <button>Delete</button>;
}

// Or use the Can component
<Can action="edit" resource="post" fallback={<div>Access Denied</div>}>
  <EditButton />
</Can>
```