cauthy-auth 0.2.0 → 0.4.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/README.md +12 -1
- package/dist/{cauthy-BrIMaoj1.d.mts → cauthy--iqtLWNa.d.ts} +7 -1
- package/dist/{cauthy-CCZc9w8r.d.ts → cauthy-Dg-DNIo9.d.mts} +7 -1
- package/dist/cli.js +129 -4
- package/dist/fastify.d.mts +3 -2
- package/dist/fastify.d.ts +3 -2
- package/dist/index.d.mts +47 -3
- package/dist/index.d.ts +47 -3
- package/dist/index.js +495 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +489 -241
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +4 -2
- package/dist/react.d.ts +4 -2
- package/dist/system-CL3Q30FT.d.ts +243 -0
- package/dist/system-CdvktS7x.d.mts +243 -0
- package/dist/theme.d.mts +16 -3
- package/dist/theme.d.ts +16 -3
- package/dist/theme.js +32 -2
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +31 -2
- package/dist/theme.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/types-CYmUVWzY.d.mts +0 -106
- package/dist/types-CYmUVWzY.d.ts +0 -106
package/README.md
CHANGED
|
@@ -44,7 +44,18 @@ Built with Stackmyth? Give Cauthy's pages your application's look from its own t
|
|
|
44
44
|
npx cauthy-auth theme --css node_modules/@stackmyth/core/core.vars.css --css src/styles/brand-theme.css --push
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Connect your application to Cauthy in one step, from Cauthy's dashboard ("Connect a System") or from a terminal. It makes the client, registers `https://<your app>/api/auth/callback`, and prints every variable to set, `CAUTHY_SECRET` included:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx cauthy-auth init --system ledger --app-url https://app.example.com
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The same client is your application's own identity: it manages its organizations with no person's token.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const org = await auth.system.organizations.create({ name: 'Acme' })
|
|
57
|
+
await auth.system.members.add(org.id, { role: 'owner', email: 'ana@acme.com' })
|
|
58
|
+
```
|
|
48
59
|
|
|
49
60
|
The full guide is in Cauthy's documentation, under "Auth SDK".
|
|
50
61
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { J as JsonValue, S as Session, f as SessionStatus, e as SessionOrganization, c as CauthySystem, P as PublicSession, b as CauthyOptions } from './system-CL3Q30FT.js';
|
|
1
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
2
|
-
import { J as JsonValue, S as Session, c as SessionStatus, b as SessionOrganization, P as PublicSession, a as CauthyOptions } from './types-CYmUVWzY.mjs';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
5
5
|
interface CauthyEvent {
|
|
@@ -86,6 +86,12 @@ interface Cauthy {
|
|
|
86
86
|
* delivery is signed with Cauthy's own key.
|
|
87
87
|
*/
|
|
88
88
|
webhook(request: Request, options?: Pick<VerifyWebhookOptions, 'jwks' | 'now' | 'url'>): Promise<CauthyEvent>;
|
|
89
|
+
/**
|
|
90
|
+
* The application acting on its own, with no person's token: its
|
|
91
|
+
* organizations, their members, invitations. Needs the client's secret, or
|
|
92
|
+
* `systemKey`.
|
|
93
|
+
*/
|
|
94
|
+
system: CauthySystem;
|
|
89
95
|
/** What the browser may be told of a session. */
|
|
90
96
|
toPublic(session: Session): Promise<PublicSession>;
|
|
91
97
|
/** Paths of this application that start a sign-in, a sign-out, or open the account page. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { J as JsonValue, S as Session, f as SessionStatus, e as SessionOrganization, c as CauthySystem, P as PublicSession, b as CauthyOptions } from './system-CdvktS7x.mjs';
|
|
1
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
2
|
-
import { J as JsonValue, S as Session, c as SessionStatus, b as SessionOrganization, P as PublicSession, a as CauthyOptions } from './types-CYmUVWzY.js';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
5
5
|
interface CauthyEvent {
|
|
@@ -86,6 +86,12 @@ interface Cauthy {
|
|
|
86
86
|
* delivery is signed with Cauthy's own key.
|
|
87
87
|
*/
|
|
88
88
|
webhook(request: Request, options?: Pick<VerifyWebhookOptions, 'jwks' | 'now' | 'url'>): Promise<CauthyEvent>;
|
|
89
|
+
/**
|
|
90
|
+
* The application acting on its own, with no person's token: its
|
|
91
|
+
* organizations, their members, invitations. Needs the client's secret, or
|
|
92
|
+
* `systemKey`.
|
|
93
|
+
*/
|
|
94
|
+
system: CauthySystem;
|
|
89
95
|
/** What the browser may be told of a session. */
|
|
90
96
|
toPublic(session: Session): Promise<PublicSession>;
|
|
91
97
|
/** Paths of this application that start a sign-in, a sign-out, or open the account page. */
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,53 @@
|
|
|
4
4
|
// src/cli.ts
|
|
5
5
|
var import_node_fs = require("fs");
|
|
6
6
|
|
|
7
|
+
// src/connect.ts
|
|
8
|
+
function sessionSecret() {
|
|
9
|
+
const bytes = crypto.getRandomValues(new Uint8Array(32));
|
|
10
|
+
let s = "";
|
|
11
|
+
for (const b of bytes) s += String.fromCharCode(b);
|
|
12
|
+
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
13
|
+
}
|
|
14
|
+
async function connectSystem(o) {
|
|
15
|
+
const env = (n) => typeof process !== "undefined" ? process.env?.[n] : void 0;
|
|
16
|
+
const issuer = (o.issuer ?? env("CAUTHY_ISSUER") ?? "").replace(/\/+$/, "");
|
|
17
|
+
const tenant = o.tenant ?? env("CAUTHY_TENANT") ?? "";
|
|
18
|
+
const token = o.token ?? env("CAUTHY_TOKEN") ?? "";
|
|
19
|
+
for (const [name, v] of Object.entries({ CAUTHY_ISSUER: issuer, CAUTHY_TENANT: tenant, CAUTHY_TOKEN: token })) {
|
|
20
|
+
if (v === "") throw new Error(`cauthy-auth: ${name} is required to connect a system`);
|
|
21
|
+
}
|
|
22
|
+
const res = await (o.fetch ?? fetch)(`${issuer}/v1/connect`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: { authorization: `Bearer ${token}`, "x-tenant-key": tenant, "content-type": "application/json" },
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
system: o.system,
|
|
27
|
+
app_url: o.appUrl,
|
|
28
|
+
name: o.name,
|
|
29
|
+
callback_path: o.callbackPath,
|
|
30
|
+
events_url: o.eventsUrl,
|
|
31
|
+
events: o.events,
|
|
32
|
+
jwks_uri: o.jwksUri
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
const body = await res.json().catch(() => null);
|
|
36
|
+
if (!res.ok || !body?.data) {
|
|
37
|
+
const why = (body?.errors ?? []).map((e) => e.message).filter(Boolean).join("; ") || res.statusText;
|
|
38
|
+
throw new Error(`cauthy-auth: Cauthy did not connect the system (${res.status}): ${why}`);
|
|
39
|
+
}
|
|
40
|
+
const d = body.data;
|
|
41
|
+
return {
|
|
42
|
+
system: d.system,
|
|
43
|
+
clientId: d.client.client_id,
|
|
44
|
+
clientSecret: d.client_secret,
|
|
45
|
+
redirectUris: d.client.redirect_uris,
|
|
46
|
+
webhook: d.webhook,
|
|
47
|
+
env: { ...d.env, CAUTHY_SECRET: sessionSecret() }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function envFile(env) {
|
|
51
|
+
return Object.entries(env).map(([k, v]) => `${k}=${v}`).join("\n") + "\n";
|
|
52
|
+
}
|
|
53
|
+
|
|
7
54
|
// src/permissions.ts
|
|
8
55
|
async function pushPolicy(o) {
|
|
9
56
|
const env = (n) => typeof process !== "undefined" ? process.env?.[n] : void 0;
|
|
@@ -219,10 +266,14 @@ function toWire(theme) {
|
|
|
219
266
|
radius: "radius",
|
|
220
267
|
buttonRadius: "button_radius",
|
|
221
268
|
fontFamily: "font_family",
|
|
222
|
-
logoUrl: "logo_url"
|
|
269
|
+
logoUrl: "logo_url",
|
|
270
|
+
fonts: "fonts"
|
|
223
271
|
};
|
|
224
272
|
const wire = {};
|
|
225
|
-
for (const [k, v] of Object.entries(theme))
|
|
273
|
+
for (const [k, v] of Object.entries(theme)) {
|
|
274
|
+
if (v === void 0 || v === "" || Array.isArray(v) && v.length === 0) continue;
|
|
275
|
+
wire[names[k]] = v;
|
|
276
|
+
}
|
|
226
277
|
return wire;
|
|
227
278
|
}
|
|
228
279
|
async function pushTheme(o) {
|
|
@@ -246,6 +297,77 @@ async function pushTheme(o) {
|
|
|
246
297
|
}
|
|
247
298
|
|
|
248
299
|
// src/cli.ts
|
|
300
|
+
var INIT_HELP = `cauthy-auth init --system <name> --app-url <address> [options]
|
|
301
|
+
|
|
302
|
+
Connects an application to Cauthy: makes its client, registers where its people
|
|
303
|
+
come back to and where it hears events, and prints the variables to set.
|
|
304
|
+
|
|
305
|
+
--system <name> The system's name: lowercase letters, digits, - or _.
|
|
306
|
+
--app-url <address> The application's public address: https://app.example.com,
|
|
307
|
+
or http://localhost:3000 while developing.
|
|
308
|
+
--name <name> Shown to people on Cauthy's pages. Default: the system's name.
|
|
309
|
+
--callback-path <path> Where the application serves the return from a sign-in.
|
|
310
|
+
Default: /api/auth/callback.
|
|
311
|
+
--events-url <address> An https address of the application that receives
|
|
312
|
+
Cauthy's events (verify them with auth.webhook).
|
|
313
|
+
--jwks-uri <address> Where the application publishes its keys, to prove
|
|
314
|
+
itself with a signature instead of its secret.
|
|
315
|
+
--write <file> Append the variables to this file instead of printing
|
|
316
|
+
them (they include the client's secret, shown once).
|
|
317
|
+
|
|
318
|
+
Needs CAUTHY_ISSUER, CAUTHY_TENANT (the workspace's slug) and CAUTHY_TOKEN (a
|
|
319
|
+
personal access token with systems:connect).
|
|
320
|
+
`;
|
|
321
|
+
async function init(argv) {
|
|
322
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
323
|
+
process.stdout.write(INIT_HELP);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const given = {};
|
|
327
|
+
const flags = ["--system", "--app-url", "--name", "--callback-path", "--events-url", "--jwks-uri", "--write"];
|
|
328
|
+
for (let i = 0; i < argv.length; i++) {
|
|
329
|
+
const arg = argv[i];
|
|
330
|
+
if (!flags.includes(arg)) fail(`unknown option ${arg}
|
|
331
|
+
|
|
332
|
+
${INIT_HELP}`);
|
|
333
|
+
given[arg] = argv[++i] ?? fail(`${arg} needs a value`);
|
|
334
|
+
}
|
|
335
|
+
if (!given["--system"] || !given["--app-url"]) fail("give --system and --app-url\n\n" + INIT_HELP);
|
|
336
|
+
const done = await connectSystem({
|
|
337
|
+
system: given["--system"],
|
|
338
|
+
appUrl: given["--app-url"],
|
|
339
|
+
name: given["--name"],
|
|
340
|
+
callbackPath: given["--callback-path"],
|
|
341
|
+
eventsUrl: given["--events-url"],
|
|
342
|
+
jwksUri: given["--jwks-uri"]
|
|
343
|
+
});
|
|
344
|
+
const vars = envFile(done.env);
|
|
345
|
+
process.stdout.write(`Connected: the system ${done.system} is the client ${done.clientId}.
|
|
346
|
+
`);
|
|
347
|
+
process.stdout.write(` people come back to ${done.redirectUris.join(", ")}
|
|
348
|
+
`);
|
|
349
|
+
if (done.webhook) process.stdout.write(` events are sent to ${done.webhook.url}
|
|
350
|
+
`);
|
|
351
|
+
if (given["--write"]) {
|
|
352
|
+
(0, import_node_fs.appendFileSync)(given["--write"], vars, { mode: 384 });
|
|
353
|
+
process.stdout.write(`
|
|
354
|
+
The variables were added to ${given["--write"]}. Keep that file out of the repository.
|
|
355
|
+
`);
|
|
356
|
+
} else {
|
|
357
|
+
process.stdout.write(`
|
|
358
|
+
Set these where the application runs. The secret is shown this once:
|
|
359
|
+
|
|
360
|
+
${vars}`);
|
|
361
|
+
}
|
|
362
|
+
process.stdout.write(`
|
|
363
|
+
Then, in the application:
|
|
364
|
+
|
|
365
|
+
import { createCauthy } from 'cauthy-auth'
|
|
366
|
+
export const auth = createCauthy()
|
|
367
|
+
|
|
368
|
+
and serve auth.handler(request) under ${(given["--callback-path"] ?? "/api/auth/callback").replace(/\/callback$/, "")}/*.
|
|
369
|
+
`);
|
|
370
|
+
}
|
|
249
371
|
var POLICY_HELP = `cauthy-auth policy --file <roles.json> [--system <name>] [--push]
|
|
250
372
|
|
|
251
373
|
Loads a system's catalog of roles into Cauthy from a file:
|
|
@@ -303,7 +425,9 @@ ${POLICY_HELP}`);
|
|
|
303
425
|
process.stdout.write("Not sent. Add --push to give it to Cauthy.\n");
|
|
304
426
|
}
|
|
305
427
|
}
|
|
306
|
-
var HELP = `cauthy-auth
|
|
428
|
+
var HELP = `cauthy-auth init \u2026 connect an application to Cauthy (cauthy-auth init --help)
|
|
429
|
+
cauthy-auth policy \u2026 load a system's catalog of roles (cauthy-auth policy --help)
|
|
430
|
+
cauthy-auth theme [options]
|
|
307
431
|
|
|
308
432
|
Reads the application's Stackmyth theme and gives it to Cauthy's hosted pages.
|
|
309
433
|
|
|
@@ -326,6 +450,7 @@ function fail(message) {
|
|
|
326
450
|
}
|
|
327
451
|
async function main(argv) {
|
|
328
452
|
if (argv[0] === "policy") return policy(argv.slice(1));
|
|
453
|
+
if (argv[0] === "init") return init(argv.slice(1));
|
|
329
454
|
if (argv[0] !== "theme" || argv.includes("--help") || argv.includes("-h")) {
|
|
330
455
|
process.stdout.write(HELP);
|
|
331
456
|
process.exit(argv[0] === "theme" || argv.length === 0 || argv.includes("--help") || argv.includes("-h") ? 0 : 1);
|
|
@@ -377,4 +502,4 @@ ${HELP}`);
|
|
|
377
502
|
process.stdout.write("Not sent. Add --push to give it to Cauthy.\n");
|
|
378
503
|
}
|
|
379
504
|
}
|
|
380
|
-
main(process.argv.slice(2)).catch((err) => fail(err instanceof Error ? err.message.replace(
|
|
505
|
+
main(process.argv.slice(2)).catch((err) => fail(err instanceof Error ? err.message.replace(/^cauthy-auth: /, "") : String(err)));
|
package/dist/fastify.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FastifyReply, FastifyPluginAsync } from 'fastify';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './
|
|
2
|
+
import { C as Cauthy } from './cauthy-Dg-DNIo9.mjs';
|
|
3
|
+
import { S as Session } from './system-CdvktS7x.mjs';
|
|
4
4
|
import 'jose';
|
|
5
|
+
import './theme.mjs';
|
|
5
6
|
|
|
6
7
|
declare module 'fastify' {
|
|
7
8
|
interface FastifyRequest {
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FastifyReply, FastifyPluginAsync } from 'fastify';
|
|
2
|
-
import { C as Cauthy } from './cauthy
|
|
3
|
-
import { S as Session } from './
|
|
2
|
+
import { C as Cauthy } from './cauthy--iqtLWNa.js';
|
|
3
|
+
import { S as Session } from './system-CL3Q30FT.js';
|
|
4
4
|
import 'jose';
|
|
5
|
+
import './theme.js';
|
|
5
6
|
|
|
6
7
|
declare module 'fastify' {
|
|
7
8
|
interface FastifyRequest {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-
|
|
2
|
-
export { C as
|
|
3
|
-
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, pushTheme, themeFromStackmyth } from './theme.mjs';
|
|
1
|
+
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-Dg-DNIo9.mjs';
|
|
2
|
+
export { C as CauthyApiError, a as CauthyConfigError, b as CauthyOptions, c as CauthySystem, J as JsonValue, N as NewMember, O as Organization, d as OrganizationMember, P as PublicSession, S as Session, e as SessionOrganization, f as SessionStatus, g as SessionUser, h as SystemKey, i as SystemOptions, j as createSystem } from './system-CdvktS7x.mjs';
|
|
3
|
+
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, ThemeFont, pushTheme, themeFromStackmyth } from './theme.mjs';
|
|
4
4
|
export { P as Permitted, a as PolicyPermission, b as PolicyRole, c as PushPolicyOptions, d as can, p as pushPolicy } from './permissions-B-a3eN0h.mjs';
|
|
5
5
|
import 'jose';
|
|
6
|
+
|
|
7
|
+
interface ConnectOptions {
|
|
8
|
+
/** The system's name, as its organizations are filed under: lowercase, digits, - or _. */
|
|
9
|
+
system: string;
|
|
10
|
+
/** The application's public address: `https://app.example.com`, or `http://localhost:3000` while developing. */
|
|
11
|
+
appUrl: string;
|
|
12
|
+
/** Shown to people on Cauthy's pages. Default: the system's name. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Where the application serves the return from a sign-in. Default: `/api/auth/callback`. */
|
|
15
|
+
callbackPath?: string;
|
|
16
|
+
/** An https address of the application that receives Cauthy's events. */
|
|
17
|
+
eventsUrl?: string;
|
|
18
|
+
/** The events to receive. Default: all of them. */
|
|
19
|
+
events?: string[];
|
|
20
|
+
/** Where the application publishes its keys, to prove itself without a secret. */
|
|
21
|
+
jwksUri?: string;
|
|
22
|
+
/** Cauthy's address. Default: `CAUTHY_ISSUER`. */
|
|
23
|
+
issuer?: string;
|
|
24
|
+
/** The workspace's slug. Default: `CAUTHY_TENANT`. */
|
|
25
|
+
tenant?: string;
|
|
26
|
+
/** A personal access token with `systems:connect`. Default: `CAUTHY_TOKEN`. */
|
|
27
|
+
token?: string;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
}
|
|
30
|
+
interface Connected {
|
|
31
|
+
system: string;
|
|
32
|
+
clientId: string;
|
|
33
|
+
/** Shown this once: Cauthy keeps only its hash. */
|
|
34
|
+
clientSecret: string;
|
|
35
|
+
redirectUris: string[];
|
|
36
|
+
webhook: {
|
|
37
|
+
id: string;
|
|
38
|
+
url: string;
|
|
39
|
+
events: string[];
|
|
40
|
+
} | null;
|
|
41
|
+
/**
|
|
42
|
+
* Everything the application sets: what Cauthy answered, plus CAUTHY_SECRET,
|
|
43
|
+
* the key of the session cookie, generated here and known to nobody else.
|
|
44
|
+
*/
|
|
45
|
+
env: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
declare function connectSystem(o: ConnectOptions): Promise<Connected>;
|
|
48
|
+
|
|
49
|
+
export { type ConnectOptions, type Connected, connectSystem };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy
|
|
2
|
-
export { C as
|
|
3
|
-
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, pushTheme, themeFromStackmyth } from './theme.js';
|
|
1
|
+
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy--iqtLWNa.js';
|
|
2
|
+
export { C as CauthyApiError, a as CauthyConfigError, b as CauthyOptions, c as CauthySystem, J as JsonValue, N as NewMember, O as Organization, d as OrganizationMember, P as PublicSession, S as Session, e as SessionOrganization, f as SessionStatus, g as SessionUser, h as SystemKey, i as SystemOptions, j as createSystem } from './system-CL3Q30FT.js';
|
|
3
|
+
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, ThemeFont, pushTheme, themeFromStackmyth } from './theme.js';
|
|
4
4
|
export { P as Permitted, a as PolicyPermission, b as PolicyRole, c as PushPolicyOptions, d as can, p as pushPolicy } from './permissions-B-a3eN0h.js';
|
|
5
5
|
import 'jose';
|
|
6
|
+
|
|
7
|
+
interface ConnectOptions {
|
|
8
|
+
/** The system's name, as its organizations are filed under: lowercase, digits, - or _. */
|
|
9
|
+
system: string;
|
|
10
|
+
/** The application's public address: `https://app.example.com`, or `http://localhost:3000` while developing. */
|
|
11
|
+
appUrl: string;
|
|
12
|
+
/** Shown to people on Cauthy's pages. Default: the system's name. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Where the application serves the return from a sign-in. Default: `/api/auth/callback`. */
|
|
15
|
+
callbackPath?: string;
|
|
16
|
+
/** An https address of the application that receives Cauthy's events. */
|
|
17
|
+
eventsUrl?: string;
|
|
18
|
+
/** The events to receive. Default: all of them. */
|
|
19
|
+
events?: string[];
|
|
20
|
+
/** Where the application publishes its keys, to prove itself without a secret. */
|
|
21
|
+
jwksUri?: string;
|
|
22
|
+
/** Cauthy's address. Default: `CAUTHY_ISSUER`. */
|
|
23
|
+
issuer?: string;
|
|
24
|
+
/** The workspace's slug. Default: `CAUTHY_TENANT`. */
|
|
25
|
+
tenant?: string;
|
|
26
|
+
/** A personal access token with `systems:connect`. Default: `CAUTHY_TOKEN`. */
|
|
27
|
+
token?: string;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
}
|
|
30
|
+
interface Connected {
|
|
31
|
+
system: string;
|
|
32
|
+
clientId: string;
|
|
33
|
+
/** Shown this once: Cauthy keeps only its hash. */
|
|
34
|
+
clientSecret: string;
|
|
35
|
+
redirectUris: string[];
|
|
36
|
+
webhook: {
|
|
37
|
+
id: string;
|
|
38
|
+
url: string;
|
|
39
|
+
events: string[];
|
|
40
|
+
} | null;
|
|
41
|
+
/**
|
|
42
|
+
* Everything the application sets: what Cauthy answered, plus CAUTHY_SECRET,
|
|
43
|
+
* the key of the session cookie, generated here and known to nobody else.
|
|
44
|
+
*/
|
|
45
|
+
env: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
declare function connectSystem(o: ConnectOptions): Promise<Connected>;
|
|
48
|
+
|
|
49
|
+
export { type ConnectOptions, type Connected, connectSystem };
|