@clivly/auth-better-auth 0.8.0 → 0.9.1
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 +57 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
# @clivly/auth-better-auth
|
|
2
2
|
|
|
3
|
-
[better-auth](https://better-auth.com) implementation of Clivly's
|
|
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`.
|
|
4
6
|
|
|
5
|
-
|
|
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:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
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"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Zero runtime dependencies.
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
6
38
|
|
|
7
39
|
```ts
|
|
8
|
-
import { createBetterAuthAdapter } from "
|
|
40
|
+
import { createBetterAuthAdapter } from "clivly/auth/better-auth";
|
|
9
41
|
import { auth } from "./auth"; // your betterAuth({ ... }) instance
|
|
10
42
|
|
|
11
43
|
const authAdapter = createBetterAuthAdapter({ auth });
|
|
@@ -13,7 +45,28 @@ const authAdapter = createBetterAuthAdapter({ auth });
|
|
|
13
45
|
const user = await authAdapter.getUser(request); // { id, email, name } | null
|
|
14
46
|
```
|
|
15
47
|
|
|
16
|
-
|
|
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
|
|
66
|
+
|
|
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)
|
|
17
70
|
|
|
18
71
|
## License
|
|
19
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clivly/auth-better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
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.
|
|
28
|
+
"@clivly/core": "0.9.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsdown": "^0.22.14",
|