@clivly/auth-clerk 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 +65 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,24 +1,82 @@
|
|
|
1
1
|
# @clivly/auth-clerk
|
|
2
2
|
|
|
3
|
-
[Clerk](https://clerk.com) implementation of Clivly's `ClivlyAuthAdapter`.
|
|
3
|
+
[Clerk](https://clerk.com) implementation of Clivly's `ClivlyAuthAdapter`.
|
|
4
|
+
Resolves a CRM end-user's identity from the host app's Clerk session on each
|
|
5
|
+
request.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> compatibility coverage is still growing.
|
|
7
|
+
It answers **"who is this person?"** only. CRM authorization lives separately in
|
|
8
|
+
Clivly's `crm_members` layer.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
> **Preview-quality surface.** The email mapper and session resolution are
|
|
11
|
+
> unit-tested; broader host-app compatibility coverage is still growing.
|
|
12
|
+
|
|
13
|
+
> **Optional.** You do not need an auth adapter to sync data into Clivly. Only
|
|
14
|
+
> reach for one when a Clivly surface must resolve which of *your* users is
|
|
15
|
+
> making a request.
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
| Requirement | Version / note |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Node.js | **≥ 22** |
|
|
22
|
+
| `@clerk/backend` | **≥ 1** — a peer dependency you install yourself |
|
|
23
|
+
| Clerk secret key | `sk_…` from your Clerk dashboard |
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Two equivalent import paths — pick whichever matches how you installed Clivly:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# If you already installed `clivly` (recommended — this is what `clivly init` does)
|
|
31
|
+
npm install @clerk/backend
|
|
32
|
+
# → import from "clivly/auth/clerk"
|
|
33
|
+
|
|
34
|
+
# Or standalone
|
|
35
|
+
npm install @clivly/auth-clerk @clerk/backend
|
|
36
|
+
# → import from "@clivly/auth-clerk"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
10
40
|
|
|
11
41
|
```ts
|
|
12
|
-
import { createClerkAuthAdapter } from "
|
|
42
|
+
import { createClerkAuthAdapter } from "clivly/auth/clerk";
|
|
13
43
|
|
|
14
44
|
const authAdapter = createClerkAuthAdapter({
|
|
15
45
|
secretKey: process.env.CLERK_SECRET_KEY!,
|
|
16
|
-
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
|
|
17
46
|
});
|
|
18
47
|
|
|
19
48
|
const user = await authAdapter.getUser(request); // { id, email, name } | null
|
|
20
49
|
```
|
|
21
50
|
|
|
51
|
+
## Options
|
|
52
|
+
|
|
53
|
+
| Option | Type | Required | Notes |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| `secretKey` | `string` | Yes | Clerk secret key (`sk_…`) |
|
|
56
|
+
| `publishableKey` | `string` | No | Clerk publishable key (`pk_…`). Improves handshake reliability |
|
|
57
|
+
| `authorizedParties` | `string[]` | No | Origins allowed to make authenticated requests (CSRF protection) |
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const authAdapter = createClerkAuthAdapter({
|
|
61
|
+
secretKey: process.env.CLERK_SECRET_KEY!,
|
|
62
|
+
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
|
|
63
|
+
authorizedParties: ["https://app.example.com"],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Behaviour
|
|
68
|
+
|
|
69
|
+
- Returns `null` when there is no authenticated session, or when the session
|
|
70
|
+
user has no email address (Clivly requires one).
|
|
71
|
+
- `clerkUserToClivlyUser` is exported separately if you already hold a Clerk
|
|
72
|
+
user object and only need the mapping.
|
|
73
|
+
|
|
74
|
+
## Related documentation
|
|
75
|
+
|
|
76
|
+
- **[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
|
|
77
|
+
- [`@clivly/core` README](https://github.com/amani-joseph/clivly.com/blob/master/packages/core/README.md) — the `ClivlyAuthAdapter` contract
|
|
78
|
+
- [`clivly` CLI README](https://github.com/amani-joseph/clivly.com/blob/master/packages/cli/README.md)
|
|
79
|
+
|
|
22
80
|
## License
|
|
23
81
|
|
|
24
82
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clivly/auth-clerk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerk 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
|
"peerDependencies": {
|
|
31
31
|
"@clerk/backend": ">=1"
|