@bitakit/better-auth 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/AGENTS.md +43 -0
  2. package/package.json +3 -2
package/AGENTS.md ADDED
@@ -0,0 +1,43 @@
1
+ # @bitakit/better-auth — guide for agents
2
+
3
+ > For agents building an app with this package (it ships in `node_modules/@bitakit/better-auth`).
4
+ > To change the package itself, follow the repository's own AGENTS.md instead.
5
+
6
+ Connects an existing Better Auth client to BitaKit: it provides the shared `auth` service
7
+ (session snapshot, changes, sign-out) that every plugin reads. It has no UI (that is
8
+ `@bitakit/better-auth-ui`) and is no server permission check.
9
+
10
+ ## Setup an app has
11
+
12
+ - The client arrives through the `betterAuthClient` contract, provided once by the app:
13
+
14
+ ```ts
15
+ // src/services/better-auth-client.ts
16
+ import { defineService } from '@bitakit/core';
17
+ import { betterAuthClient } from '@bitakit/better-auth';
18
+ import { authClient } from '../lib/auth-client';
19
+
20
+ export default defineService(() => ({ client: authClient }), { provides: betterAuthClient });
21
+ ```
22
+
23
+ Keep the `{ client }` wrapper; without the service, startup fails with a named error.
24
+
25
+ - Options in `src/configs/better-auth.ts`: `paths` (`signIn`, `afterSignIn`, `afterSignOut`),
26
+ optional `signIn`/`signOut` overrides.
27
+ - `createBetterAuthClient` (`./client`) creates the standard browser client with organization,
28
+ multi-session, API key and two-factor client extensions; the server must enable the same.
29
+
30
+ ## Use it
31
+
32
+ - Read the session with `useAuth()` from `@bitakit/ui` or `getService(services, authService)`;
33
+ check `app.has('auth')` when it is optional.
34
+ - Organizations: `betterAuthOrganizations(client)` (`./organizations`) is the backend for
35
+ `@bitakit/organizations`, provided as `organizationBackend`.
36
+ - E-mail: `betterAuthEmail(emailService, { invitationURL })` (`./email`) gives the server
37
+ callbacks for verification, reset and invitation mail on the `@bitakit/email` contract.
38
+
39
+ ## Rules
40
+
41
+ - Authorization happens on the server (Better Auth access control and the app's routes); the
42
+ client session and an active organization ID prove nothing.
43
+ - Do not build a second session store or login flow; keep Better Auth's native APIs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitakit/better-auth",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "bitakit": {
6
6
  "plugin": "./plugin",
@@ -9,7 +9,8 @@
9
9
  "sideEffects": false,
10
10
  "files": [
11
11
  "dist",
12
- "README.md"
12
+ "README.md",
13
+ "AGENTS.md"
13
14
  ],
14
15
  "exports": {
15
16
  ".": {