@absolutejs/auth 0.50.0 → 0.52.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/dist/cli/migrate.js +33 -1
- package/dist/cli/migrate.js.map +5 -5
- package/dist/htmx/index.js +38 -5
- package/dist/htmx/index.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +134 -18
- package/dist/index.js.map +13 -13
- package/dist/oidc/config.d.ts +9 -0
- package/dist/oidc/routes.d.ts +14 -0
- package/dist/providers/clients.d.ts +1740 -6
- package/dist/providers/index.js +38 -5
- package/dist/providers/index.js.map +3 -3
- package/dist/routes/authorize.d.ts +2 -2
- package/dist/typebox.d.ts +1 -3
- package/dist/types.d.ts +29 -4
- package/dist/utils.d.ts +5 -4
- package/package.json +2 -2
|
@@ -28,7 +28,7 @@ export declare const authorize: ({ clientProviders, authorizeRoute, cookieSecure
|
|
|
28
28
|
get: {
|
|
29
29
|
body: unknown;
|
|
30
30
|
params: {
|
|
31
|
-
provider:
|
|
31
|
+
provider: string;
|
|
32
32
|
};
|
|
33
33
|
query: {
|
|
34
34
|
client?: string | undefined;
|
|
@@ -60,7 +60,7 @@ export declare const authorize: ({ clientProviders, authorizeRoute, cookieSecure
|
|
|
60
60
|
get: {
|
|
61
61
|
body: unknown;
|
|
62
62
|
params: {
|
|
63
|
-
provider:
|
|
63
|
+
provider: string;
|
|
64
64
|
};
|
|
65
65
|
query: {
|
|
66
66
|
client?: string | undefined;
|
package/dist/typebox.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export declare const authClientOption: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
2
2
|
export declare const authIntentOption: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"login">, import("@sinclair/typebox").TLiteral<"link_identity">, import("@sinclair/typebox").TLiteral<"link_connector">]>>;
|
|
3
|
-
export declare const authProviderOption: import("@sinclair/typebox").
|
|
4
|
-
[k: string]: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "attio" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "calendly" | "close" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "gohighlevel" | "google" | "hubspot" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "monday" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "pipedrive" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "slackuser" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoho" | "zoom";
|
|
5
|
-
}>;
|
|
3
|
+
export declare const authProviderOption: import("@sinclair/typebox").TString;
|
|
6
4
|
export declare const userSessionIdTypebox: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CredentialsFor, NonEmptyArray, OAuth2Client, OAuth2TokenResponse, ProviderOption, ProvidersMap } from 'citra';
|
|
1
|
+
import { CredentialsFor, CustomProviderCredentials, NonEmptyArray, OAuth2Client, OAuth2TokenResponse, ProviderConfig, ProviderOption, ProvidersMap } from 'citra';
|
|
2
2
|
import { Cookie, status as statusType, redirect as redirectType } from 'elysia';
|
|
3
3
|
import { ElysiaCustomStatusResponse } from 'elysia/error';
|
|
4
4
|
import type { ApiKeysConfig } from './apikeys/config';
|
|
@@ -35,6 +35,20 @@ export type OAuth2ProviderConfiguration<Provider extends ProviderOption> = OAuth
|
|
|
35
35
|
export type OAuth2ConfigurationOptions = {
|
|
36
36
|
[Provider in ProviderOption]?: OAuth2ProviderConfiguration<Provider>;
|
|
37
37
|
};
|
|
38
|
+
/** One client of a caller-defined (custom) OAuth provider: the full citra
|
|
39
|
+
* ProviderConfig plus this app's credentials. Same optional scope /
|
|
40
|
+
* searchParams knobs as built-in provider clients. */
|
|
41
|
+
export type CustomProviderClientConfiguration = {
|
|
42
|
+
credentials: CustomProviderCredentials;
|
|
43
|
+
providerConfig: ProviderConfig;
|
|
44
|
+
scope?: string[];
|
|
45
|
+
searchParams?: [string, string][];
|
|
46
|
+
};
|
|
47
|
+
/** Caller-defined providers keyed by YOUR provider name (any key that isn't a
|
|
48
|
+
* built-in citra provider). Single client or named client variants — the same
|
|
49
|
+
* shape as providersConfiguration. Registered providers get the full route
|
|
50
|
+
* set (authorize/callback/refresh/revoke/linked-providers) like built-ins. */
|
|
51
|
+
export type CustomProvidersConfiguration = Record<string, CustomProviderClientConfiguration | Record<string, CustomProviderClientConfiguration>>;
|
|
38
52
|
export type UserSessionId = `${string}-${string}-${string}-${string}-${string}`;
|
|
39
53
|
/** Stamped on a session created via admin impersonation (`startImpersonation`). RFC 8693
|
|
40
54
|
* actor semantics: `actorId`/`actorEmail` are the admin acting as the user, `reason` is
|
|
@@ -117,7 +131,11 @@ export type CallbackCookie = Record<string, Cookie<unknown>> & {
|
|
|
117
131
|
};
|
|
118
132
|
export type CallbackContext<UserType> = {
|
|
119
133
|
providerInstance: OAuth2Client<ProviderOption>;
|
|
120
|
-
|
|
134
|
+
/** Configured provider name — a built-in citra key or a customProviders key. */
|
|
135
|
+
authProvider: string;
|
|
136
|
+
/** The provider's citra config — pass to instantiateUserSession so identity
|
|
137
|
+
* extraction works for custom providers too. */
|
|
138
|
+
providerConfiguration: ProviderConfig;
|
|
121
139
|
authClient?: string;
|
|
122
140
|
authIntent: AuthIntent;
|
|
123
141
|
tokenResponse: OAuth2TokenResponse;
|
|
@@ -131,7 +149,7 @@ export type CallbackContext<UserType> = {
|
|
|
131
149
|
redirect: typeof redirectType;
|
|
132
150
|
};
|
|
133
151
|
export type ResolveAuthIntent<UserType> = (({ authProvider, authClient, originUrl, session, userSessionId, currentUser }: {
|
|
134
|
-
authProvider:
|
|
152
|
+
authProvider: string;
|
|
135
153
|
authClient?: string;
|
|
136
154
|
originUrl: string;
|
|
137
155
|
session: SessionRecord<UserType>;
|
|
@@ -220,6 +238,9 @@ export type AuthConfig<UserType> = {
|
|
|
220
238
|
* `protectRoute`'s context. */
|
|
221
239
|
getUser: (sub: string) => UserType | null | Promise<UserType | null>;
|
|
222
240
|
providersConfiguration: OAuth2ConfigurationOptions;
|
|
241
|
+
/** Bring-your-own OAuth providers (citra createCustomOAuth2Client) — keys
|
|
242
|
+
* must not collide with built-in provider names. */
|
|
243
|
+
customProviders?: CustomProvidersConfiguration;
|
|
223
244
|
/** Override the `Secure` attribute on every cookie the package sets (session, OAuth state,
|
|
224
245
|
* code_verifier, SSO nonce, ring, etc.). When omitted, defaults to
|
|
225
246
|
* `process.env.NODE_ENV === 'production'` — matching the convention used by
|
|
@@ -361,6 +382,8 @@ export type AuthConfig<UserType> = {
|
|
|
361
382
|
* `auth({ ...defineAuthSettings({...}), authSessionStore, providersConfiguration })`. */
|
|
362
383
|
export type AuthSettings = Pick<AuthConfig<unknown>, 'authorizeRoute' | 'callbackRoute' | 'cleanupIntervalMs' | 'maxSessions' | 'profileRoute' | 'refreshRoute' | 'revokeRoute' | 'sessionDurationMs' | 'signoutRoute' | 'statusRoute' | 'unregisteredSessionDurationMs'>;
|
|
363
384
|
export type ClientProviderEntry = {
|
|
385
|
+
providerConfiguration: ProviderConfig;
|
|
386
|
+
requiresPKCE: boolean;
|
|
364
387
|
clientName?: string;
|
|
365
388
|
providerInstance: OAuth2Client<ProviderOption>;
|
|
366
389
|
scope?: string[];
|
|
@@ -372,7 +395,9 @@ export type ClientProviderGroup = {
|
|
|
372
395
|
};
|
|
373
396
|
export type ClientProviders = Record<string, ClientProviderGroup>;
|
|
374
397
|
export type InsantiateUserSessionProps<UserType> = {
|
|
375
|
-
authProvider:
|
|
398
|
+
authProvider: string;
|
|
399
|
+
/** Required for custom providers (names outside the citra registry). */
|
|
400
|
+
providerConfiguration?: ProviderConfig;
|
|
376
401
|
tokenResponse: OAuth2TokenResponse;
|
|
377
402
|
session: SessionRecord<UserType>;
|
|
378
403
|
unregisteredSession: UnregisteredSessionRecord;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuth2Client, OAuth2TokenResponse, ProviderOption } from 'citra';
|
|
1
|
+
import { OAuth2Client, OAuth2TokenResponse, ProviderConfig, ProviderOption } from 'citra';
|
|
2
2
|
import { Cookie } from 'elysia';
|
|
3
3
|
import { AuthHtmxConfig } from './htmx/types';
|
|
4
4
|
import { AuthConfig, AuthSettings, InsantiateUserSessionProps, OAuth2ConfigurationOptions, ResolvedOAuthAuthorization, SessionRecord, UnregisteredSessionRecord, UserSessionId } from './types';
|
|
@@ -16,10 +16,11 @@ export declare const getStatus: <UserType>(session: SessionRecord<UserType>, use
|
|
|
16
16
|
error: null;
|
|
17
17
|
user: NonNullable<UserType> | null;
|
|
18
18
|
}>;
|
|
19
|
-
export declare const instantiateUserSession: <UserType>({ authProvider, cookieSecure, session, user_session_id, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser, resolvedAuthorization, sessionDurationMs, unregisteredSessionDurationMs }: InsantiateUserSessionProps<UserType>) => Promise<Response | import("./types").StatusReturn | undefined>;
|
|
19
|
+
export declare const instantiateUserSession: <UserType>({ authProvider, providerConfiguration, cookieSecure, session, user_session_id, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser, resolvedAuthorization, sessionDurationMs, unregisteredSessionDurationMs }: InsantiateUserSessionProps<UserType>) => Promise<Response | import("./types").StatusReturn | undefined>;
|
|
20
20
|
export declare const resolveCookieSecure: (override?: boolean) => boolean;
|
|
21
|
-
export declare const resolveOAuthAuthorization: ({ authProvider, providerInstance, tokenResponse, now }: {
|
|
22
|
-
authProvider:
|
|
21
|
+
export declare const resolveOAuthAuthorization: ({ authProvider, providerConfiguration, providerInstance, tokenResponse, now }: {
|
|
22
|
+
authProvider: string;
|
|
23
|
+
providerConfiguration?: ProviderConfig;
|
|
23
24
|
providerInstance: OAuth2Client<ProviderOption>;
|
|
24
25
|
tokenResponse: OAuth2TokenResponse;
|
|
25
26
|
now?: number;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.52.0",
|
|
3
3
|
"name": "@absolutejs/auth",
|
|
4
4
|
"description": "An authorization library for absolutejs",
|
|
5
5
|
"repository": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@absolutejs/linked-providers": "0.0.2",
|
|
77
77
|
"@neondatabase/serverless": "1.0.0",
|
|
78
|
-
"citra": "0.
|
|
78
|
+
"citra": "0.29.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@absolutejs/absolute": "^0.19.0-beta.1023",
|