@cauthyhq/node 1.2.1 → 1.3.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/CHANGELOG.md +31 -7
- package/README.md +10 -29
- package/dist/{cauthy-CCSSj3Lg.d.mts → cauthy-DHRZLndK.d.mts} +31 -147
- package/dist/{cauthy-C7gZ-pbv.d.ts → cauthy-JSYh7J2o.d.ts} +31 -147
- 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 +159 -524
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -514
- 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 +51 -49
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +51 -49
- package/dist/testing.mjs.map +1 -1
- package/package.json +3 -15
- 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,13 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Removed
|
|
6
|
+
|
|
7
|
+
- The startup refusal 1.3.0 gave a deploy still configured for a contract, and the `contract`, `keys`, `rootKey` and `rootKeyPrevious` option stubs: what is left of that configuration is ignored.
|
|
8
|
+
- `FakeCauthy` no longer answers a `contract` field on `GET /v1/connect/self`, as Cauthy does not.
|
|
9
|
+
|
|
10
|
+
## 1.3.0
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **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.
|
|
17
|
+
- **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.
|
|
18
|
+
- **`@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.
|
|
19
|
+
- **"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`.
|
|
20
|
+
|
|
21
|
+
### Removed
|
|
22
|
+
|
|
23
|
+
- **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).
|
|
24
|
+
- **The 1.1 way of contracts**: the contract root keys, the `keys` store and the `rootKey` / `rootKeyPrevious` options, including the read-only readers of 1.2 beside `CAUTHY_KEY`. Sessions sealed with the contract 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.
|
|
25
|
+
- **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`.
|
|
26
|
+
|
|
3
27
|
## 1.2.1
|
|
4
28
|
|
|
5
29
|
### Fixed
|
|
6
30
|
|
|
7
|
-
- **Moving to `CAUTHY_KEY`**: a session sealed with `CAUTHY_SECRET`,
|
|
8
|
-
-
|
|
31
|
+
- **Moving to `CAUTHY_KEY`**: a session sealed with `CAUTHY_SECRET`, the contract 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.
|
|
32
|
+
- the previous contract root key beside `CAUTHY_KEY` and the contract 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.
|
|
9
33
|
- 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.
|
|
10
|
-
- Covered end to end with the published packages: sessions signed in by `cauthy-auth` 0.41.0 and 0.42.0 (contract,
|
|
34
|
+
- Covered end to end with the published packages: sessions signed in by `cauthy-auth` 0.41.0 and 0.42.0 (contract, the contract root key, `keys`) and by `@cauthyhq/node` 1.1.0 (`CAUTHY_SECRET`), read by 1.2 at `GET /api/id/session`, fresh and renewed.
|
|
11
35
|
|
|
12
36
|
## 1.2.0
|
|
13
37
|
|
|
@@ -19,7 +43,7 @@ One variable for every application: `CAUTHY_KEY`.
|
|
|
19
43
|
- **Startup**: a damaged key throws `CauthyKeyError` at once with its reason (`key_format`, `key_version`, `key_checksum`, `key_issuer`, `key_client`, `key_secret`, `key_contract_issuer`, `key_previous_mismatch`), never the value. Cauthy unreachable: the server starts and `/api/auth/*` answers `503 unavailable` until Cauthy answers. Cauthy refusing the key: `503 misconfigured`, logged once with the `kid`. `auth.ready()` awaits the identity.
|
|
20
44
|
- **The redirect URI** comes from the request's origin when it is one of the application's addresses in Cauthy, else the only one; otherwise `400 unknown_origin`.
|
|
21
45
|
- **A contract on top of the key**: `createCauthy({ contract: { graph, system } })` with `CAUTHY_KEY` needs no key store and no table. The key proves the link's service client; the JWKS route publishes the key's Ed25519 public half (and the previous key's during a rotation). The key must name the graph's Cauthy.
|
|
22
|
-
- **`CAUTHY_KEY_PREVIOUS`** (`keyPrevious`) for rotations: its sessions are read, never written. `CAUTHY_SECRET` and
|
|
46
|
+
- **`CAUTHY_KEY_PREVIOUS`** (`keyPrevious`) for rotations: its sessions are read, never written. `CAUTHY_SECRET` and the contract root key beside the key are read-only too while an application moves (one warning each); with the contract root key, a contract and `keys`, the old RS256 keys stay published beside the new one.
|
|
23
47
|
- **`createVerifierFromEnv()`**: a token verifier from `CAUTHY_KEY` alone (issuer, audience and workspace from Cauthy).
|
|
24
48
|
- `verifyWebhook` takes the issuer from `CAUTHY_KEY` when it is set.
|
|
25
49
|
- `parseKey`, `composeKey`, `KEY_REPLACES`, `CauthyKeyError`, and the types `CauthyKey`, `CauthyKeyReason`, `Identity`.
|
|
@@ -27,15 +51,15 @@ One variable for every application: `CAUTHY_KEY`.
|
|
|
27
51
|
|
|
28
52
|
### Refused beside `CAUTHY_KEY`
|
|
29
53
|
|
|
30
|
-
`CAUTHY_ISSUER`, `CAUTHY_CLIENT_ID`, `CAUTHY_CLIENT_SECRET`, `CAUTHY_SYSTEM`, `CAUTHY_TENANT`, `CAUTHY_SYSTEM_KEY`, `CAUTHY_SYSTEM_KEY_ID`, `CAUTHY_BASE_URL`, `CAUTHY_AUDIENCE`, `CAUTHY_TENANT_ID`, and the options `issuer`, `clientId`, `clientSecret`, `secret`, `system`, `tenant`, `audience`, `tenantId`, `systemKey`, `rootKey` (and `keys`, except beside
|
|
54
|
+
`CAUTHY_ISSUER`, `CAUTHY_CLIENT_ID`, `CAUTHY_CLIENT_SECRET`, `CAUTHY_SYSTEM`, `CAUTHY_TENANT`, `CAUTHY_SYSTEM_KEY`, `CAUTHY_SYSTEM_KEY_ID`, `CAUTHY_BASE_URL`, `CAUTHY_AUDIENCE`, `CAUTHY_TENANT_ID`, and the options `issuer`, `clientId`, `clientSecret`, `secret`, `system`, `tenant`, `audience`, `tenantId`, `systemKey`, `rootKey` (and `keys`, except beside the contract root key with a contract while moving).
|
|
31
55
|
|
|
32
56
|
### Deprecated (removed in 2.0)
|
|
33
57
|
|
|
34
|
-
One `DeprecationWarning` (code `CAUTHY_DEPRECATED`) per process each: configuring with the `CAUTHY_*` variables or their options;
|
|
58
|
+
One `DeprecationWarning` (code `CAUTHY_DEPRECATED`) per process each: configuring with the `CAUTHY_*` variables or their options; the contract root keys and the `keys` store; a verifier reading `CAUTHY_ISSUER`, `CAUTHY_AUDIENCE` or `CAUTHY_TENANT_ID`. They keep working through 1.x.
|
|
35
59
|
|
|
36
60
|
### Unchanged
|
|
37
61
|
|
|
38
|
-
Applications on the 1.1 variables or on
|
|
62
|
+
Applications on the 1.1 variables or on the contract root key work as before, apart from the warning. The MCP variables (`CAUTHY_MCP_*`) are not part of this change.
|
|
39
63
|
|
|
40
64
|
## 1.1.0 — security release
|
|
41
65
|
|
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
|
|
|
@@ -113,8 +113,8 @@ CAUTHY_KEY**. Deploy with `CAUTHY_KEY` and keep `CAUTHY_SECRET` for the window
|
|
|
113
113
|
(old sessions stay readable, and each is sealed again with the key the first
|
|
114
114
|
time it is read; one warning says to remove it), remove the other variables,
|
|
115
115
|
then **Remove the secret**. A session nobody used during the window is lost
|
|
116
|
-
with the secret. The variables of 1.1
|
|
117
|
-
|
|
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.
|
|
118
118
|
|
|
119
119
|
## Verifying a token
|
|
120
120
|
|
|
@@ -124,10 +124,9 @@ For an API that receives Cauthy access tokens from somewhere other than the brow
|
|
|
124
124
|
import { auth } from './auth'
|
|
125
125
|
|
|
126
126
|
// Where each value comes from:
|
|
127
|
-
// issuer the instance's own (CAUTHY_KEY
|
|
128
|
-
// 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)
|
|
129
129
|
// audience on CAUTHY_KEY, Cauthy's answer; otherwise `audience` or CAUTHY_AUDIENCE (deprecated): your Cauthy's JWT_AUDIENCE
|
|
130
|
-
// clientId by contract, the link's sign-in client: a person's token issued through another is refused (wrong_client)
|
|
131
130
|
const verify = auth.tokenVerifier() // throws CauthyConfigError now if one is missing
|
|
132
131
|
const who = await verify(request) // or: await auth.verifyToken(request)
|
|
133
132
|
```
|
|
@@ -151,7 +150,7 @@ const verify = createTokenVerifier({ issuer: 'https://id.example.com', audience:
|
|
|
151
150
|
- **The audience and the workspace are required.** Without them a token issued for another application or workspace would be accepted.
|
|
152
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.
|
|
153
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).
|
|
154
|
-
- `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.
|
|
155
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.
|
|
156
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`.
|
|
157
156
|
|
|
@@ -162,7 +161,7 @@ const verify = createTokenVerifier({ issuer: 'https://id.example.com', audience:
|
|
|
162
161
|
| cauthy-auth 0.42 | @cauthyhq/node 1.0 |
|
|
163
162
|
| --- | --- |
|
|
164
163
|
| `cauthy-auth` | `@cauthyhq/node` |
|
|
165
|
-
| `cauthy-auth/express`, `/fastify`, `/hono`, `/next`, `/mcp`, `/
|
|
164
|
+
| `cauthy-auth/express`, `/fastify`, `/hono`, `/next`, `/mcp`, `/theme` | `@cauthyhq/node/express`, … (same names) |
|
|
166
165
|
| `cauthy-auth/react`, `/styles.css` | `@cauthyhq/react`, `@cauthyhq/react/styles.css` |
|
|
167
166
|
| `cauthy-auth/client` | `@cauthyhq/js` |
|
|
168
167
|
| `cauthy-auth/vue`, `/svelte` | No 1.0 wrapper yet: keep `cauthy-auth` 0.43 in the browser (security fixes until 2027-02-06) |
|
|
@@ -178,29 +177,11 @@ Everything that behaves differently from 0.42:
|
|
|
178
177
|
6. **http issuers are refused** except for `localhost`, `127.0.0.1`, `*.localhost` and `*.test`.
|
|
179
178
|
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`.
|
|
180
179
|
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.
|
|
181
|
-
9. **
|
|
182
|
-
10. **
|
|
183
|
-
11. **Error messages start with `@cauthyhq/node:`** instead of `cauthy-auth:`. Classes and codes are the same.
|
|
180
|
+
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`.
|
|
181
|
+
10. **Error messages start with `@cauthyhq/node:`** instead of `cauthy-auth:`. Classes and codes are the same.
|
|
184
182
|
|
|
185
183
|
`/sign-in/anonymous`, `/me/upgrade` and `connectSystem` are deprecated: one `DeprecationWarning` per process, removed in 2.0.
|
|
186
184
|
|
|
187
|
-
## Contract mode
|
|
188
|
-
|
|
189
|
-
A contract is a layer on top of an application that runs on `CAUTHY_KEY`: the environment stays that one line, and the vendored graph adds the link (system proof, drift, the link's policies). No key store and no table:
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
import { createCauthy } from '@cauthyhq/node'
|
|
193
|
-
import graph from './contracts/graph.json'
|
|
194
|
-
|
|
195
|
-
export const auth = createCauthy({ contract: { graph, system: 'acme-crm' } }) // and CAUTHY_KEY in the environment
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
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)`.
|
|
199
|
-
|
|
200
|
-
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 `PACT_ROOT_KEY_PREVIOUS`, if a root rotation is open) and the `keys` option still beside it for the window (old sessions stay readable and are sealed again with the key the first time they are read, its RS256 keys stay published beside the new Ed25519 key), then remove `PACT_ROOT_KEY`, the option and the table. A session nobody used during the window is lost with the root key.
|
|
201
|
-
|
|
202
|
-
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).
|
|
203
|
-
|
|
204
185
|
## Options added in 1.0
|
|
205
186
|
|
|
206
187
|
| Option | Default | What it does |
|
|
@@ -209,7 +190,7 @@ It refuses to start when any variable `CAUTHY_KEY` replaces is also set, when th
|
|
|
209
190
|
| `timeouts.system` | `2000` | Deadline in milliseconds of the application's own calls to Cauthy (`auth.system`, the sign-in proof) |
|
|
210
191
|
| `timeouts.request` | `5000` | Deadline in milliseconds of the sign-in screens' calls and of the code, refresh and userinfo calls |
|
|
211
192
|
| `audience` | `CAUTHY_AUDIENCE` | The audience `auth.verifyToken` accepts |
|
|
212
|
-
| `tenantId` | `CAUTHY_TENANT_ID` | The workspace id `auth.verifyToken` accepts
|
|
193
|
+
| `tenantId` | `CAUTHY_TENANT_ID` | The workspace id `auth.verifyToken` accepts |
|
|
213
194
|
|
|
214
195
|
## Testing your application
|
|
215
196
|
|
|
@@ -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
|
/**
|
|
@@ -267,24 +177,6 @@ interface CauthyOptions {
|
|
|
267
177
|
system?: number;
|
|
268
178
|
request?: number;
|
|
269
179
|
};
|
|
270
|
-
/**
|
|
271
|
-
* Run by contract: the issuer, the workspace, the clients and where the
|
|
272
|
-
* application's keys are published all come from its link in the network's
|
|
273
|
-
* context graph, and none of the CAUTHY_* variables may be set. See
|
|
274
|
-
* "Connect a system by contract".
|
|
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`.
|
|
284
|
-
*/
|
|
285
|
-
rootKey?: string;
|
|
286
|
-
/** The root key before the current one, while rotating it. Default: `PACT_ROOT_KEY_PREVIOUS`. */
|
|
287
|
-
rootKeyPrevious?: string;
|
|
288
180
|
/**
|
|
289
181
|
* Where `auth.webhook` remembers the deliveries it took, so one sent twice
|
|
290
182
|
* is refused. Default: this process's memory. Give a shared one (a table)
|
|
@@ -411,7 +303,7 @@ declare class CauthyConfigError extends Error {
|
|
|
411
303
|
constructor(message: string);
|
|
412
304
|
}
|
|
413
305
|
/** 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' | '
|
|
306
|
+
type CauthyKeyReason = 'key_format' | 'key_version' | 'key_checksum' | 'key_issuer' | 'key_client' | 'key_secret' | 'key_previous_mismatch';
|
|
415
307
|
/** A refused CAUTHY_KEY. The message names the reason, never the key. */
|
|
416
308
|
declare class CauthyKeyError extends CauthyConfigError {
|
|
417
309
|
readonly reason: CauthyKeyReason;
|
|
@@ -703,17 +595,10 @@ interface SystemOptions {
|
|
|
703
595
|
* client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
|
|
704
596
|
*/
|
|
705
597
|
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
598
|
/**
|
|
714
599
|
* 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
|
-
*
|
|
600
|
+
* every token is asked with an EdDSA assertion. Takes the place of `key`
|
|
601
|
+
* and the secret.
|
|
717
602
|
*/
|
|
718
603
|
signer?: {
|
|
719
604
|
clientId: string;
|
|
@@ -939,8 +824,8 @@ interface VerifyTokenOptions {
|
|
|
939
824
|
/**
|
|
940
825
|
* The client this backend signs people in through. When set, a person's
|
|
941
826
|
* token issued through another client (an `azp` naming another) is refused
|
|
942
|
-
* with `wrong_client` (rule R15); a token with no `azp` passes.
|
|
943
|
-
*
|
|
827
|
+
* with `wrong_client` (rule R15); a token with no `azp` passes. Default:
|
|
828
|
+
* none, and `azp` is not checked.
|
|
944
829
|
*/
|
|
945
830
|
clientId?: string;
|
|
946
831
|
}
|
|
@@ -988,6 +873,25 @@ declare function createVerifierFromEnv(options?: Omit<VerifyTokenOptions, 'issue
|
|
|
988
873
|
*/
|
|
989
874
|
type MountTarget = string | ((request: Request) => Response | Promise<Response>);
|
|
990
875
|
|
|
876
|
+
/** What `GET /v1/connect/self` answers. */
|
|
877
|
+
interface Identity {
|
|
878
|
+
issuer: string;
|
|
879
|
+
audience: string;
|
|
880
|
+
tenant: {
|
|
881
|
+
id: string;
|
|
882
|
+
slug: string;
|
|
883
|
+
};
|
|
884
|
+
system: string;
|
|
885
|
+
client_id: string;
|
|
886
|
+
sign_in_client_id: string;
|
|
887
|
+
app_urls: string[];
|
|
888
|
+
callback_path: string;
|
|
889
|
+
key: {
|
|
890
|
+
kid: string;
|
|
891
|
+
retires_at: string | null;
|
|
892
|
+
} | null;
|
|
893
|
+
}
|
|
894
|
+
|
|
991
895
|
/** What `resolve` answers: who is there, and the cookies that must go back. */
|
|
992
896
|
interface Resolved {
|
|
993
897
|
session: Session | null;
|
|
@@ -1071,10 +975,9 @@ interface Cauthy {
|
|
|
1071
975
|
/**
|
|
1072
976
|
* Verifies a Cauthy access token (or a request's `Authorization: Bearer`) for
|
|
1073
977
|
* 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`).
|
|
978
|
+
* workspace (on CAUTHY_KEY, Cauthy's answer; otherwise `tenantId` or
|
|
979
|
+
* `CAUTHY_TENANT_ID`) and its audience (on CAUTHY_KEY, Cauthy's answer;
|
|
980
|
+
* otherwise `audience` or `CAUTHY_AUDIENCE`).
|
|
1078
981
|
*/
|
|
1079
982
|
verifyToken(from: string | Request | Headers, options?: Partial<VerifyTokenOptions>): Promise<TokenIdentity>;
|
|
1080
983
|
/** The same, built once: throws `CauthyConfigError` now if the audience or the workspace is missing. */
|
|
@@ -1085,11 +988,6 @@ interface Cauthy {
|
|
|
1085
988
|
* `systemKey`.
|
|
1086
989
|
*/
|
|
1087
990
|
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
991
|
/** What the browser may be told of a session. */
|
|
1094
992
|
toPublic(session: Session): Promise<PublicSession>;
|
|
1095
993
|
/** Paths of this application that start a sign-in, a sign-out, or open the account page. */
|
|
@@ -1101,20 +999,6 @@ interface Cauthy {
|
|
|
1101
999
|
};
|
|
1102
1000
|
options: Readonly<Required<Pick<CauthyOptions, 'issuer' | 'clientId' | 'basePath' | 'afterSignIn' | 'afterSignOut' | 'cookieName'>>>;
|
|
1103
1001
|
}
|
|
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
1002
|
declare function createCauthy(given?: CauthyOptions): Cauthy;
|
|
1119
1003
|
|
|
1120
|
-
export {
|
|
1004
|
+
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 };
|