@cauthyhq/node 1.2.0 → 1.3.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.
- package/CHANGELOG.md +30 -0
- package/README.md +16 -28
- package/dist/{cauthy-CCSSj3Lg.d.mts → cauthy-CsWUgyv_.d.mts} +42 -145
- package/dist/{cauthy-C7gZ-pbv.d.ts → cauthy-DHLBEuqP.d.ts} +42 -145
- package/dist/express.d.mts +2 -5
- package/dist/express.d.ts +2 -5
- package/dist/express.js +1 -2
- package/dist/express.js.map +1 -1
- package/dist/express.mjs +1 -2
- package/dist/express.mjs.map +1 -1
- package/dist/fastify.d.mts +1 -3
- package/dist/fastify.d.ts +1 -3
- package/dist/fastify.js +0 -2
- package/dist/fastify.js.map +1 -1
- package/dist/fastify.mjs +0 -2
- package/dist/fastify.mjs.map +1 -1
- package/dist/hono.d.mts +2 -5
- package/dist/hono.d.ts +2 -5
- package/dist/hono.js +1 -2
- package/dist/hono.js.map +1 -1
- package/dist/hono.mjs +1 -2
- package/dist/hono.mjs.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +187 -530
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -520
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs.map +1 -1
- package/dist/next.d.mts +1 -3
- package/dist/next.d.ts +1 -3
- package/dist/testing.d.mts +11 -5
- package/dist/testing.d.ts +11 -5
- package/dist/testing.js +52 -50
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +52 -50
- package/dist/testing.mjs.map +1 -1
- package/package.json +5 -14
- package/dist/identity-BTJ8NB_w.d.mts +0 -27
- package/dist/identity-BTJ8NB_w.d.ts +0 -27
- package/dist/keys-D5k0omTb.d.mts +0 -64
- package/dist/keys-D5k0omTb.d.ts +0 -64
- package/dist/keys.d.mts +0 -8
- package/dist/keys.d.ts +0 -8
- package/dist/keys.js +0 -157
- package/dist/keys.js.map +0 -1
- package/dist/keys.mjs +0 -129
- package/dist/keys.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
Contracts are retired, and contract mode is removed (not deprecated): an application once connected by contract runs on its `CAUTHY_KEY` alone, and its people stay signed in. Protect sign-in with the **Protect sign-in** switches on the application's card in Cauthy's dashboard.
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **On `CAUTHY_KEY`, people sign in through the client Cauthy names** (`sign_in_client_id` of `GET /v1/connect/self`, read at startup and every 5 minutes). An application once connected by contract has its key on the link's service client (`pact.<link>.service`) and its people, and their refresh tokens, on the link's sign-in client (`pact.<link>`): the authorize redirect, the code exchange, renewals, revocation, sign-out, the account page, the look and the hosted-page and invitation calls now go as that client. It is a public client: the key's assertion (`private_key_jwt`) proves the key's own client only, and the code exchange uses PKCE and carries the system's proof (`X-Cauthy-System-Token`). A renewal outside the handler waits for Cauthy's answer first, so a refresh token is never spent on the wrong client. When the two clients are the same, nothing changes.
|
|
10
|
+
- **The same key keeps every session**: a cookie sealed by 1.2.1 by contract on `CAUTHY_KEY` is read and renewed by 1.3 on the same key, without the `contract` option. `CAUTHY_KEY_PREVIOUS` still names the key's client.
|
|
11
|
+
- **`@cauthyhq/node/testing`**: `FakeCauthy.signInClients` (the key's client → the sign-in client `GET /v1/connect/self` names). The fake now binds a code to the client that asked for it and a refresh token to the client it was issued to, as Cauthy does.
|
|
12
|
+
- **"Keep me signed in" is the workspace's setting** (`persistent_sessions` of `GET /v1/auth/settings`, set with `PUT /v1/settings/auth`): `/methods.persistentSessions` follows it. `FakeCauthy` keeps it as a workspace setting and, as Cauthy does, refuses `allow_persistent_sessions` on a client with `400 persistent_sessions_moved`. The conformance script no longer passes the runner's ignored `--client-id`.
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
|
|
16
|
+
- **Contract mode**: the `contract` option, `auth.pact` (its JWKS route at the contract's `jwks_url` path, `keys` and `status()`), and the SDK-side `require_verified_email` check of a link (Cauthy enforces the client's switch at the token endpoint).
|
|
17
|
+
- **The 1.1 way of contracts**: `PACT_ROOT_KEY`, `PACT_ROOT_KEY_PREVIOUS`, the `keys` store and the `rootKey` / `rootKeyPrevious` options, including the read-only readers of 1.2 beside `CAUTHY_KEY`. Sessions sealed with `PACT_ROOT_KEY` and not read during the 1.2 rotation window are no longer read. `CAUTHY_SECRET` beside `CAUTHY_KEY` is still read-only for the window.
|
|
18
|
+
- **Exports**: `readContract`, `failClosed`, `STANDARD_VARIABLES` and the types `ContractOptions`, `ResolvedContract`, `PactItem`, `PactStatus`, `CauthyPact`, `KeyStore`, `PactKeys`, `StoredKey`; the whole `@cauthyhq/node/keys` entry (`memoryKeyStore`, `postgresKeyStore`, `fileKeyStore`, `pactKeysTableSql`, `Query`); `Identity.contract`, `FakeCauthy.contract` and the `CauthyKeyReason` `key_contract_issuer`.
|
|
19
|
+
|
|
20
|
+
### Refused at startup
|
|
21
|
+
|
|
22
|
+
A `CauthyConfigError` ("contracts are retired: run on CAUTHY_KEY alone, and remove …"), on `CAUTHY_KEY` and on the variables alike, naming everything to remove: the `contract`, `keys`, `rootKey` or `rootKeyPrevious` option, or `PACT_ROOT_KEY` or `PACT_ROOT_KEY_PREVIOUS` set in the environment. A deploy still configured for contracts never runs half-configured.
|
|
23
|
+
|
|
24
|
+
## 1.2.1
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Moving to `CAUTHY_KEY`**: a session sealed with `CAUTHY_SECRET`, `PACT_ROOT_KEY` or `CAUTHY_KEY_PREVIOUS` is sealed again with the key on the first request that reads it through the handler or an adapter (`GET <basePath>/session`, `req.cauthy()`, …), not only when its access token is renewed. A session read during the window now outlives the old secret's removal.
|
|
29
|
+
- `PACT_ROOT_KEY_PREVIOUS` beside `CAUTHY_KEY` and `PACT_ROOT_KEY` is read too: sessions sealed before a root rotation that was still open at the move stay readable. 1.2.0 read the current root only.
|
|
30
|
+
- A session cookie that no configured key opens is still cleared, and is now said once per process (`console.warn`), naming the secret to keep beside `CAUTHY_KEY` for the window.
|
|
31
|
+
- Covered end to end with the published packages: sessions signed in by `cauthy-auth` 0.41.0 and 0.42.0 (contract, `PACT_ROOT_KEY`, `keys`) and by `@cauthyhq/node` 1.1.0 (`CAUTHY_SECRET`), read by 1.2 at `GET /api/id/session`, fresh and renewed.
|
|
32
|
+
|
|
3
33
|
## 1.2.0
|
|
4
34
|
|
|
5
35
|
One variable for every application: `CAUTHY_KEY`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @cauthyhq/node
|
|
2
2
|
|
|
3
|
-
Cauthy for Node.js backends: sign-in, cookie sessions, organizations
|
|
3
|
+
Cauthy for Node.js backends: sign-in, cookie sessions, organizations and token verification, served as the [auth-bff protocol](https://github.com/vennet-developers/cauthy-sdk-spec) version 1, level `strict`.
|
|
4
4
|
|
|
5
5
|
The browser never holds a token. Your server mounts one route, keeps the session in an encrypted HttpOnly cookie, and every security setting (sign-in methods, second factors, session length) is a switch in Cauthy's dashboard, not code.
|
|
6
6
|
|
|
@@ -110,9 +110,11 @@ new is written with it.
|
|
|
110
110
|
|
|
111
111
|
**Moving from the variables of 1.1:** on the application's card, **Move to
|
|
112
112
|
CAUTHY_KEY**. Deploy with `CAUTHY_KEY` and keep `CAUTHY_SECRET` for the window
|
|
113
|
-
(old sessions stay readable
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
(old sessions stay readable, and each is sealed again with the key the first
|
|
114
|
+
time it is read; one warning says to remove it), remove the other variables,
|
|
115
|
+
then **Remove the secret**. A session nobody used during the window is lost
|
|
116
|
+
with the secret. The variables of 1.1 still work in 1.x with one
|
|
117
|
+
`DeprecationWarning` per process and leave in 2.0.
|
|
116
118
|
|
|
117
119
|
## Verifying a token
|
|
118
120
|
|
|
@@ -122,10 +124,9 @@ For an API that receives Cauthy access tokens from somewhere other than the brow
|
|
|
122
124
|
import { auth } from './auth'
|
|
123
125
|
|
|
124
126
|
// Where each value comes from:
|
|
125
|
-
// issuer the instance's own (CAUTHY_KEY
|
|
126
|
-
// tenantId
|
|
127
|
+
// issuer the instance's own (CAUTHY_KEY; deprecated: CAUTHY_ISSUER)
|
|
128
|
+
// tenantId on CAUTHY_KEY, Cauthy's answer; otherwise `tenantId` or CAUTHY_TENANT_ID (deprecated)
|
|
127
129
|
// audience on CAUTHY_KEY, Cauthy's answer; otherwise `audience` or CAUTHY_AUDIENCE (deprecated): your Cauthy's JWT_AUDIENCE
|
|
128
|
-
// clientId by contract, the link's sign-in client: a person's token issued through another is refused (wrong_client)
|
|
129
130
|
const verify = auth.tokenVerifier() // throws CauthyConfigError now if one is missing
|
|
130
131
|
const who = await verify(request) // or: await auth.verifyToken(request)
|
|
131
132
|
```
|
|
@@ -149,7 +150,7 @@ const verify = createTokenVerifier({ issuer: 'https://id.example.com', audience:
|
|
|
149
150
|
- **The audience and the workspace are required.** Without them a token issued for another application or workspace would be accepted.
|
|
150
151
|
- A system's own token (`sys` claim, whatever its value) and a guest's token (`anon: true`) are refused where a person is expected. Pass `allowSystem` or `allowAnonymous` for an endpoint that takes them.
|
|
151
152
|
- A client's own token (a `client_credentials` grant: `token_use: "client"`, whatever the value) is refused with `client_token` where a person is expected. A backend that serves machines too passes `allowClientTokens: true`; the identity then carries `clientId`, the client's public id (its `userId` is the client's internal id).
|
|
152
|
-
- `authorizedParty` is the token's `azp`: the client a person's token was issued through, absent when none was named. With `clientId
|
|
153
|
+
- `authorizedParty` is the token's `azp`: the client a person's token was issued through, absent when none was named. With `clientId`, a token whose `azp` names another client is refused with `wrong_client`; a token with no `azp` passes.
|
|
153
154
|
- Clock tolerance is 30 seconds (`leeway`, 0 to 60). A token over 8192 bytes, with a repeated JSON name, a fractional date or a wrongly typed claim is refused.
|
|
154
155
|
- Keys are fetched from `<issuer>/.well-known/jwks.json` with no redirect, within 5 seconds, at most 64 KiB, and kept for the answer's `max-age`.
|
|
155
156
|
|
|
@@ -160,7 +161,8 @@ const verify = createTokenVerifier({ issuer: 'https://id.example.com', audience:
|
|
|
160
161
|
| cauthy-auth 0.42 | @cauthyhq/node 1.0 |
|
|
161
162
|
| --- | --- |
|
|
162
163
|
| `cauthy-auth` | `@cauthyhq/node` |
|
|
163
|
-
| `cauthy-auth/express`, `/fastify`, `/hono`, `/next`, `/mcp`, `/
|
|
164
|
+
| `cauthy-auth/express`, `/fastify`, `/hono`, `/next`, `/mcp`, `/theme` | `@cauthyhq/node/express`, … (same names) |
|
|
165
|
+
| Contract mode (`contract`, `PACT_ROOT_KEY`, `cauthy-auth/keys`) | Removed in 1.3: run on `CAUTHY_KEY` (see [Contracts are retired](#contracts-are-retired)) |
|
|
164
166
|
| `cauthy-auth/react`, `/styles.css` | `@cauthyhq/react`, `@cauthyhq/react/styles.css` |
|
|
165
167
|
| `cauthy-auth/client` | `@cauthyhq/js` |
|
|
166
168
|
| `cauthy-auth/vue`, `/svelte` | No 1.0 wrapper yet: keep `cauthy-auth` 0.43 in the browser (security fixes until 2027-02-06) |
|
|
@@ -176,28 +178,14 @@ Everything that behaves differently from 0.42:
|
|
|
176
178
|
6. **http issuers are refused** except for `localhost`, `127.0.0.1`, `*.localhost` and `*.test`.
|
|
177
179
|
7. **Calls to Cauthy have a deadline**: 2 seconds for `auth.system` and the sign-in proof, 5 seconds for the sign-in screens' calls and for the code, refresh and userinfo calls (`timeouts`, below). 0.42 waited forever. `pushTheme`, `pushPolicy`, `pullPolicy`, `pushCatalog`, `pullCatalog` and `connectSystem` take `timeoutMs`.
|
|
178
180
|
8. **The Fastify plugin checks its mount on `onReady`** and fails startup when another route answers under the base path. It is skipped when `NODE_ENV=test`; `checkMount: false` turns it off.
|
|
179
|
-
9. **
|
|
180
|
-
10. **
|
|
181
|
-
11. **Error messages start with `@cauthyhq/node:`** instead of `cauthy-auth:`. Classes and codes are the same.
|
|
181
|
+
9. **A person whose address is not confirmed** gets no session when the application's **Protect sign-in** switch requires a verified email: Cauthy refuses the code exchange (`email_not_confirmed`), and the hosted callback redirects to your sign-in page with `auth_error=email_not_confirmed`.
|
|
182
|
+
10. **Error messages start with `@cauthyhq/node:`** instead of `cauthy-auth:`. Classes and codes are the same.
|
|
182
183
|
|
|
183
184
|
`/sign-in/anonymous`, `/me/upgrade` and `connectSystem` are deprecated: one `DeprecationWarning` per process, removed in 2.0.
|
|
184
185
|
|
|
185
|
-
##
|
|
186
|
+
## Contracts are retired
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
import { createCauthy } from '@cauthyhq/node'
|
|
191
|
-
import graph from './contracts/graph.json'
|
|
192
|
-
|
|
193
|
-
export const auth = createCauthy({ contract: { graph, system: 'acme-crm' } }) // and CAUTHY_KEY in the environment
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
The key proves the link's service client (`pact.<link>.service`); people sign in through its public client (`pact.<link>`). The key must name the graph's Cauthy (`key_contract_issuer` otherwise). The application publishes the key's public half at the contract's `jwks_url` path (`/.well-known/pact-jwks.json` by default), and the previous key's too during a rotation. The Express, Hono and Fastify adapters route that path to the handler as they do `/api/auth`, so those need no route of their own for it. **Next.js and TanStack Start still need a route file** for it that calls `auth.handler(request)`.
|
|
197
|
-
|
|
198
|
-
The 1.1 way (`PACT_ROOT_KEY` and `keys: postgresKeyStore(query)`) keeps working through 1.x with a deprecation warning. Moving: generate `CAUTHY_KEY` on the application's card, deploy it with `PACT_ROOT_KEY` and the `keys` option still beside it for the window (old sessions stay readable, its RS256 keys stay published beside the new Ed25519 key), then remove `PACT_ROOT_KEY`, the option and the table.
|
|
199
|
-
|
|
200
|
-
It refuses to start when any variable `CAUTHY_KEY` replaces is also set, when the link names its workspace by slug and the graph has no `tenant_id` for it yet, when a workspace named by id is pinned to a different `tenant_id`, when `system_proof` is not `off`, `auto` or `required`, or when the link asks for a system proof without a `service` block. When the link sets `require_verified_email`, a person whose address is not confirmed gets no session. See [`contract/pact.md`](https://github.com/vennet-developers/cauthy-sdk-spec/blob/main/contract/pact.md).
|
|
188
|
+
Contract mode is removed in 1.3: run on `CAUTHY_KEY` alone, and protect sign-in with the **Protect sign-in** switches on the application's card in Cauthy's dashboard. The `contract`, `keys`, `rootKey` and `rootKeyPrevious` options, and `PACT_ROOT_KEY` or `PACT_ROOT_KEY_PREVIOUS` in the environment, refuse to start with a `CauthyConfigError` naming them.
|
|
201
189
|
|
|
202
190
|
## Options added in 1.0
|
|
203
191
|
|
|
@@ -207,7 +195,7 @@ It refuses to start when any variable `CAUTHY_KEY` replaces is also set, when th
|
|
|
207
195
|
| `timeouts.system` | `2000` | Deadline in milliseconds of the application's own calls to Cauthy (`auth.system`, the sign-in proof) |
|
|
208
196
|
| `timeouts.request` | `5000` | Deadline in milliseconds of the sign-in screens' calls and of the code, refresh and userinfo calls |
|
|
209
197
|
| `audience` | `CAUTHY_AUDIENCE` | The audience `auth.verifyToken` accepts |
|
|
210
|
-
| `tenantId` | `CAUTHY_TENANT_ID` | The workspace id `auth.verifyToken` accepts
|
|
198
|
+
| `tenantId` | `CAUTHY_TENANT_ID` | The workspace id `auth.verifyToken` accepts |
|
|
211
199
|
|
|
212
200
|
## Testing your application
|
|
213
201
|
|
|
@@ -1,95 +1,5 @@
|
|
|
1
|
-
import { K as KeyStore, P as PactKeys } from './keys-D5k0omTb.mjs';
|
|
2
1
|
import { JWTVerifyGetKey, JWK } from 'jose';
|
|
3
2
|
import { CauthyTheme } from './theme.mjs';
|
|
4
|
-
import { I as Identity } from './identity-BTJ8NB_w.mjs';
|
|
5
|
-
|
|
6
|
-
/** What createCauthy is given to run by contract. */
|
|
7
|
-
interface ContractOptions {
|
|
8
|
-
/** The context graph, as `cauthy contracts pull` writes it (contracts/graph.json). */
|
|
9
|
-
graph: unknown;
|
|
10
|
-
/** This application's system in the graph: `"acme-crm"`. */
|
|
11
|
-
system: string;
|
|
12
|
-
/** The link to read, when the system has more than one with Cauthy. */
|
|
13
|
-
link?: string;
|
|
14
|
-
/** Cauthy's system in the graph. Default: `"cauthy"`. */
|
|
15
|
-
provider?: string;
|
|
16
|
-
}
|
|
17
|
-
/** What an application reads of its contract. */
|
|
18
|
-
interface ResolvedContract {
|
|
19
|
-
system: string;
|
|
20
|
-
link: string;
|
|
21
|
-
/** Cauthy's public address. */
|
|
22
|
-
issuer: string;
|
|
23
|
-
/** The workspace's id, and its slug (what the application's own screens send). */
|
|
24
|
-
tenantId: string;
|
|
25
|
-
tenant: string;
|
|
26
|
-
/** The public client people sign in with: `pact.<link>`. */
|
|
27
|
-
clientId: string;
|
|
28
|
-
/** Where people may return after signing in. */
|
|
29
|
-
redirectUris: string[];
|
|
30
|
-
/** Whether Cauthy asks the system's proof on the code exchange now (`systemProof` is `required`). */
|
|
31
|
-
requireSystemProof: boolean;
|
|
32
|
-
/** How the link asks for the proof: never, from the first proved sign-in on (`auto`), or always. */
|
|
33
|
-
systemProof: 'off' | 'auto' | 'required';
|
|
34
|
-
/** Whether Cauthy issues no token through this link before the address is confirmed. */
|
|
35
|
-
requireVerifiedEmail: boolean;
|
|
36
|
-
/** Whether the link lets its people ask to stay signed in. */
|
|
37
|
-
persistentSessions: boolean;
|
|
38
|
-
/** The system's own client, when the link gives it one: `pact.<link>.service`. */
|
|
39
|
-
serviceClientId?: string;
|
|
40
|
-
/** Where the system publishes its keys, and the path of that address. */
|
|
41
|
-
jwksUrl?: string;
|
|
42
|
-
jwksPath?: string;
|
|
43
|
-
/** Where the system receives Cauthy's events, when it says. */
|
|
44
|
-
eventsUrl?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The variables of the standard mode. With a contract none may be set: two
|
|
48
|
-
* sources of the same thing, one silently winning, is how a system ends up
|
|
49
|
-
* signing people in through a client nobody meant.
|
|
50
|
-
*/
|
|
51
|
-
declare const STANDARD_VARIABLES: readonly ["CAUTHY_ISSUER", "CAUTHY_CLIENT_ID", "CAUTHY_CLIENT_SECRET", "CAUTHY_SECRET", "CAUTHY_SYSTEM", "CAUTHY_TENANT", "CAUTHY_SYSTEM_KEY", "CAUTHY_SYSTEM_KEY_ID"];
|
|
52
|
-
/** Refuses to run by contract with a variable of the standard mode set: names it. */
|
|
53
|
-
declare function failClosed(environment: Record<string, string | undefined> | undefined): void;
|
|
54
|
-
/** Reads what the graph says of the system's link with Cauthy. */
|
|
55
|
-
declare function readContract(options: ContractOptions): ResolvedContract;
|
|
56
|
-
/** One difference between a contract and what Cauthy holds. */
|
|
57
|
-
interface PactItem {
|
|
58
|
-
kind: 'client' | 'redirect_uri' | 'grant_type' | 'role' | 'organization' | 'require_system_proof' | 'persistent_sessions' | 'jwks_url';
|
|
59
|
-
client_id?: string;
|
|
60
|
-
value: string;
|
|
61
|
-
detail?: string;
|
|
62
|
-
}
|
|
63
|
-
/** How the system stands against its contract, as Cauthy checks it (GET /v1/pact/status). Moments are UTC. */
|
|
64
|
-
interface PactStatus {
|
|
65
|
-
system: string;
|
|
66
|
-
tenant_id: string;
|
|
67
|
-
checked_at: string;
|
|
68
|
-
/** When Cauthy's daily reconciliation last checked it; null before the first. */
|
|
69
|
-
reconciled_at: string | null;
|
|
70
|
-
in_step: boolean;
|
|
71
|
-
/** In Cauthy, and the contract does not name it. Nothing is ever deleted for it. */
|
|
72
|
-
outside: PactItem[];
|
|
73
|
-
/** Named by the contract, and Cauthy does not hold it as it says. */
|
|
74
|
-
missing: PactItem[];
|
|
75
|
-
contract: {
|
|
76
|
-
clients: {
|
|
77
|
-
client_id: string;
|
|
78
|
-
link: string;
|
|
79
|
-
purpose: 'sign_in' | 'service';
|
|
80
|
-
redirect_uris?: string[];
|
|
81
|
-
grant_types: string[];
|
|
82
|
-
require_system_proof?: boolean;
|
|
83
|
-
jwks_url?: string;
|
|
84
|
-
}[];
|
|
85
|
-
roles?: Record<string, string[]>;
|
|
86
|
-
};
|
|
87
|
-
held: {
|
|
88
|
-
clients: Record<string, unknown>[];
|
|
89
|
-
roles: string[];
|
|
90
|
-
organizations: Record<string, number>;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
3
|
|
|
94
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
95
5
|
interface CauthyEvent {
|
|
@@ -157,7 +67,7 @@ interface CauthyOptions {
|
|
|
157
67
|
* `CAUTHY_KEY`. With it nothing else is read: the workspace, the system and
|
|
158
68
|
* the application's addresses come from Cauthy (`GET /v1/connect/self`),
|
|
159
69
|
* and passing `issuer`, `clientId`, `clientSecret`, `secret`, `system`,
|
|
160
|
-
* `tenant`, `audience`, `tenantId
|
|
70
|
+
* `tenant`, `audience`, `tenantId` or `systemKey` is refused.
|
|
161
71
|
*/
|
|
162
72
|
key?: string;
|
|
163
73
|
/** The key being replaced, during a rotation: read, never written with. Default: `CAUTHY_KEY_PREVIOUS`. */
|
|
@@ -203,8 +113,8 @@ interface CauthyOptions {
|
|
|
203
113
|
*/
|
|
204
114
|
audience?: string;
|
|
205
115
|
/**
|
|
206
|
-
* The workspace's id (a lowercase UUID) for `auth.verifyToken`.
|
|
207
|
-
* it
|
|
116
|
+
* The workspace's id (a lowercase UUID) for `auth.verifyToken`. On
|
|
117
|
+
* CAUTHY_KEY it is Cauthy's answer; otherwise: this, or `CAUTHY_TENANT_ID`.
|
|
208
118
|
*/
|
|
209
119
|
tenantId?: string;
|
|
210
120
|
/**
|
|
@@ -268,23 +178,18 @@ interface CauthyOptions {
|
|
|
268
178
|
request?: number;
|
|
269
179
|
};
|
|
270
180
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* createCauthy({ contract: { graph, system: 'acme-crm' }, keys: postgresKeyStore(query) })
|
|
277
|
-
*/
|
|
278
|
-
contract?: ContractOptions;
|
|
279
|
-
/** Where the application keeps its own key, with a contract (@cauthyhq/node/keys). */
|
|
280
|
-
keys?: KeyStore;
|
|
281
|
-
/**
|
|
282
|
-
* The one secret of a contracted application: every key it needs is
|
|
283
|
-
* derived from it. 32 random bytes or more. Default: `PACT_ROOT_KEY`.
|
|
181
|
+
* Removed in 1.3: contracts are retired. Given, `createCauthy` refuses to
|
|
182
|
+
* start (as it does with `PACT_ROOT_KEY` or `PACT_ROOT_KEY_PREVIOUS` set):
|
|
183
|
+
* run on CAUTHY_KEY alone, and protect sign-in with the "Protect sign-in"
|
|
184
|
+
* switches on the application's card in Cauthy's dashboard.
|
|
284
185
|
*/
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
|
|
186
|
+
contract?: never;
|
|
187
|
+
/** Removed in 1.3 with contracts: given, `createCauthy` refuses to start. */
|
|
188
|
+
keys?: never;
|
|
189
|
+
/** Removed in 1.3 with contracts (it was `PACT_ROOT_KEY`): given, `createCauthy` refuses to start. */
|
|
190
|
+
rootKey?: never;
|
|
191
|
+
/** Removed in 1.3 with contracts (it was `PACT_ROOT_KEY_PREVIOUS`): given, `createCauthy` refuses to start. */
|
|
192
|
+
rootKeyPrevious?: never;
|
|
288
193
|
/**
|
|
289
194
|
* Where `auth.webhook` remembers the deliveries it took, so one sent twice
|
|
290
195
|
* is refused. Default: this process's memory. Give a shared one (a table)
|
|
@@ -411,7 +316,7 @@ declare class CauthyConfigError extends Error {
|
|
|
411
316
|
constructor(message: string);
|
|
412
317
|
}
|
|
413
318
|
/** Why a CAUTHY_KEY was refused (key/cauthy-key.md §3, §8, §9). */
|
|
414
|
-
type CauthyKeyReason = 'key_format' | 'key_version' | 'key_checksum' | 'key_issuer' | 'key_client' | 'key_secret' | '
|
|
319
|
+
type CauthyKeyReason = 'key_format' | 'key_version' | 'key_checksum' | 'key_issuer' | 'key_client' | 'key_secret' | 'key_previous_mismatch';
|
|
415
320
|
/** A refused CAUTHY_KEY. The message names the reason, never the key. */
|
|
416
321
|
declare class CauthyKeyError extends CauthyConfigError {
|
|
417
322
|
readonly reason: CauthyKeyReason;
|
|
@@ -703,17 +608,10 @@ interface SystemOptions {
|
|
|
703
608
|
* client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
|
|
704
609
|
*/
|
|
705
610
|
acceptInviteUrl?: string;
|
|
706
|
-
/**
|
|
707
|
-
* The application's own keys, kept in its database (contract mode): it
|
|
708
|
-
* signs with the newest and publishes them. Takes the place of `key`.
|
|
709
|
-
*/
|
|
710
|
-
keys?: PactKeys;
|
|
711
|
-
/** The client the keys prove: the system's own, beside the sign-in client. */
|
|
712
|
-
keysClientId?: string;
|
|
713
611
|
/**
|
|
714
612
|
* CAUTHY_KEY's Ed25519 key (key/cauthy-key.md §6) and the client it proves:
|
|
715
|
-
* every token is asked with an EdDSA assertion. Takes the place of `key
|
|
716
|
-
*
|
|
613
|
+
* every token is asked with an EdDSA assertion. Takes the place of `key`
|
|
614
|
+
* and the secret.
|
|
717
615
|
*/
|
|
718
616
|
signer?: {
|
|
719
617
|
clientId: string;
|
|
@@ -939,8 +837,8 @@ interface VerifyTokenOptions {
|
|
|
939
837
|
/**
|
|
940
838
|
* The client this backend signs people in through. When set, a person's
|
|
941
839
|
* token issued through another client (an `azp` naming another) is refused
|
|
942
|
-
* with `wrong_client` (rule R15); a token with no `azp` passes.
|
|
943
|
-
*
|
|
840
|
+
* with `wrong_client` (rule R15); a token with no `azp` passes. Default:
|
|
841
|
+
* none, and `azp` is not checked.
|
|
944
842
|
*/
|
|
945
843
|
clientId?: string;
|
|
946
844
|
}
|
|
@@ -988,6 +886,25 @@ declare function createVerifierFromEnv(options?: Omit<VerifyTokenOptions, 'issue
|
|
|
988
886
|
*/
|
|
989
887
|
type MountTarget = string | ((request: Request) => Response | Promise<Response>);
|
|
990
888
|
|
|
889
|
+
/** What `GET /v1/connect/self` answers. */
|
|
890
|
+
interface Identity {
|
|
891
|
+
issuer: string;
|
|
892
|
+
audience: string;
|
|
893
|
+
tenant: {
|
|
894
|
+
id: string;
|
|
895
|
+
slug: string;
|
|
896
|
+
};
|
|
897
|
+
system: string;
|
|
898
|
+
client_id: string;
|
|
899
|
+
sign_in_client_id: string;
|
|
900
|
+
app_urls: string[];
|
|
901
|
+
callback_path: string;
|
|
902
|
+
key: {
|
|
903
|
+
kid: string;
|
|
904
|
+
retires_at: string | null;
|
|
905
|
+
} | null;
|
|
906
|
+
}
|
|
907
|
+
|
|
991
908
|
/** What `resolve` answers: who is there, and the cookies that must go back. */
|
|
992
909
|
interface Resolved {
|
|
993
910
|
session: Session | null;
|
|
@@ -1071,10 +988,9 @@ interface Cauthy {
|
|
|
1071
988
|
/**
|
|
1072
989
|
* Verifies a Cauthy access token (or a request's `Authorization: Bearer`) for
|
|
1073
990
|
* an API of this application: `verifyToken` with this instance's issuer, its
|
|
1074
|
-
* workspace (
|
|
1075
|
-
* `CAUTHY_TENANT_ID`) and its audience (
|
|
1076
|
-
*
|
|
1077
|
-
* client than the link's (`wrong_client`).
|
|
991
|
+
* workspace (on CAUTHY_KEY, Cauthy's answer; otherwise `tenantId` or
|
|
992
|
+
* `CAUTHY_TENANT_ID`) and its audience (on CAUTHY_KEY, Cauthy's answer;
|
|
993
|
+
* otherwise `audience` or `CAUTHY_AUDIENCE`).
|
|
1078
994
|
*/
|
|
1079
995
|
verifyToken(from: string | Request | Headers, options?: Partial<VerifyTokenOptions>): Promise<TokenIdentity>;
|
|
1080
996
|
/** The same, built once: throws `CauthyConfigError` now if the audience or the workspace is missing. */
|
|
@@ -1085,11 +1001,6 @@ interface Cauthy {
|
|
|
1085
1001
|
* `systemKey`.
|
|
1086
1002
|
*/
|
|
1087
1003
|
system: CauthySystem;
|
|
1088
|
-
/**
|
|
1089
|
-
* The application's contract, when it runs by one: what its link says,
|
|
1090
|
-
* its own keys, and how it stands against its contract in Cauthy.
|
|
1091
|
-
*/
|
|
1092
|
-
pact?: CauthyPact;
|
|
1093
1004
|
/** What the browser may be told of a session. */
|
|
1094
1005
|
toPublic(session: Session): Promise<PublicSession>;
|
|
1095
1006
|
/** Paths of this application that start a sign-in, a sign-out, or open the account page. */
|
|
@@ -1101,20 +1012,6 @@ interface Cauthy {
|
|
|
1101
1012
|
};
|
|
1102
1013
|
options: Readonly<Required<Pick<CauthyOptions, 'issuer' | 'clientId' | 'basePath' | 'afterSignIn' | 'afterSignOut' | 'cookieName'>>>;
|
|
1103
1014
|
}
|
|
1104
|
-
/** A contracted application's view of its contract (`auth.pact`). */
|
|
1105
|
-
interface CauthyPact {
|
|
1106
|
-
/** What its link in the graph says. */
|
|
1107
|
-
contract: ResolvedContract;
|
|
1108
|
-
/** Its own keys: the one that signs, the ones published, rotating them. */
|
|
1109
|
-
keys: PactKeys;
|
|
1110
|
-
/**
|
|
1111
|
-
* The response for its jwks_url: the published keys. `handler` serves it
|
|
1112
|
-
* at that path too, when the route reaches it.
|
|
1113
|
-
*/
|
|
1114
|
-
jwks(): Promise<Response>;
|
|
1115
|
-
/** How it stands against its contract, as Cauthy checks it now. For a health endpoint. */
|
|
1116
|
-
status(): Promise<PactStatus>;
|
|
1117
|
-
}
|
|
1118
1015
|
declare function createCauthy(given?: CauthyOptions): Cauthy;
|
|
1119
1016
|
|
|
1120
|
-
export {
|
|
1017
|
+
export { memoryReplayStore as $, type AttributeType as A, type RoleOf as B, type Cauthy as C, type SessionOrganization as D, type SessionStatus as E, type SessionUser as F, type SystemKey as G, type SystemOptions as H, type Identity as I, type JsonValue as J, type SystemPolicy as K, type TokenRefusal as L, type MountTarget as M, type NewMember as N, type Organization as O, type PermissionOf as P, type VerifyWebhookOptions as Q, type ReplayStore as R, type Session as S, type TokenIdentity as T, can as U, type VerifyTokenOptions as V, createCauthy as W, createSystem as X, createTokenVerifier as Y, createVerifierFromEnv as Z, definePolicy as _, type CatalogResource as a, policySource as a0, pullCatalog as a1, pullPolicy as a2, pushCatalog as a3, pushPolicy as a4, remoteKeys as a5, verifyToken as a6, verifyWebhook as a7, CauthyApiError as b, CauthyConfigError as c, type CauthyEvent as d, CauthyKeyError as e, type CauthyKeyReason as f, type CauthyOptions as g, type CauthySystem as h, CauthyTokenError as i, CauthyUnavailableError as j, CauthyWebhookError as k, type CheckOf as l, type CheckQuestion as m, type CheckResult as n, type CheckRule as o, type ConditionalPermission as p, type OrganizationMember as q, type OrganizationRef as r, type Permitted as s, type Policy as t, type PolicyDefinition as u, type PolicyPermission as v, type PolicyRole as w, type PublicSession as x, type PushPolicyOptions as y, type Resolved as z };
|