@absolutejs/auth 0.52.1 → 0.53.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/dist/index.d.ts +1 -0
- package/dist/index.js +24 -3
- package/dist/index.js.map +6 -5
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +8722 -0
- package/dist/manifest.js.map +123 -0
- package/dist/manifest.json +329 -0
- package/dist/oidc/config.d.ts +3 -1
- package/dist/providersFromEnv.d.ts +19 -0
- package/package.json +16 -5
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"identity": {
|
|
4
|
+
"accent": "#6366f1",
|
|
5
|
+
"category": "auth",
|
|
6
|
+
"description": "OAuth/OIDC sign-in for 60+ providers, email/password, magic links, passkeys, MFA, enterprise SSO/SCIM, organizations, roles, and API keys — one Elysia plugin backed by your Postgres database.",
|
|
7
|
+
"docsUrl": "https://github.com/absolutejs/auth",
|
|
8
|
+
"name": "@absolutejs/auth",
|
|
9
|
+
"tagline": "Let people create accounts and sign in."
|
|
10
|
+
},
|
|
11
|
+
"implements": [
|
|
12
|
+
{
|
|
13
|
+
"contract": "auth/session-store",
|
|
14
|
+
"factory": "createNeonAuthSessionStore",
|
|
15
|
+
"from": "@absolutejs/auth",
|
|
16
|
+
"requires": {
|
|
17
|
+
"env": [
|
|
18
|
+
{
|
|
19
|
+
"description": "Postgres connection string",
|
|
20
|
+
"example": "postgres://user:pass@host/db",
|
|
21
|
+
"key": "DATABASE_URL",
|
|
22
|
+
"secret": true
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"title": "Your Postgres database (recommended)",
|
|
27
|
+
"wiring": {
|
|
28
|
+
"code": "createNeonAuthSessionStore(${env.DATABASE_URL} ?? \"\")",
|
|
29
|
+
"imports": [
|
|
30
|
+
{
|
|
31
|
+
"from": "@absolutejs/auth",
|
|
32
|
+
"names": [
|
|
33
|
+
"createNeonAuthSessionStore"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"contract": "auth/session-store",
|
|
41
|
+
"factory": "createInMemoryAuthSessionStore",
|
|
42
|
+
"from": "@absolutejs/auth",
|
|
43
|
+
"title": "In memory (development only — sign-ins reset on restart)",
|
|
44
|
+
"wiring": {
|
|
45
|
+
"code": "createInMemoryAuthSessionStore()",
|
|
46
|
+
"imports": [
|
|
47
|
+
{
|
|
48
|
+
"from": "@absolutejs/auth",
|
|
49
|
+
"names": [
|
|
50
|
+
"createInMemoryAuthSessionStore"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"lifecycle": [
|
|
58
|
+
{
|
|
59
|
+
"command": "bunx absolute-auth migrate",
|
|
60
|
+
"id": "migrate",
|
|
61
|
+
"idempotent": true,
|
|
62
|
+
"kind": "migration",
|
|
63
|
+
"title": "Set up the sign-in tables in your database",
|
|
64
|
+
"when": "after-install"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"command": "bunx absolute-auth migrate",
|
|
68
|
+
"id": "migrate-upgrade",
|
|
69
|
+
"idempotent": true,
|
|
70
|
+
"kind": "migration",
|
|
71
|
+
"title": "Apply new sign-in tables after upgrading",
|
|
72
|
+
"when": "after-upgrade"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"presets": [
|
|
76
|
+
{
|
|
77
|
+
"id": "social-login",
|
|
78
|
+
"title": "Social login (Google + GitHub)",
|
|
79
|
+
"values": {
|
|
80
|
+
"providersConfiguration": {
|
|
81
|
+
"github": {},
|
|
82
|
+
"google": {}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"requires": {
|
|
88
|
+
"env": [
|
|
89
|
+
{
|
|
90
|
+
"description": "Postgres connection string (sign-in tables live here)",
|
|
91
|
+
"example": "postgres://user:pass@host/db",
|
|
92
|
+
"key": "DATABASE_URL",
|
|
93
|
+
"secret": true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"description": "Discord OAuth client id",
|
|
97
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
98
|
+
"key": "DISCORD_CLIENT_ID",
|
|
99
|
+
"when": "providersConfiguration.discord"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"description": "Discord OAuth client secret",
|
|
103
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
104
|
+
"key": "DISCORD_CLIENT_SECRET",
|
|
105
|
+
"secret": true,
|
|
106
|
+
"when": "providersConfiguration.discord"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"description": "Facebook OAuth client id",
|
|
110
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
111
|
+
"key": "FACEBOOK_CLIENT_ID",
|
|
112
|
+
"when": "providersConfiguration.facebook"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"description": "Facebook OAuth client secret",
|
|
116
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
117
|
+
"key": "FACEBOOK_CLIENT_SECRET",
|
|
118
|
+
"secret": true,
|
|
119
|
+
"when": "providersConfiguration.facebook"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"description": "Github OAuth client id",
|
|
123
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
124
|
+
"key": "GITHUB_CLIENT_ID",
|
|
125
|
+
"when": "providersConfiguration.github"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"description": "Github OAuth client secret",
|
|
129
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
130
|
+
"key": "GITHUB_CLIENT_SECRET",
|
|
131
|
+
"secret": true,
|
|
132
|
+
"when": "providersConfiguration.github"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"description": "Google OAuth client id",
|
|
136
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
137
|
+
"key": "GOOGLE_CLIENT_ID",
|
|
138
|
+
"when": "providersConfiguration.google"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"description": "Google OAuth client secret",
|
|
142
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
143
|
+
"key": "GOOGLE_CLIENT_SECRET",
|
|
144
|
+
"secret": true,
|
|
145
|
+
"when": "providersConfiguration.google"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"description": "Linkedin OAuth client id",
|
|
149
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
150
|
+
"key": "LINKEDIN_CLIENT_ID",
|
|
151
|
+
"when": "providersConfiguration.linkedin"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"description": "Linkedin OAuth client secret",
|
|
155
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
156
|
+
"key": "LINKEDIN_CLIENT_SECRET",
|
|
157
|
+
"secret": true,
|
|
158
|
+
"when": "providersConfiguration.linkedin"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"description": "Microsoft OAuth client id",
|
|
162
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
163
|
+
"key": "MICROSOFT_CLIENT_ID",
|
|
164
|
+
"when": "providersConfiguration.microsoft"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"description": "Microsoft OAuth client secret",
|
|
168
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
169
|
+
"key": "MICROSOFT_CLIENT_SECRET",
|
|
170
|
+
"secret": true,
|
|
171
|
+
"when": "providersConfiguration.microsoft"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"description": "Slack OAuth client id",
|
|
175
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
176
|
+
"key": "SLACK_CLIENT_ID",
|
|
177
|
+
"when": "providersConfiguration.slack"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"description": "Slack OAuth client secret",
|
|
181
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
182
|
+
"key": "SLACK_CLIENT_SECRET",
|
|
183
|
+
"secret": true,
|
|
184
|
+
"when": "providersConfiguration.slack"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"description": "Spotify OAuth client id",
|
|
188
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
189
|
+
"key": "SPOTIFY_CLIENT_ID",
|
|
190
|
+
"when": "providersConfiguration.spotify"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"description": "Spotify OAuth client secret",
|
|
194
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
195
|
+
"key": "SPOTIFY_CLIENT_SECRET",
|
|
196
|
+
"secret": true,
|
|
197
|
+
"when": "providersConfiguration.spotify"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"description": "Twitch OAuth client id",
|
|
201
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
202
|
+
"key": "TWITCH_CLIENT_ID",
|
|
203
|
+
"when": "providersConfiguration.twitch"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"description": "Twitch OAuth client secret",
|
|
207
|
+
"docsUrl": "https://github.com/absolutejs/auth#providers",
|
|
208
|
+
"key": "TWITCH_CLIENT_SECRET",
|
|
209
|
+
"secret": true,
|
|
210
|
+
"when": "providersConfiguration.twitch"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"peers": [
|
|
214
|
+
{
|
|
215
|
+
"name": "elysia",
|
|
216
|
+
"range": ">=1.0",
|
|
217
|
+
"reason": "plugin host"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"services": [
|
|
221
|
+
{
|
|
222
|
+
"description": "Stores accounts, sessions, and audit events",
|
|
223
|
+
"id": "postgres"
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
"settings": {
|
|
228
|
+
"type": "object",
|
|
229
|
+
"properties": {
|
|
230
|
+
"cleanupIntervalMs": {
|
|
231
|
+
"description": "How often expired sessions are swept, in milliseconds.",
|
|
232
|
+
"minimum": 1000,
|
|
233
|
+
"title": "Session cleanup interval",
|
|
234
|
+
"x-group": "advanced",
|
|
235
|
+
"type": "number"
|
|
236
|
+
},
|
|
237
|
+
"cookieSecure": {
|
|
238
|
+
"description": "Only send the sign-in cookie over HTTPS. Leave off in local development.",
|
|
239
|
+
"title": "HTTPS-only cookies",
|
|
240
|
+
"x-group": "advanced",
|
|
241
|
+
"type": "boolean"
|
|
242
|
+
},
|
|
243
|
+
"maxSessions": {
|
|
244
|
+
"description": "How many devices someone can stay signed in on at once.",
|
|
245
|
+
"minimum": 1,
|
|
246
|
+
"title": "Signed-in devices per person",
|
|
247
|
+
"x-group": "sessions",
|
|
248
|
+
"type": "integer"
|
|
249
|
+
},
|
|
250
|
+
"providersConfiguration": {
|
|
251
|
+
"description": "Which services people can sign in with. Each needs a client id and secret from that provider.",
|
|
252
|
+
"title": "Sign-in providers",
|
|
253
|
+
"x-group": "providers",
|
|
254
|
+
"type": "object",
|
|
255
|
+
"patternProperties": {
|
|
256
|
+
"^(.*)$": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"properties": {
|
|
259
|
+
"scope": {
|
|
260
|
+
"description": "Extra permissions to request from the provider.",
|
|
261
|
+
"title": "Permissions",
|
|
262
|
+
"type": "array",
|
|
263
|
+
"items": {
|
|
264
|
+
"type": "string"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"sessionDurationMs": {
|
|
272
|
+
"description": "How long someone stays signed in, in milliseconds. Default is 7 days.",
|
|
273
|
+
"minimum": 60000,
|
|
274
|
+
"title": "Stay signed in for",
|
|
275
|
+
"x-group": "sessions",
|
|
276
|
+
"type": "number"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
"slots": {
|
|
281
|
+
"sessionStore": {
|
|
282
|
+
"configPath": "authSessionStore",
|
|
283
|
+
"contract": "auth/session-store",
|
|
284
|
+
"description": "Where live sign-in sessions are kept",
|
|
285
|
+
"known": [
|
|
286
|
+
"@absolutejs/auth#postgres",
|
|
287
|
+
"@absolutejs/auth#memory"
|
|
288
|
+
],
|
|
289
|
+
"required": true
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"wiring": [
|
|
293
|
+
{
|
|
294
|
+
"description": "Sign in with Google, GitHub, and 60+ other services. Add email/password later from settings.",
|
|
295
|
+
"id": "default",
|
|
296
|
+
"server": {
|
|
297
|
+
"code": ".use(\n\tawait auth({\n\t\t// TODO: return your application user for a session subject.\n\t\tgetUser: (sub) => ({ sub }),\n\t\tauthSessionStore: ${slot.sessionStore},\n\t\tcookieSecure: ${settings.cookieSecure},\n\t\tmaxSessions: ${settings.maxSessions},\n\t\tprovidersConfiguration: providersFromEnv(${settings.providersConfiguration} ?? {}),\n\t\tsessionDurationMs: ${settings.sessionDurationMs}\n\t})\n)",
|
|
298
|
+
"imports": [
|
|
299
|
+
{
|
|
300
|
+
"from": "@absolutejs/auth",
|
|
301
|
+
"names": [
|
|
302
|
+
"auth",
|
|
303
|
+
"providersFromEnv"
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"placement": "server-plugin"
|
|
308
|
+
},
|
|
309
|
+
"title": "Social sign-in (OAuth)"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
"tools": {
|
|
313
|
+
"list_sign_in_providers": {
|
|
314
|
+
"annotations": {
|
|
315
|
+
"readOnlyHint": true
|
|
316
|
+
},
|
|
317
|
+
"capabilities": [
|
|
318
|
+
"read",
|
|
319
|
+
"glob"
|
|
320
|
+
],
|
|
321
|
+
"description": "List which sign-in providers this project has configured, and which are missing credentials.",
|
|
322
|
+
"input": {
|
|
323
|
+
"type": "object",
|
|
324
|
+
"properties": {}
|
|
325
|
+
},
|
|
326
|
+
"kind": "workspace"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
package/dist/oidc/config.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import type { VciConfig } from './vci';
|
|
|
5
5
|
import type { AuthorizationCodeStore, BackchannelAuthStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
|
|
6
6
|
export declare const DEFAULT_OIDC_ROUTE: RouteString;
|
|
7
7
|
export type OidcProviderConfig<UserType> = {
|
|
8
|
-
accessTokenTtlMs?: number
|
|
8
|
+
accessTokenTtlMs?: number | ((context: {
|
|
9
|
+
scopes: string[];
|
|
10
|
+
}) => number);
|
|
9
11
|
acrValuesSupported?: string[];
|
|
10
12
|
authorizationCodeStore: AuthorizationCodeStore;
|
|
11
13
|
clientAssertionJtiStore?: ClientAssertionJtiStore;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OAuth2ConfigurationOptions } from './types';
|
|
2
|
+
export type ProviderSelection = Record<string, {
|
|
3
|
+
scope?: string[];
|
|
4
|
+
searchParams?: [string, string][];
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Build `providersConfiguration` from a serializable provider selection plus
|
|
8
|
+
* environment credentials, by convention: `<PROVIDER>_CLIENT_ID` and
|
|
9
|
+
* `<PROVIDER>_CLIENT_SECRET` (e.g. `GOOGLE_CLIENT_ID`). This is the bridge
|
|
10
|
+
* between no-code/manifest-driven configuration (which must never contain
|
|
11
|
+
* secrets) and `auth()`'s credential-bearing provider entries — the host app
|
|
12
|
+
* wires env → config, the selection stays serializable.
|
|
13
|
+
*
|
|
14
|
+
* Covers providers whose citra credentials are the standard
|
|
15
|
+
* clientId/clientSecret pair. Providers with richer credential shapes
|
|
16
|
+
* (e.g. Apple's team/key ids) should be configured directly in
|
|
17
|
+
* `providersConfiguration`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const providersFromEnv: (selection: ProviderSelection, env?: Record<string, string | undefined>) => OAuth2ConfigurationOptions;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.53.1",
|
|
3
3
|
"name": "@absolutejs/auth",
|
|
4
4
|
"description": "An authorization library for absolutejs",
|
|
5
5
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "BSL-1.1",
|
|
18
18
|
"author": "Alex Kahn",
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "rm -rf dist && bun build src/index.ts src/htmx/index.ts src/client/index.ts src/client/react.ts src/client/vue.ts src/client/solid.ts src/client/svelte.ts src/plugins/index.ts src/providers/index.ts --root src --outdir dist --sourcemap --target=bun --external elysia --external react --external vue --external solid-js --external svelte --external @opentelemetry/api --external @simplewebauthn/server --external @node-saml/node-saml && bun build src/cli/migrate.ts --outdir dist/cli --sourcemap --target=bun --external @neondatabase/serverless --external drizzle-orm && bun build src/fingerprint-client/index.ts --outdir dist/fingerprint-client --sourcemap --target=browser && tsc --emitDeclarationOnly --project tsconfig.json && chmod +x dist/cli/migrate.js",
|
|
20
|
+
"build": "rm -rf dist && bun build src/index.ts src/htmx/index.ts src/client/index.ts src/client/react.ts src/client/vue.ts src/client/solid.ts src/client/svelte.ts src/plugins/index.ts src/providers/index.ts src/manifest.ts --root src --outdir dist --sourcemap --target=bun --external elysia --external react --external vue --external solid-js --external svelte --external @opentelemetry/api --external @simplewebauthn/server --external @node-saml/node-saml && bun build src/cli/migrate.ts --outdir dist/cli --sourcemap --target=bun --external @neondatabase/serverless --external drizzle-orm && bun build src/fingerprint-client/index.ts --outdir dist/fingerprint-client --sourcemap --target=browser && tsc --emitDeclarationOnly --project tsconfig.json && chmod +x dist/cli/migrate.js && absolute-manifest emit",
|
|
21
21
|
"config": "absolute config",
|
|
22
22
|
"test": "bun test",
|
|
23
23
|
"format": "absolute prettier --write",
|
|
@@ -75,7 +75,9 @@
|
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@absolutejs/linked-providers": "0.0.2",
|
|
77
77
|
"@neondatabase/serverless": "1.0.0",
|
|
78
|
-
"citra": "0.29.1"
|
|
78
|
+
"citra": "0.29.1",
|
|
79
|
+
"@absolutejs/manifest": "^0.1.0",
|
|
80
|
+
"@sinclair/typebox": "^0.34.0"
|
|
79
81
|
},
|
|
80
82
|
"devDependencies": {
|
|
81
83
|
"@absolutejs/absolute": "^0.19.0-beta.1023",
|
|
@@ -154,7 +156,13 @@
|
|
|
154
156
|
"import": "./dist/client/vue.js",
|
|
155
157
|
"types": "./dist/client/vue.d.ts",
|
|
156
158
|
"require": "./dist/client/vue.js"
|
|
157
|
-
}
|
|
159
|
+
},
|
|
160
|
+
"./manifest": {
|
|
161
|
+
"types": "./dist/manifest.d.ts",
|
|
162
|
+
"import": "./dist/manifest.js",
|
|
163
|
+
"default": "./dist/manifest.js"
|
|
164
|
+
},
|
|
165
|
+
"./manifest.json": "./dist/manifest.json"
|
|
158
166
|
},
|
|
159
167
|
"type": "module",
|
|
160
168
|
"files": [
|
|
@@ -168,5 +176,8 @@
|
|
|
168
176
|
]
|
|
169
177
|
}
|
|
170
178
|
},
|
|
171
|
-
"build": null
|
|
179
|
+
"build": null,
|
|
180
|
+
"absolutejs": {
|
|
181
|
+
"manifestContract": 1
|
|
182
|
+
}
|
|
172
183
|
}
|