cauthy-auth 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +52 -2
- package/dist/cauthy-By2cryXN.d.ts +56 -0
- package/dist/cauthy-DsUNqjg6.d.mts +56 -0
- package/dist/cli.js +301 -0
- package/dist/fastify.d.mts +21 -0
- package/dist/fastify.d.ts +21 -0
- package/dist/fastify.js +81 -0
- package/dist/fastify.js.map +1 -0
- package/dist/fastify.mjs +56 -0
- package/dist/fastify.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +633 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +603 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +37 -0
- package/dist/react.d.ts +37 -0
- package/dist/react.js +107 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +81 -0
- package/dist/react.mjs.map +1 -0
- package/dist/theme.d.mts +82 -0
- package/dist/theme.d.ts +82 -0
- package/dist/theme.js +254 -0
- package/dist/theme.js.map +1 -0
- package/dist/theme.mjs +226 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/types-BwCjBn-K.d.mts +97 -0
- package/dist/types-BwCjBn-K.d.ts +97 -0
- package/package.json +84 -4
|
@@ -0,0 +1,97 @@
|
|
|
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 };
|
|
@@ -0,0 +1,97 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cauthy-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sign in with Cauthy: one route to mount, getSession on the server, useSession in the browser. No database, no screens to build.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./fastify": {
|
|
16
|
+
"types": "./dist/fastify.d.ts",
|
|
17
|
+
"import": "./dist/fastify.mjs",
|
|
18
|
+
"require": "./dist/fastify.js"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react.d.ts",
|
|
22
|
+
"import": "./dist/react.mjs",
|
|
23
|
+
"require": "./dist/react.js"
|
|
24
|
+
},
|
|
25
|
+
"./theme": {
|
|
26
|
+
"types": "./dist/theme.d.ts",
|
|
27
|
+
"import": "./dist/theme.mjs",
|
|
28
|
+
"require": "./dist/theme.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "tsup --watch",
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"lint": "tsc --noEmit",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"typecheck": "tsc --noEmit"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"jose": "^5.9.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"fastify": ">=4",
|
|
49
|
+
"react": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"fastify": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"react": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^20.0.0",
|
|
61
|
+
"@types/react": "^19.0.0",
|
|
62
|
+
"fastify": "^5.6.0",
|
|
63
|
+
"react": "^19.0.0",
|
|
64
|
+
"tsup": "^8.5.0",
|
|
65
|
+
"typescript": "^5.4.0",
|
|
66
|
+
"vitest": "^3.2.0"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=20.0.0"
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"cauthy",
|
|
76
|
+
"auth",
|
|
77
|
+
"authentication",
|
|
78
|
+
"oauth",
|
|
79
|
+
"oidc",
|
|
80
|
+
"session",
|
|
81
|
+
"sso"
|
|
82
|
+
],
|
|
83
|
+
"bin": {
|
|
84
|
+
"cauthy-auth": "dist/cli.js"
|
|
85
|
+
}
|
|
86
|
+
}
|