@neondatabase/auth 0.1.0-beta.12 → 0.1.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@neondatabase/auth.svg)](https://www.npmjs.com/package/@neondatabase/auth)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@neondatabase/auth.svg)](https://www.npmjs.com/package/@neondatabase/auth)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue.svg)](https://www.typescriptlang.org/)
6
- [![License](https://img.shields.io/npm/l/@neondatabase/auth.svg)](https://github.com/neondatabase-labs/neon-js/blob/main/LICENSE)
6
+ [![License](https://img.shields.io/npm/l/@neondatabase/auth.svg)](https://github.com/neondatabase/neon-js/blob/main/LICENSE)
7
7
 
8
8
  Authentication adapters for Neon Auth, supporting multiple auth providers.
9
9
 
@@ -19,6 +19,7 @@ This package is designed to work seamlessly with Neon's authentication infrastru
19
19
 
20
20
  - **Simple default API** - Works out of the box with Better Auth patterns
21
21
  - **Optional adapters** - Switch API styles for migrations or preferences
22
+ - **Anonymous access** - Optional RLS-based data access for unauthenticated users
22
23
  - **Performance optimizations** - Session caching and request deduplication
23
24
  - **TypeScript support** - Fully typed with strict type checking
24
25
 
@@ -144,6 +145,23 @@ function MyComponent() {
144
145
  }
145
146
  ```
146
147
 
148
+ ## Anonymous Access
149
+
150
+ Enable `allowAnonymous` to let unauthenticated users access data via RLS policies:
151
+
152
+ ```typescript
153
+ import { createAuthClient } from '@neondatabase/auth';
154
+
155
+ const auth = createAuthClient('https://your-auth-server.com', {
156
+ allowAnonymous: true, // Enable anonymous data access
157
+ });
158
+
159
+ // Get token - returns anonymous token if no user session exists
160
+ const token = await auth.getJWTToken?.();
161
+ ```
162
+
163
+ This is useful when you want to allow read-only public access to certain data while still enforcing RLS policies.
164
+
147
165
  ## API Reference
148
166
 
149
167
  ### createAuthClient(url, config?)
@@ -153,6 +171,7 @@ Factory function to create an auth client.
153
171
  **Parameters:**
154
172
  - `url` - The auth service URL (required)
155
173
  - `config.adapter` - Optional adapter factory function (e.g., `SupabaseAuthAdapter()`)
174
+ - `config.allowAnonymous` - When `true`, returns an anonymous token if no user session exists (default: `false`)
156
175
 
157
176
  **Returns:** The adapter's public API (varies by adapter type)
158
177