@clivly/auth-better-auth 0.7.2 → 0.7.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/README.md +53 -16
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,35 +1,72 @@
1
1
  # @clivly/auth-better-auth
2
2
 
3
- better-auth implementation of Clivly's `ClivlyAuthAdapter`. It resolves the
4
- current end-user through `auth.api.getSession({ headers })` on each request.
3
+ [better-auth](https://better-auth.com) implementation of Clivly's
4
+ `ClivlyAuthAdapter`. Resolves a CRM end-user's identity from the host app's
5
+ better-auth session via `auth.api.getSession`.
5
6
 
6
- ## Install
7
+ It answers **"who is this person?"** only. CRM authorization lives separately in
8
+ Clivly's `crm_members` layer.
9
+
10
+ > **Optional.** You do not need an auth adapter to sync data into Clivly. Only
11
+ > reach for one when a Clivly surface must resolve which of *your* users is
12
+ > making a request.
13
+
14
+ ## Prerequisites
15
+
16
+ | Requirement | Version / note |
17
+ | --- | --- |
18
+ | Node.js | **≥ 22** |
19
+ | A `betterAuth({...})` instance | You pass your own — there is **no peer dependency** and no `better-auth` version to keep in lockstep |
20
+
21
+ ## Installation
22
+
23
+ Two equivalent import paths — pick whichever matches how you installed Clivly:
7
24
 
8
25
  ```bash
9
- npm install @clivly/auth-better-auth better-auth
26
+ # If you already installed `clivly` (recommended — this is what `clivly init` does)
27
+ # nothing extra to install
28
+ # → import from "clivly/auth/better-auth"
29
+
30
+ # Or standalone
31
+ npm install @clivly/auth-better-auth
32
+ # → import from "@clivly/auth-better-auth"
10
33
  ```
11
34
 
12
- This adapter is a Tier 2 surface in
13
- [STABILITY.md](https://github.com/amani-joseph/clivly.com/blob/master/STABILITY.md).
35
+ Zero runtime dependencies.
14
36
 
15
- ## Usage
37
+ ## Quick start
16
38
 
17
39
  ```ts
18
- import { createBetterAuthAdapter } from "@clivly/auth-better-auth";
19
- import { auth } from "./auth";
40
+ import { createBetterAuthAdapter } from "clivly/auth/better-auth";
41
+ import { auth } from "./auth"; // your betterAuth({ ... }) instance
20
42
 
21
43
  const authAdapter = createBetterAuthAdapter({ auth });
22
44
 
23
- const user = await authAdapter.getUser(request);
24
- // { id, email, name } | null
45
+ const user = await authAdapter.getUser(request); // { id, email, name } | null
25
46
  ```
26
47
 
27
- The package does not bundle its own better-auth runtime. You pass your existing
28
- `betterAuth({...})` instance in.
48
+ ## Options
49
+
50
+ | Option | Type | Required | Notes |
51
+ | --- | --- | --- | --- |
52
+ | `auth` | `BetterAuthLike` | Yes | Anything exposing `api.getSession({ headers })` — your `betterAuth({...})` instance satisfies this structurally |
53
+
54
+ ## Behaviour
55
+
56
+ - Returns `null` when there is no session, or when the session user has no
57
+ email address (Clivly requires one).
58
+ - `betterAuthUserToClivlyUser` is exported separately if you already hold a
59
+ better-auth user object and only need the mapping.
60
+
61
+ `clivly init` detects a better-auth instance in your project and wires it into
62
+ the scaffolded auth-verify route. Pass `--auth-import <specifier>` when it lives
63
+ across a package boundary the on-disk probe cannot see.
64
+
65
+ ## Related documentation
29
66
 
30
- Returns `null` when there is no session, or when the session user cannot be
31
- mapped to a Clivly user. The adapter only answers identity; CRM authorization
32
- still lives in Clivly's separate `crm_members` layer.
67
+ - **[Connecting to Clivly Cloud](https://github.com/amani-joseph/clivly.com/blob/master/docs/guides/connecting-to-clivly-cloud.md#auth-adapters-optional)** — where auth adapters fit in the setup
68
+ - [`@clivly/core` README](https://github.com/amani-joseph/clivly.com/blob/master/packages/core/README.md) — the `ClivlyAuthAdapter` contract
69
+ - [`clivly` CLI README](https://github.com/amani-joseph/clivly.com/blob/master/packages/cli/README.md)
33
70
 
34
71
  ## License
35
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clivly/auth-better-auth",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "better-auth implementation of Clivly's ClivlyAuthAdapter.",
@@ -25,7 +25,7 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "@clivly/core": "0.7.2"
28
+ "@clivly/core": "0.7.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "tsdown": "^0.22.14",