@absolutejs/auth 0.22.4 → 0.22.5
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.js +11078 -233
- package/dist/index.js.map +106 -17
- package/dist/src/authSessionStores.d.ts +7 -0
- package/dist/src/authorize.d.ts +12 -6
- package/dist/src/callback.d.ts +8 -2
- package/dist/src/errors.d.ts +12 -0
- package/dist/src/index.d.ts +25 -11
- package/dist/src/linkedProviderResolver.d.ts +22 -0
- package/dist/src/linkedProviderStores.d.ts +9 -0
- package/dist/src/neonLinkedProviders.d.ts +1722 -0
- package/dist/src/oauthLinkedProviderResolver.d.ts +9 -0
- package/dist/src/profile.d.ts +1 -1
- package/dist/src/protectRoute.d.ts +8 -3
- package/dist/src/providerClients.d.ts +41 -0
- package/dist/src/refresh.d.ts +5 -3
- package/dist/src/revoke.d.ts +5 -3
- package/dist/src/sessionAccess.d.ts +31 -0
- package/dist/src/sessionCleanup.d.ts +4 -2
- package/dist/src/sessionTypes.d.ts +11 -0
- package/dist/src/signout.d.ts +3 -1
- package/dist/src/typeGuards.d.ts +2 -1
- package/dist/src/typebox.d.ts +2 -0
- package/dist/src/types.d.ts +65 -12
- package/dist/src/userStatus.d.ts +3 -1
- package/dist/src/utils.d.ts +10 -2
- package/package.json +12 -5
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbsoluteAuthSessionStore } from './sessionTypes';
|
|
2
|
+
import type { SessionData, UnregisteredSessionData, UserSessionId } from './types';
|
|
3
|
+
export type CreateInMemoryAuthSessionStoreOptions<UserType> = {
|
|
4
|
+
sessions?: Record<UserSessionId, SessionData<UserType>>;
|
|
5
|
+
unregisteredSessions?: Record<UserSessionId, UnregisteredSessionData>;
|
|
6
|
+
};
|
|
7
|
+
export declare const createInMemoryAuthSessionStore: <UserType>(input?: CreateInMemoryAuthSessionStoreOptions<UserType>) => AbsoluteAuthSessionStore<UserType>;
|
package/dist/src/authorize.d.ts
CHANGED
|
@@ -29,12 +29,15 @@ export declare const authorize: ({ clientProviders, authorizeRoute, onAuthorizeS
|
|
|
29
29
|
params: {
|
|
30
30
|
provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
|
|
31
31
|
};
|
|
32
|
-
query:
|
|
32
|
+
query: {
|
|
33
|
+
client?: string | undefined;
|
|
34
|
+
intent?: "login" | "link_identity" | "link_connector" | undefined;
|
|
35
|
+
};
|
|
33
36
|
headers: unknown;
|
|
34
37
|
response: {
|
|
35
38
|
200: Response;
|
|
36
|
-
400: "
|
|
37
|
-
401: "Client provider not found";
|
|
39
|
+
400: "Provider is required" | "Cookies are missing";
|
|
40
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
|
|
38
41
|
422: {
|
|
39
42
|
type: "validation";
|
|
40
43
|
on: string;
|
|
@@ -58,12 +61,15 @@ export declare const authorize: ({ clientProviders, authorizeRoute, onAuthorizeS
|
|
|
58
61
|
params: {
|
|
59
62
|
provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
|
|
60
63
|
};
|
|
61
|
-
query:
|
|
64
|
+
query: {
|
|
65
|
+
client?: string | undefined;
|
|
66
|
+
intent?: "login" | "link_identity" | "link_connector" | undefined;
|
|
67
|
+
};
|
|
62
68
|
headers: unknown;
|
|
63
69
|
response: {
|
|
64
70
|
200: Response;
|
|
65
|
-
400: "
|
|
66
|
-
401: "Client provider not found";
|
|
71
|
+
400: "Provider is required" | "Cookies are missing";
|
|
72
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
|
|
67
73
|
422: {
|
|
68
74
|
type: "validation";
|
|
69
75
|
on: string;
|
package/dist/src/callback.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import {
|
|
2
|
+
import type { AbsoluteAuthSessionStore } from './sessionTypes';
|
|
3
|
+
import { ClientProviders, OnCallbackError, OnCallbackSuccess, OnLinkConnector, OnLinkIdentity, OnLinkIdentityConflict, ResolveAuthIntent, RouteString } from './types';
|
|
3
4
|
type CallbackProps<UserType> = {
|
|
5
|
+
authSessionStore?: AbsoluteAuthSessionStore<UserType>;
|
|
4
6
|
clientProviders: ClientProviders;
|
|
5
7
|
callbackRoute?: RouteString;
|
|
8
|
+
resolveAuthIntent?: ResolveAuthIntent<UserType>;
|
|
6
9
|
onCallbackSuccess: OnCallbackSuccess<UserType>;
|
|
10
|
+
onLinkIdentity?: OnLinkIdentity<UserType>;
|
|
11
|
+
onLinkIdentityConflict?: OnLinkIdentityConflict<UserType>;
|
|
12
|
+
onLinkConnector?: OnLinkConnector<UserType>;
|
|
7
13
|
onCallbackError: OnCallbackError;
|
|
8
14
|
};
|
|
9
|
-
export declare const callback: <UserType>({ clientProviders, callbackRoute, onCallbackSuccess, onCallbackError }: CallbackProps<UserType>) => Elysia<"", {
|
|
15
|
+
export declare const callback: <UserType>({ authSessionStore, clientProviders, callbackRoute, resolveAuthIntent, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError }: CallbackProps<UserType>) => Elysia<"", {
|
|
10
16
|
decorator: {};
|
|
11
17
|
store: {
|
|
12
18
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthIntent } from './types';
|
|
2
|
+
export type AuthIdentityConflict = {
|
|
3
|
+
authProvider: string;
|
|
4
|
+
providerSubject: string;
|
|
5
|
+
existingUserAuthSub: string;
|
|
6
|
+
currentUserAuthSub?: string;
|
|
7
|
+
intent?: AuthIntent;
|
|
8
|
+
};
|
|
9
|
+
export declare class AbsoluteAuthIdentityConflictError extends Error {
|
|
10
|
+
conflict: AuthIdentityConflict;
|
|
11
|
+
constructor(conflict: AuthIdentityConflict);
|
|
12
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { AbsoluteAuthProps } from './types';
|
|
3
|
-
export declare const absoluteAuth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
|
|
3
|
+
export declare const absoluteAuth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
|
|
4
4
|
decorator: {};
|
|
5
5
|
store: {
|
|
6
6
|
session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
|
|
@@ -90,7 +90,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
90
90
|
response: {
|
|
91
91
|
200: Response;
|
|
92
92
|
400: "Cookies are missing" | "Invalid provider";
|
|
93
|
-
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
93
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "No user session found";
|
|
94
94
|
422: {
|
|
95
95
|
type: "validation";
|
|
96
96
|
on: string;
|
|
@@ -140,7 +140,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
140
140
|
response: {
|
|
141
141
|
200: Response;
|
|
142
142
|
400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
|
|
143
|
-
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
143
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "No user session found";
|
|
144
144
|
422: {
|
|
145
145
|
type: "validation";
|
|
146
146
|
on: string;
|
|
@@ -163,12 +163,15 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
163
163
|
params: {
|
|
164
164
|
provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
|
|
165
165
|
};
|
|
166
|
-
query:
|
|
166
|
+
query: {
|
|
167
|
+
client?: string | undefined;
|
|
168
|
+
intent?: "login" | "link_identity" | "link_connector" | undefined;
|
|
169
|
+
};
|
|
167
170
|
headers: unknown;
|
|
168
171
|
response: {
|
|
169
172
|
200: Response;
|
|
170
|
-
400: "
|
|
171
|
-
401: "Client provider not found";
|
|
173
|
+
400: "Provider is required" | "Cookies are missing";
|
|
174
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
|
|
172
175
|
422: {
|
|
173
176
|
type: "validation";
|
|
174
177
|
on: string;
|
|
@@ -192,12 +195,15 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
192
195
|
params: {
|
|
193
196
|
provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
|
|
194
197
|
};
|
|
195
|
-
query:
|
|
198
|
+
query: {
|
|
199
|
+
client?: string | undefined;
|
|
200
|
+
intent?: "login" | "link_identity" | "link_connector" | undefined;
|
|
201
|
+
};
|
|
196
202
|
headers: unknown;
|
|
197
203
|
response: {
|
|
198
204
|
200: Response;
|
|
199
|
-
400: "
|
|
200
|
-
401: "Client provider not found";
|
|
205
|
+
400: "Provider is required" | "Cookies are missing";
|
|
206
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
|
|
201
207
|
422: {
|
|
202
208
|
type: "validation";
|
|
203
209
|
on: string;
|
|
@@ -235,7 +241,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
235
241
|
response: {
|
|
236
242
|
200: Response;
|
|
237
243
|
400: "Cookies are missing";
|
|
238
|
-
401: "Client provider not found" | "No auth provider found" | "Invalid provider" | "No user session found";
|
|
244
|
+
401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "Invalid provider" | "No user session found";
|
|
239
245
|
422: {
|
|
240
246
|
type: "validation";
|
|
241
247
|
on: string;
|
|
@@ -276,10 +282,18 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
276
282
|
}>>;
|
|
277
283
|
export * from './types';
|
|
278
284
|
export * from './typebox';
|
|
279
|
-
export {
|
|
285
|
+
export type { AbsoluteAuthSessionStore } from './sessionTypes';
|
|
286
|
+
export { isAuthIntent, isUserSessionId, isValidUser } from './typeGuards';
|
|
287
|
+
export { AbsoluteAuthIdentityConflictError } from './errors';
|
|
280
288
|
export { sessionStore } from './sessionStore';
|
|
289
|
+
export { createInMemoryAuthSessionStore } from './authSessionStores';
|
|
290
|
+
export { createLinkedProviderCredentialResolver } from './linkedProviderResolver';
|
|
291
|
+
export { createOAuthLinkedProviderCredentialResolver } from './oauthLinkedProviderResolver';
|
|
292
|
+
export { createNeonLinkedProviderStores, createNeonOAuthLinkedProviderCredentialResolver } from './neonLinkedProviders';
|
|
293
|
+
export { createInMemoryLinkedProviderStores } from './linkedProviderStores';
|
|
281
294
|
export { protectRoutePlugin } from './protectRoute';
|
|
282
295
|
export { sessionCleanup } from './sessionCleanup';
|
|
283
296
|
export * from './utils';
|
|
297
|
+
export { buildClientProviders, resolveClientProviderEntry, resolveProviderClientConfiguration } from './providerClients';
|
|
284
298
|
export type { OAuth2TokenResponse, OAuth2Client, ProviderOption, PKCEProvider, OIDCProvider, RefreshableProvider, RevocableProvider, ScopeRequiredProvider, ProvidersMap, ProviderConfiguration, CredentialsFor } from 'citra';
|
|
285
299
|
export { providers, providerOptions, refreshableProviderOptions, revocableProviderOptions, oidcProviderOptions, pkceProviderOptions, scopeRequiredProviderOptions, decodeJWT, extractPropFromIdentity, isValidProviderOption, isRefreshableOAuth2Client, isRefreshableProviderOption, isOIDCProviderOption, isPKCEProviderOption, isRevocableProviderOption, isRevocableOAuth2Client } from 'citra';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LinkedProviderAccessTokenLease, LinkedProviderBinding, LinkedProviderBindingStore, LinkedProviderCredentialFailureReport, LinkedProviderCredentialResolver, LinkedProviderGrant, LinkedProviderGrantStore, ResolvedLinkedProviderCredential } from '@absolutejs/linked-providers';
|
|
2
|
+
export type LinkedProviderRefreshResult = {
|
|
3
|
+
grant: LinkedProviderGrant;
|
|
4
|
+
lease: LinkedProviderAccessTokenLease;
|
|
5
|
+
};
|
|
6
|
+
export type CreateLinkedProviderCredentialResolverOptions = {
|
|
7
|
+
grantStore: LinkedProviderGrantStore;
|
|
8
|
+
bindingStore: LinkedProviderBindingStore;
|
|
9
|
+
loadAccessTokenLease: (grant: LinkedProviderGrant) => Promise<LinkedProviderAccessTokenLease | null> | LinkedProviderAccessTokenLease | null;
|
|
10
|
+
refreshAccessTokenLease?: (grant: LinkedProviderGrant, input?: {
|
|
11
|
+
minValidityMs?: number;
|
|
12
|
+
requiredScopes?: string[];
|
|
13
|
+
}) => Promise<LinkedProviderRefreshResult | null> | LinkedProviderRefreshResult | null;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
onReportFailure?: (input: {
|
|
16
|
+
credential: ResolvedLinkedProviderCredential;
|
|
17
|
+
report: LinkedProviderCredentialFailureReport;
|
|
18
|
+
grant?: LinkedProviderGrant;
|
|
19
|
+
binding?: LinkedProviderBinding;
|
|
20
|
+
}) => Promise<void> | void;
|
|
21
|
+
};
|
|
22
|
+
export declare const createLinkedProviderCredentialResolver: ({ grantStore, bindingStore, loadAccessTokenLease, refreshAccessTokenLease, now, onReportFailure }: CreateLinkedProviderCredentialResolverOptions) => LinkedProviderCredentialResolver;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LinkedProviderBinding, LinkedProviderBindingStore, LinkedProviderGrant, LinkedProviderGrantStore } from '@absolutejs/linked-providers';
|
|
2
|
+
export type CreateInMemoryLinkedProviderStoresOptions = {
|
|
3
|
+
grants?: LinkedProviderGrant[];
|
|
4
|
+
bindings?: LinkedProviderBinding[];
|
|
5
|
+
};
|
|
6
|
+
export declare const createInMemoryLinkedProviderStores: (input?: CreateInMemoryLinkedProviderStoresOptions) => {
|
|
7
|
+
grantStore: LinkedProviderGrantStore;
|
|
8
|
+
bindingStore: LinkedProviderBindingStore;
|
|
9
|
+
};
|