@absolutejs/auth 0.82.0 → 0.84.0

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.
@@ -0,0 +1,42 @@
1
+ import type { CustomProviderClientConfiguration } from '../types';
2
+ /** Neon requires a registered partner OAuth application. */
3
+ export declare const neonProviderConfiguration: import("citra").CustomProviderDefinition<{
4
+ readonly authorizationUrl: "https://oauth2.neon.tech/oauth2/auth";
5
+ readonly isOIDC: true;
6
+ readonly isRefreshable: true;
7
+ readonly PKCEMethod: "S256";
8
+ readonly profileRequest: {
9
+ readonly authIn: "header";
10
+ readonly encoding: "application/json";
11
+ readonly method: "GET";
12
+ readonly url: "https://oauth2.neon.tech/userinfo";
13
+ };
14
+ readonly revocationRequest: {
15
+ readonly authIn: "body";
16
+ readonly encoding: "application/x-www-form-urlencoded";
17
+ readonly tokenParamName: "token";
18
+ readonly url: "https://oauth2.neon.tech/oauth2/revoke";
19
+ };
20
+ readonly scopeRequired: true;
21
+ readonly subject: ["sub"];
22
+ readonly subjectType: "string";
23
+ readonly tokenRequest: {
24
+ readonly authIn: "body";
25
+ readonly encoding: "application/x-www-form-urlencoded";
26
+ readonly url: "https://oauth2.neon.tech/oauth2/token";
27
+ };
28
+ }, import("citra").CustomProviderCredentials>;
29
+ export type NeonManagementScope = `urn:neoncloud:${'projects' | 'orgs'}:${'create' | 'read' | 'update' | 'delete' | 'permission'}`;
30
+ export type NeonProviderOptions = {
31
+ credentials: {
32
+ clientId: string;
33
+ clientSecret: string;
34
+ redirectUri: string;
35
+ };
36
+ /** Select permissions deliberately; no management permissions are implicit. */
37
+ scopes: readonly NeonManagementScope[];
38
+ /** Request both scopes required by Neon to issue a refresh token. */
39
+ offlineAccess?: boolean;
40
+ };
41
+ /** Configure `customProviders.neon` without granting management permissions implicitly. */
42
+ export declare const createNeonProviderConfiguration: ({ credentials, offlineAccess, scopes }: NeonProviderOptions) => CustomProviderClientConfiguration;
@@ -12,7 +12,8 @@ The application owns user records. The auth package owns credentials and session
12
12
 
13
13
  ```ts
14
14
  import { auth } from '@absolutejs/auth/server';
15
- import { createPostgresAuthSessionStore, createPostgresCredentialStore, runMigrations } from '@absolutejs/auth';
15
+ import { runBunMigrations } from '@absolutejs/auth/bun';
16
+ import { createPostgresAuthSessionStore, createPostgresCredentialStore } from '@absolutejs/auth';
16
17
  import { SQL } from 'bun';
17
18
  import { Database } from 'bun:sqlite';
18
19
  import { drizzle } from 'drizzle-orm/bun-sql';
@@ -25,20 +26,11 @@ if (!databaseUrl)
25
26
  throw new Error(
26
27
  "AUTH_DATABASE_URL must point to the isolated acceptance database",
27
28
  );
28
- const migrationClient = new SQL({ url: databaseUrl, max: 1, prepare: false });
29
- try {
30
- await runMigrations({
31
- blocks: ["sessions", "credentials"],
32
- client: {
33
- query: async (text, values) => ({
34
- rows: await migrationClient.unsafe(text, values ? [...values] : []),
35
- }),
36
- },
37
- log: () => undefined,
38
- });
39
- } finally {
40
- await migrationClient.close();
41
- }
29
+ await runBunMigrations({
30
+ databaseUrl,
31
+ blocks: ['sessions', 'credentials'],
32
+ log: () => undefined,
33
+ });
42
34
  const authDb = drizzle({ client: new SQL(databaseUrl) });
43
35
  const decodeCustomer = (value: unknown): Customer => {
44
36
  if (typeof value !== "object" || value === null)
package/docs/neon.md ADDED
@@ -0,0 +1,42 @@
1
+ # Neon partner OAuth
2
+
3
+ Neon direct OAuth requires a registered partner application and an active commercial
4
+ relationship. This preset does not register an application or confer partner status.
5
+ See https://neon.com/docs/guides/oauth-integration for registration and callback requirements.
6
+
7
+ ```ts
8
+ import { createNeonProviderConfiguration } from '@absolutejs/auth/providers';
9
+
10
+ const neon = createNeonProviderConfiguration({
11
+ credentials: {
12
+ clientId: process.env.NEON_CLIENT_ID!,
13
+ clientSecret: process.env.NEON_CLIENT_SECRET!,
14
+ redirectUri: 'https://app.example.com/auth/neon/callback'
15
+ },
16
+ scopes: ['urn:neoncloud:orgs:read', 'urn:neoncloud:projects:read'],
17
+ offlineAccess: true
18
+ });
19
+ // Pass customProviders: { neon } to your existing Auth configuration.
20
+ ```
21
+
22
+ Keep credentials on the server. Register the exact callback used by your Auth
23
+ mount. The preset enables S256 PKCE, identifies accounts by `sub`, and requests
24
+ `openid`. Management permissions must be explicit. `offlineAccess` adds both
25
+ `offline` and `offline_access`; it defaults to false. Request create/update only
26
+ when the customer needs those operations. Delete and organization administration
27
+ are never implicit. Do not infer an email or organization from the subject.
28
+
29
+ The existing custom-provider authorization, callback, profile, refresh and revoke
30
+ routes handle this definition. An account connection is separate from signing the
31
+ customer into your application; enforce your application's account-linking policy.
32
+ The generic `createOAuthLinkedProviderCredentialResolver` currently accepts only
33
+ built-in providers. Applications using that resolver need a custom-provider-aware
34
+ resolver before enabling unattended Neon management. This preset alone does not
35
+ provide a resource picker, database provisioning, secret delivery or browser
36
+ assistance. Do not enable the customer-facing connection until those pieces and
37
+ partner credentials are in place.
38
+
39
+ Use a provider-owned sign-in window where required. Do not proxy sign-in into an
40
+ embedded browser that violates the identity provider's policies. Never put client
41
+ secrets, refresh tokens or database connection strings into chat or referral URLs.
42
+ Referral agreements and reporting are separate from OAuth permission grants.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.82.0",
2
+ "version": "0.84.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "license": "BSL-1.1",
18
18
  "author": "Alex Kahn",
19
19
  "scripts": {
20
- "build": "rm -rf dist && bun build src/index.ts src/server.ts src/agents/index.ts src/oidc/index.ts src/saml.ts src/webauthn.ts src/htmx/index.ts src/client/index.ts src/client/mobile.ts src/client/react.ts src/client/vue.ts src/client/solid.ts src/client/svelte.ts src/plugins/index.ts src/providers/index.ts src/linkedProviders/index.ts src/vault/index.ts src/manifest.ts --root src --outdir dist --sourcemap --target=bun --external elysia --external react --external vue --external solid-js --external svelte --external @opentelemetry/api --external @simplewebauthn/browser --external @simplewebauthn/server --external @node-saml/node-saml && bun build src/cli/migrate.ts --outdir dist/cli --sourcemap --target=bun --external @neondatabase/serverless --external drizzle-orm && bun build src/fingerprint-client/index.ts --outdir dist/fingerprint-client --sourcemap --target=browser && bun run scripts/emitDeclarations.ts && chmod +x dist/cli/migrate.js && absolute-manifest emit",
20
+ "build": "rm -rf dist && bun build src/bun.ts src/index.ts src/server.ts src/agents/index.ts src/oidc/index.ts src/saml.ts src/webauthn.ts src/htmx/index.ts src/client/index.ts src/client/mobile.ts src/client/react.ts src/client/vue.ts src/client/solid.ts src/client/svelte.ts src/plugins/index.ts src/providers/index.ts src/linkedProviders/index.ts src/vault/index.ts src/manifest.ts --root src --outdir dist --sourcemap --target=bun --external elysia --external react --external vue --external solid-js --external svelte --external @opentelemetry/api --external @simplewebauthn/browser --external @simplewebauthn/server --external @node-saml/node-saml && bun build src/cli/migrate.ts --outdir dist/cli --sourcemap --target=bun --external @neondatabase/serverless --external drizzle-orm && bun build src/fingerprint-client/index.ts --outdir dist/fingerprint-client --sourcemap --target=browser && bun run scripts/emitDeclarations.ts && chmod +x dist/cli/migrate.js && absolute-manifest emit",
21
21
  "config": "absolute config",
22
22
  "test": "bun test",
23
23
  "format": "absolute prettier --write",
@@ -201,7 +201,12 @@
201
201
  "import": "./dist/manifest.js",
202
202
  "default": "./dist/manifest.js"
203
203
  },
204
- "./manifest.json": "./dist/manifest.json"
204
+ "./manifest.json": "./dist/manifest.json",
205
+ "./bun": {
206
+ "types": "./dist/bun.d.ts",
207
+ "import": "./dist/bun.js",
208
+ "require": "./dist/bun.js"
209
+ }
205
210
  },
206
211
  "type": "module",
207
212
  "files": [