@neondatabase/neon-js 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/neon-js.svg)](https://www.npmjs.com/package/@neondatabase/neon-js)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@neondatabase/neon-js.svg)](https://www.npmjs.com/package/@neondatabase/neon-js)
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/neon-js.svg)](https://github.com/neondatabase-labs/neon-js/blob/main/LICENSE)
6
+ [![License](https://img.shields.io/npm/l/@neondatabase/neon-js.svg)](https://github.com/neondatabase/neon-js/blob/main/LICENSE)
7
7
 
8
8
  The official TypeScript SDK for Neon, combining authentication and database querying in a familiar interface.
9
9
 
@@ -15,6 +15,7 @@ The official TypeScript SDK for Neon, combining authentication and database quer
15
15
 
16
16
  - **Integrated Authentication** - Works out of the box with optional adapters (Supabase-compatible, React hooks)
17
17
  - **PostgreSQL Querying** - Full PostgREST client with type-safe queries
18
+ - **Anonymous Access** - Optional RLS-based data access for unauthenticated users
18
19
  - **High Performance** - Session caching, request deduplication
19
20
  - **Automatic Token Management** - Seamless token injection for database queries
20
21
  - **TypeScript First** - Fully typed with strict type checking
@@ -44,6 +45,8 @@ import { createClient } from '@neondatabase/neon-js';
44
45
  const client = createClient<Database>({
45
46
  auth: {
46
47
  url: import.meta.env.VITE_NEON_AUTH_URL,
48
+ // Optional: allow unauthenticated users to query data via RLS
49
+ // allowAnonymous: true,
47
50
  },
48
51
  dataApi: {
49
52
  url: import.meta.env.VITE_NEON_DATA_API_URL,
@@ -126,6 +129,27 @@ function MyComponent() {
126
129
  }
127
130
  ```
128
131
 
132
+ ### Anonymous Access
133
+
134
+ Enable `allowAnonymous` to let unauthenticated users query data. This uses an anonymous token for RLS-based access control:
135
+
136
+ ```typescript
137
+ import { createClient } from '@neondatabase/neon-js';
138
+
139
+ const client = createClient<Database>({
140
+ auth: {
141
+ url: import.meta.env.VITE_NEON_AUTH_URL,
142
+ allowAnonymous: true, // Enable anonymous data access
143
+ },
144
+ dataApi: {
145
+ url: import.meta.env.VITE_NEON_DATA_API_URL,
146
+ },
147
+ });
148
+
149
+ // Works without signing in - uses anonymous token for RLS
150
+ const { data: publicItems } = await client.from('public_items').select();
151
+ ```
152
+
129
153
  ## Authentication
130
154
 
131
155
  ### Sign Up
@@ -293,6 +317,7 @@ const client = createClient({
293
317
  // Auth configuration
294
318
  auth: {
295
319
  url: 'https://your-auth-server.neon.tech/auth',
320
+ allowAnonymous: true, // Optional: enable anonymous data access
296
321
  },
297
322
 
298
323
  // Data API configuration
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { NeonAuth, NeonAuth as NeonAuth$1, NeonAuthAdapter, NeonAuthAdapter as NeonAuthAdapter$1, NeonAuthConfig, NeonAuthPublicApi, NeonAuthPublicApi as NeonAuthPublicApi$1, ReactBetterAuthClient, VanillaBetterAuthClient } from "@neondatabase/auth";
1
+ import { NeonAuth, NeonAuth as NeonAuth$1, NeonAuthAdapter, NeonAuthAdapter as NeonAuthAdapter$1, NeonAuthConfig, NeonAuthConfig as NeonAuthConfig$1, NeonAuthPublicApi, NeonAuthPublicApi as NeonAuthPublicApi$1, ReactBetterAuthClient, VanillaBetterAuthClient } from "@neondatabase/auth";
2
2
  import { BetterAuthVanillaAdapter, BetterAuthVanillaAdapterInstance, BetterAuthVanillaAdapterInstance as BetterAuthVanillaAdapterInstance$1, BetterAuthVanillaAdapterOptions, SupabaseAuthAdapter, SupabaseAuthAdapterInstance, SupabaseAuthAdapterInstance as SupabaseAuthAdapterInstance$1, SupabaseAuthAdapterOptions } from "@neondatabase/auth/vanilla/adapters";
3
3
  import { BetterAuthReactAdapterInstance } from "@neondatabase/auth/react/adapters";
4
4
  import { AuthRequiredError, DefaultSchemaName, DefaultSchemaName as DefaultSchemaName$1, NeonPostgrestClient, NeonPostgrestClientConstructorOptions, fetchWithToken } from "@neondatabase/postgrest-js";
@@ -27,11 +27,9 @@ declare class NeonClient<Database = any, SchemaName extends string & keyof Datab
27
27
  * Auth configuration for createClient
28
28
  */
29
29
  type CreateClientAuthConfig<T extends NeonAuthAdapter$1> = {
30
- /** The adapter builder to use. Defaults to BetterAuthVanillaAdapter() if not specified. */
31
- adapter?: (url: string) => T;
32
30
  /** The auth service URL */
33
31
  url: string;
34
- };
32
+ } & NeonAuthConfig$1<T>;
35
33
  /**
36
34
  * Data API configuration for createClient
37
35
  */
@@ -101,6 +99,7 @@ type CreateClientResult<Database, TAdapter extends NeonAuthAdapter$1> = NeonClie
101
99
  declare function createClient<Database = any>(config: {
102
100
  auth: {
103
101
  url: string;
102
+ allowAnonymous?: boolean;
104
103
  };
105
104
  dataApi: CreateClientDataApiConfig<DefaultSchemaName$1<Database>, BetterAuthVanillaAdapterInstance$1>;
106
105
  }): CreateClientResult<Database, BetterAuthVanillaAdapterInstance$1>;
package/dist/index.mjs CHANGED
@@ -25,9 +25,12 @@ var NeonClient = class extends NeonPostgrestClient {
25
25
  //#region src/client/client-factory.ts
26
26
  function createClient(config) {
27
27
  const { auth: authConfig, dataApi: dataApiConfig } = config;
28
- const auth = createInternalNeonAuth(authConfig.url, { adapter: authConfig.adapter });
28
+ const auth = createInternalNeonAuth(authConfig.url, {
29
+ adapter: authConfig.adapter,
30
+ allowAnonymous: authConfig.allowAnonymous ?? false
31
+ });
29
32
  const getAccessToken = async () => {
30
- return await auth.getJWTToken();
33
+ return auth.getJWTToken();
31
34
  };
32
35
  const authFetch = fetchWithToken$1(getAccessToken, dataApiConfig.options?.global?.fetch);
33
36
  return new NeonClient({
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neondatabase/neon-js",
3
- "version": "0.1.0-beta.11",
3
+ "version": "0.1.0-beta.12",
4
4
  "description": "TypeScript SDK for Neon Auth and Data API - authentication and PostgreSQL querying",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -18,13 +18,13 @@
18
18
  "supabase",
19
19
  "data-api"
20
20
  ],
21
- "homepage": "https://github.com/neondatabase-labs/neon-js/tree/main/packages/neon-js#readme",
21
+ "homepage": "https://github.com/neondatabase/neon-js/tree/main/packages/neon-js#readme",
22
22
  "bugs": {
23
- "url": "https://github.com/neondatabase-labs/neon-js/issues"
23
+ "url": "https://github.com/neondatabase/neon-js/issues"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/neondatabase-labs/neon-js.git",
27
+ "url": "git+https://github.com/neondatabase/neon-js.git",
28
28
  "directory": "packages/neon-js"
29
29
  },
30
30
  "funding": {
@@ -117,7 +117,7 @@
117
117
  },
118
118
  "dependencies": {
119
119
  "@neondatabase/postgrest-js": "^0.1.0-alpha.1",
120
- "@neondatabase/auth": "^0.1.0-beta.12",
120
+ "@neondatabase/auth": "^0.1.0-beta.13",
121
121
  "@supabase/postgres-meta": "0.93.1",
122
122
  "meow": "14.0.0",
123
123
  "zod": "4.1.12"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neondatabase/neon-js",
3
- "version": "0.1.0-beta.12",
3
+ "version": "0.1.0-beta.13",
4
4
  "description": "TypeScript SDK for Neon Auth and Data API - authentication and PostgreSQL querying",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -18,13 +18,13 @@
18
18
  "supabase",
19
19
  "data-api"
20
20
  ],
21
- "homepage": "https://github.com/neondatabase-labs/neon-js/tree/main/packages/neon-js#readme",
21
+ "homepage": "https://github.com/neondatabase/neon-js/tree/main/packages/neon-js#readme",
22
22
  "bugs": {
23
- "url": "https://github.com/neondatabase-labs/neon-js/issues"
23
+ "url": "https://github.com/neondatabase/neon-js/issues"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/neondatabase-labs/neon-js.git",
27
+ "url": "git+https://github.com/neondatabase/neon-js.git",
28
28
  "directory": "packages/neon-js"
29
29
  },
30
30
  "funding": {
@@ -117,7 +117,7 @@
117
117
  },
118
118
  "dependencies": {
119
119
  "@neondatabase/postgrest-js": "0.1.0-alpha.1",
120
- "@neondatabase/auth": "0.1.0-beta.12",
120
+ "@neondatabase/auth": "0.1.0-beta.13",
121
121
  "@supabase/postgres-meta": "0.93.1",
122
122
  "meow": "14.0.0",
123
123
  "zod": "4.1.12"