cauthy-auth 0.1.0 → 0.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/README.md +12 -1
- package/dist/cauthy-C5_lopMQ.d.ts +108 -0
- package/dist/cauthy-mNADGlNl.d.mts +108 -0
- package/dist/cli.js +202 -2
- package/dist/fastify.d.mts +3 -2
- package/dist/fastify.d.ts +3 -2
- package/dist/index.d.mts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +343 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -13
- package/dist/index.mjs.map +1 -1
- package/dist/permissions-B-a3eN0h.d.mts +52 -0
- package/dist/permissions-B-a3eN0h.d.ts +52 -0
- package/dist/react.d.mts +4 -2
- package/dist/react.d.ts +4 -2
- package/dist/react.js +18 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +17 -0
- package/dist/react.mjs.map +1 -1
- package/dist/system-BWLddIt2.d.mts +233 -0
- package/dist/system-BWLddIt2.d.ts +233 -0
- package/package.json +1 -1
- package/dist/cauthy-By2cryXN.d.ts +0 -56
- package/dist/cauthy-DsUNqjg6.d.mts +0 -56
- package/dist/types-BwCjBn-K.d.mts +0 -97
- package/dist/types-BwCjBn-K.d.ts +0 -97
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { S as Session, c as SessionStatus, b as SessionOrganization, P as PublicSession, a as CauthyOptions } from './types-BwCjBn-K.mjs';
|
|
2
|
-
|
|
3
|
-
/** What `resolve` answers: who is there, and the cookies that must go back. */
|
|
4
|
-
interface Resolved {
|
|
5
|
-
session: Session | null;
|
|
6
|
-
status: SessionStatus;
|
|
7
|
-
/** `Set-Cookie` values to send with the response. Empty when nothing changed. */
|
|
8
|
-
cookies: string[];
|
|
9
|
-
}
|
|
10
|
-
interface Cauthy {
|
|
11
|
-
/** Serves the routes under `basePath`: login, callback, session, refresh, logout, account. */
|
|
12
|
-
handler(request: Request): Promise<Response>;
|
|
13
|
-
/**
|
|
14
|
-
* Who is signed in, or null.
|
|
15
|
-
*
|
|
16
|
-
* Give it the response's headers and a session that needs renewing is
|
|
17
|
-
* renewed on the spot, its new cookie added to them. Without them an
|
|
18
|
-
* expired session reads as null (see `status`): renewing changes the
|
|
19
|
-
* cookie, and a cookie nobody sends back is a session lost.
|
|
20
|
-
*/
|
|
21
|
-
getSession(request: Request, responseHeaders?: Headers): Promise<Session | null>;
|
|
22
|
-
/** Whether somebody is signed in, nobody is, or the session must be renewed first. */
|
|
23
|
-
status(request: Request): Promise<SessionStatus>;
|
|
24
|
-
/**
|
|
25
|
-
* The session, renewed when it has to be, and the cookies to send back.
|
|
26
|
-
* The caller MUST send `cookies` with its response.
|
|
27
|
-
*/
|
|
28
|
-
resolve(request: Request): Promise<Resolved>;
|
|
29
|
-
/**
|
|
30
|
-
* For a route only a signed-in person may see: the session, or the response
|
|
31
|
-
* to give instead — a redirect to sign in (or to renew) for a page, a 401
|
|
32
|
-
* for anything else.
|
|
33
|
-
*/
|
|
34
|
-
protect(request: Request): Promise<{
|
|
35
|
-
session: Session;
|
|
36
|
-
response?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
session?: undefined;
|
|
39
|
-
response: Response;
|
|
40
|
-
}>;
|
|
41
|
-
/** The organizations the person belongs to (of `system`, when set), with their role in each. */
|
|
42
|
-
organizations(session: Session): Promise<SessionOrganization[]>;
|
|
43
|
-
/** What the browser may be told of a session. */
|
|
44
|
-
toPublic(session: Session): Promise<PublicSession>;
|
|
45
|
-
/** Paths of this application that start a sign-in, a sign-out, or open the account page. */
|
|
46
|
-
urls: {
|
|
47
|
-
signIn(returnTo?: string): string;
|
|
48
|
-
signOut(): string;
|
|
49
|
-
account(returnTo?: string): string;
|
|
50
|
-
session: string;
|
|
51
|
-
};
|
|
52
|
-
options: Readonly<Required<Pick<CauthyOptions, 'issuer' | 'clientId' | 'basePath' | 'afterSignIn' | 'afterSignOut' | 'cookieName'>>>;
|
|
53
|
-
}
|
|
54
|
-
declare function createCauthy(given?: CauthyOptions): Cauthy;
|
|
55
|
-
|
|
56
|
-
export { type Cauthy as C, type Resolved as R, createCauthy as c };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/** How an application is set up to sign its people in with Cauthy. */
|
|
2
|
-
interface CauthyOptions {
|
|
3
|
-
/** Cauthy's public address, e.g. `https://id.example.com`. Default: `CAUTHY_ISSUER`. */
|
|
4
|
-
issuer?: string;
|
|
5
|
-
/** The application's OAuth client id. Default: `CAUTHY_CLIENT_ID`. */
|
|
6
|
-
clientId?: string;
|
|
7
|
-
/** Its secret, when the client is confidential. Default: `CAUTHY_CLIENT_SECRET`. */
|
|
8
|
-
clientSecret?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The key the session cookie is encrypted with: any string of 32 characters
|
|
11
|
-
* or more, kept on the server. Default: `CAUTHY_SECRET`.
|
|
12
|
-
*/
|
|
13
|
-
secret?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The system this application is, as its organizations are filed under in
|
|
16
|
-
* Cauthy (`"pondari"`). When set, a session's organizations are that
|
|
17
|
-
* system's. Default: `CAUTHY_SYSTEM`.
|
|
18
|
-
*/
|
|
19
|
-
system?: string;
|
|
20
|
-
/** Where the routes are mounted. Default: `/api/auth`. */
|
|
21
|
-
basePath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The application's own public origin (`https://app.example.com`), for the
|
|
24
|
-
* redirect URI. Default: the origin of each request, which is right unless
|
|
25
|
-
* a proxy hides it.
|
|
26
|
-
*/
|
|
27
|
-
baseURL?: string;
|
|
28
|
-
/** Where a person lands after signing in, when no `return_to` was asked. Default: `/`. */
|
|
29
|
-
afterSignIn?: string;
|
|
30
|
-
/** Where a person lands after signing out. Default: `/`. */
|
|
31
|
-
afterSignOut?: string;
|
|
32
|
-
/** Name of the session cookie. Default: `cauthy_session`. */
|
|
33
|
-
cookieName?: string;
|
|
34
|
-
/** `fetch` to reach Cauthy with. Default: the global one. */
|
|
35
|
-
fetch?: typeof fetch;
|
|
36
|
-
}
|
|
37
|
-
/** The person signed in. Every moment is UTC. */
|
|
38
|
-
interface SessionUser {
|
|
39
|
-
id: string;
|
|
40
|
-
email: string;
|
|
41
|
-
name: string;
|
|
42
|
-
emailVerified: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* True when the account ran out of time to confirm its address: let it read
|
|
45
|
-
* and refuse its writes.
|
|
46
|
-
*/
|
|
47
|
-
restricted: boolean;
|
|
48
|
-
/** When an unconfirmed address stops being enough (ISO 8601, UTC), if there is a deadline. */
|
|
49
|
-
emailVerifyBy?: string;
|
|
50
|
-
/** The language the person reads in ("es", "en-US"), when Cauthy knows it. */
|
|
51
|
-
locale?: string;
|
|
52
|
-
}
|
|
53
|
-
/** A value JSON can carry. What crosses from server to browser is typed as this, never `unknown`. */
|
|
54
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
55
|
-
[key: string]: JsonValue;
|
|
56
|
-
};
|
|
57
|
-
/** An organization the person belongs to, with their role in it. */
|
|
58
|
-
interface SessionOrganization {
|
|
59
|
-
id: string;
|
|
60
|
-
system: string;
|
|
61
|
-
name: string;
|
|
62
|
-
kind: string;
|
|
63
|
-
externalId?: string;
|
|
64
|
-
role: string;
|
|
65
|
-
/** What the system keeps about the organization, as it filed it in Cauthy. */
|
|
66
|
-
metadata: Record<string, JsonValue>;
|
|
67
|
-
}
|
|
68
|
-
/** A signed-in person, as the server sees them. */
|
|
69
|
-
interface Session {
|
|
70
|
-
user: SessionUser;
|
|
71
|
-
/** The Cauthy tenant the account is of. */
|
|
72
|
-
tenantId: string;
|
|
73
|
-
/** The roles the account holds in that tenant. */
|
|
74
|
-
roles: string[];
|
|
75
|
-
/**
|
|
76
|
-
* Cauthy's access token for this person: send it as `Authorization: Bearer`
|
|
77
|
-
* to another service that verifies Cauthy's tokens. Never give it to the browser.
|
|
78
|
-
*/
|
|
79
|
-
accessToken: string;
|
|
80
|
-
/** When the access token expires and the session is checked with Cauthy again (ISO 8601, UTC). */
|
|
81
|
-
expiresAt: string;
|
|
82
|
-
}
|
|
83
|
-
/** What the browser is told of a session: who, and their organizations — never a token. */
|
|
84
|
-
interface PublicSession {
|
|
85
|
-
user: SessionUser;
|
|
86
|
-
tenantId: string;
|
|
87
|
-
roles: string[];
|
|
88
|
-
organizations: SessionOrganization[];
|
|
89
|
-
expiresAt: string;
|
|
90
|
-
}
|
|
91
|
-
/** Why there is no session. */
|
|
92
|
-
type SessionStatus = 'authenticated' | 'unauthenticated' | 'expired';
|
|
93
|
-
declare class CauthyConfigError extends Error {
|
|
94
|
-
constructor(message: string);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { CauthyConfigError as C, type JsonValue as J, type PublicSession as P, type Session as S, type CauthyOptions as a, type SessionOrganization as b, type SessionStatus as c, type SessionUser as d };
|
package/dist/types-BwCjBn-K.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/** How an application is set up to sign its people in with Cauthy. */
|
|
2
|
-
interface CauthyOptions {
|
|
3
|
-
/** Cauthy's public address, e.g. `https://id.example.com`. Default: `CAUTHY_ISSUER`. */
|
|
4
|
-
issuer?: string;
|
|
5
|
-
/** The application's OAuth client id. Default: `CAUTHY_CLIENT_ID`. */
|
|
6
|
-
clientId?: string;
|
|
7
|
-
/** Its secret, when the client is confidential. Default: `CAUTHY_CLIENT_SECRET`. */
|
|
8
|
-
clientSecret?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The key the session cookie is encrypted with: any string of 32 characters
|
|
11
|
-
* or more, kept on the server. Default: `CAUTHY_SECRET`.
|
|
12
|
-
*/
|
|
13
|
-
secret?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The system this application is, as its organizations are filed under in
|
|
16
|
-
* Cauthy (`"pondari"`). When set, a session's organizations are that
|
|
17
|
-
* system's. Default: `CAUTHY_SYSTEM`.
|
|
18
|
-
*/
|
|
19
|
-
system?: string;
|
|
20
|
-
/** Where the routes are mounted. Default: `/api/auth`. */
|
|
21
|
-
basePath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The application's own public origin (`https://app.example.com`), for the
|
|
24
|
-
* redirect URI. Default: the origin of each request, which is right unless
|
|
25
|
-
* a proxy hides it.
|
|
26
|
-
*/
|
|
27
|
-
baseURL?: string;
|
|
28
|
-
/** Where a person lands after signing in, when no `return_to` was asked. Default: `/`. */
|
|
29
|
-
afterSignIn?: string;
|
|
30
|
-
/** Where a person lands after signing out. Default: `/`. */
|
|
31
|
-
afterSignOut?: string;
|
|
32
|
-
/** Name of the session cookie. Default: `cauthy_session`. */
|
|
33
|
-
cookieName?: string;
|
|
34
|
-
/** `fetch` to reach Cauthy with. Default: the global one. */
|
|
35
|
-
fetch?: typeof fetch;
|
|
36
|
-
}
|
|
37
|
-
/** The person signed in. Every moment is UTC. */
|
|
38
|
-
interface SessionUser {
|
|
39
|
-
id: string;
|
|
40
|
-
email: string;
|
|
41
|
-
name: string;
|
|
42
|
-
emailVerified: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* True when the account ran out of time to confirm its address: let it read
|
|
45
|
-
* and refuse its writes.
|
|
46
|
-
*/
|
|
47
|
-
restricted: boolean;
|
|
48
|
-
/** When an unconfirmed address stops being enough (ISO 8601, UTC), if there is a deadline. */
|
|
49
|
-
emailVerifyBy?: string;
|
|
50
|
-
/** The language the person reads in ("es", "en-US"), when Cauthy knows it. */
|
|
51
|
-
locale?: string;
|
|
52
|
-
}
|
|
53
|
-
/** A value JSON can carry. What crosses from server to browser is typed as this, never `unknown`. */
|
|
54
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
55
|
-
[key: string]: JsonValue;
|
|
56
|
-
};
|
|
57
|
-
/** An organization the person belongs to, with their role in it. */
|
|
58
|
-
interface SessionOrganization {
|
|
59
|
-
id: string;
|
|
60
|
-
system: string;
|
|
61
|
-
name: string;
|
|
62
|
-
kind: string;
|
|
63
|
-
externalId?: string;
|
|
64
|
-
role: string;
|
|
65
|
-
/** What the system keeps about the organization, as it filed it in Cauthy. */
|
|
66
|
-
metadata: Record<string, JsonValue>;
|
|
67
|
-
}
|
|
68
|
-
/** A signed-in person, as the server sees them. */
|
|
69
|
-
interface Session {
|
|
70
|
-
user: SessionUser;
|
|
71
|
-
/** The Cauthy tenant the account is of. */
|
|
72
|
-
tenantId: string;
|
|
73
|
-
/** The roles the account holds in that tenant. */
|
|
74
|
-
roles: string[];
|
|
75
|
-
/**
|
|
76
|
-
* Cauthy's access token for this person: send it as `Authorization: Bearer`
|
|
77
|
-
* to another service that verifies Cauthy's tokens. Never give it to the browser.
|
|
78
|
-
*/
|
|
79
|
-
accessToken: string;
|
|
80
|
-
/** When the access token expires and the session is checked with Cauthy again (ISO 8601, UTC). */
|
|
81
|
-
expiresAt: string;
|
|
82
|
-
}
|
|
83
|
-
/** What the browser is told of a session: who, and their organizations — never a token. */
|
|
84
|
-
interface PublicSession {
|
|
85
|
-
user: SessionUser;
|
|
86
|
-
tenantId: string;
|
|
87
|
-
roles: string[];
|
|
88
|
-
organizations: SessionOrganization[];
|
|
89
|
-
expiresAt: string;
|
|
90
|
-
}
|
|
91
|
-
/** Why there is no session. */
|
|
92
|
-
type SessionStatus = 'authenticated' | 'unauthenticated' | 'expired';
|
|
93
|
-
declare class CauthyConfigError extends Error {
|
|
94
|
-
constructor(message: string);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { CauthyConfigError as C, type JsonValue as J, type PublicSession as P, type Session as S, type CauthyOptions as a, type SessionOrganization as b, type SessionStatus as c, type SessionUser as d };
|