@geekapps/auth-nextjs 0.12.0 → 0.14.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/connections.js +967 -25
- package/dist/connections.js.map +1 -1
- package/package.json +3 -2
- package/dist/actions.d.ts +0 -15
- package/dist/client.d.ts +0 -610
- package/dist/connections.d.ts +0 -78
- package/dist/middleware.d.ts +0 -22
- package/dist/server.d.ts +0 -138
package/dist/middleware.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
|
|
3
|
-
type AuthMiddlewareConfig = {
|
|
4
|
-
issuer?: string;
|
|
5
|
-
basePath?: string;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated cookiePrefix is now auto-derived from GEEKAPPS_AUTH_CLIENT_ID.
|
|
8
|
-
* This field is kept for backwards compatibility but is ignored.
|
|
9
|
-
*/
|
|
10
|
-
cookiePrefix?: string;
|
|
11
|
-
secureCookies?: boolean;
|
|
12
|
-
/** Base URL of this app (e.g. "https://meuapp.com"). Overrides the GEEKAPPS_APP_URL env var. */
|
|
13
|
-
appUrl?: string;
|
|
14
|
-
/**
|
|
15
|
-
* When true, unauthenticated requests are redirected to sign-in.
|
|
16
|
-
* Defaults to false — the app controls its own auth-gating.
|
|
17
|
-
*/
|
|
18
|
-
forceLoginOnUnauthenticated?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare function createAuthMiddleware(input?: AuthMiddlewareConfig): (request: NextRequest) => Promise<NextResponse>;
|
|
21
|
-
|
|
22
|
-
export { type AuthMiddlewareConfig, createAuthMiddleware };
|
package/dist/server.d.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { JWTPayload } from 'jose';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A sessão não vale mais: expirou, foi revogada no painel ou o refresh token
|
|
6
|
-
* foi invalidado. Os cookies já foram limpos quando este erro é lançado, então
|
|
7
|
-
* o tratamento normal é redirecionar para o login.
|
|
8
|
-
*/
|
|
9
|
-
declare class GeekappsSessionExpiredError extends Error {
|
|
10
|
-
readonly code: "session_expired";
|
|
11
|
-
constructor(message?: string);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Fixed URL of the Geekapps Auth Server (OIDC issuer + API). This never
|
|
15
|
-
* changes per-environment, so it is hardcoded rather than read from env.
|
|
16
|
-
*/
|
|
17
|
-
declare const GEEKAPPS_AUTH_SERVER_URL = "https://accounts-api.geekapps.com.br";
|
|
18
|
-
type GeekappsAuthConfig = {
|
|
19
|
-
/**
|
|
20
|
-
* Auth Server (OIDC) issuer URL. Defaults to GEEKAPPS_AUTH_SERVER_URL and
|
|
21
|
-
* should not need overriding in normal use.
|
|
22
|
-
*
|
|
23
|
-
* Deprecated (still supported as a fallback): GEEKAPPS_AUTH_SERVER_ISSUER,
|
|
24
|
-
* GEEKAPPS_AUTH_ISSUER, GEEKAPPS_AUTH_SERVER_URL env, GEEKAPPS_AUTH_API_URL
|
|
25
|
-
*/
|
|
26
|
-
issuer?: string;
|
|
27
|
-
/**
|
|
28
|
-
* OAuth client id. Optional when GEEKAPPS_AUTH_CLIENT_ID is defined.
|
|
29
|
-
*/
|
|
30
|
-
clientId?: string;
|
|
31
|
-
/**
|
|
32
|
-
* OAuth client secret for confidential clients. Optional when
|
|
33
|
-
* GEEKAPPS_AUTH_CLIENT_SECRET is defined.
|
|
34
|
-
*/
|
|
35
|
-
clientSecret?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Callback URL. Optional when GEEKAPPS_AUTH_REDIRECT_URI is defined.
|
|
38
|
-
* If omitted, it is inferred from the current request origin + basePath/callback.
|
|
39
|
-
*/
|
|
40
|
-
redirectUri?: string;
|
|
41
|
-
scopes?: string[];
|
|
42
|
-
basePath?: string;
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated cookiePrefix is now auto-derived from clientId.
|
|
45
|
-
* This field is kept for backwards compatibility but is ignored.
|
|
46
|
-
*/
|
|
47
|
-
cookiePrefix?: string;
|
|
48
|
-
secureCookies?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Friendly alias used by apps. Same as afterSignInRedirectTo.
|
|
51
|
-
*/
|
|
52
|
-
redirectTo?: string;
|
|
53
|
-
afterSignInRedirectTo?: string;
|
|
54
|
-
afterSignOutRedirectTo?: string;
|
|
55
|
-
};
|
|
56
|
-
type SessionTokens = {
|
|
57
|
-
accessToken: string | null;
|
|
58
|
-
refreshToken: string | null;
|
|
59
|
-
idToken: string | null;
|
|
60
|
-
sessionId: string | null;
|
|
61
|
-
};
|
|
62
|
-
type StoredAccount = {
|
|
63
|
-
/** Stable identifier — `sub` from id_token or fallback to sessionId. */
|
|
64
|
-
id: string;
|
|
65
|
-
accessToken: string;
|
|
66
|
-
refreshToken: string | null;
|
|
67
|
-
idToken: string | null;
|
|
68
|
-
sessionId: string | null;
|
|
69
|
-
user: {
|
|
70
|
-
sub: string;
|
|
71
|
-
name?: string | null;
|
|
72
|
-
email?: string | null;
|
|
73
|
-
picture?: string | null;
|
|
74
|
-
phone?: string | null;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
type ServerAuthApiClient = {
|
|
78
|
-
get: <T>(path: string) => Promise<T>;
|
|
79
|
-
post: <T>(path: string, body?: unknown) => Promise<T>;
|
|
80
|
-
patch: <T>(path: string, body?: unknown) => Promise<T>;
|
|
81
|
-
put: <T>(path: string, body?: unknown) => Promise<T>;
|
|
82
|
-
delete: <T>(path: string) => Promise<T>;
|
|
83
|
-
};
|
|
84
|
-
type ServiceAccountConfig = {
|
|
85
|
-
issuer?: string;
|
|
86
|
-
clientId?: string;
|
|
87
|
-
clientSecret?: string;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Returns a service account access token.
|
|
91
|
-
* The issuer is always the Geekapps Auth Server (GEEKAPPS_AUTH_SERVER_URL) —
|
|
92
|
-
* it does not need to be configured. Reads GEEKAPPS_SERVICE_ACCOUNT_CLIENT_ID,
|
|
93
|
-
* GEEKAPPS_SERVICE_ACCOUNT_CLIENT_SECRET by default.
|
|
94
|
-
* Any field can be overridden via the optional config argument.
|
|
95
|
-
* Tokens are cached per client and auto-renewed before expiry (~7 min TTL).
|
|
96
|
-
*/
|
|
97
|
-
declare function getServiceAccountToken(override?: ServiceAccountConfig): Promise<string | null>;
|
|
98
|
-
declare function verifyToken(token: string, issuer: string): Promise<JWTPayload | null>;
|
|
99
|
-
declare function configureGeekappsAuth(input?: GeekappsAuthConfig): {
|
|
100
|
-
handlers: {
|
|
101
|
-
GET: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
102
|
-
POST: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
103
|
-
PATCH: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
104
|
-
DELETE: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
105
|
-
};
|
|
106
|
-
GetSession: () => Promise<SessionTokens | null>;
|
|
107
|
-
GetUser: () => Promise<StoredAccount["user"] | null>;
|
|
108
|
-
GetUserById: (userId: string, applicationId?: string) => Promise<unknown | null>;
|
|
109
|
-
GetOrganizations: () => Promise<{
|
|
110
|
-
organizations: unknown[];
|
|
111
|
-
currentOrgId: string | null;
|
|
112
|
-
}>;
|
|
113
|
-
SaveSession: (tokens: SessionTokens) => Promise<void>;
|
|
114
|
-
GetAccessToken: () => Promise<string | null>;
|
|
115
|
-
GetRefreshToken: () => Promise<string | null>;
|
|
116
|
-
IsAuthenticated: () => Promise<boolean>;
|
|
117
|
-
TryRefreshTokens: () => Promise<string | null>;
|
|
118
|
-
RequireUser: (options?: {
|
|
119
|
-
redirectTo?: string;
|
|
120
|
-
}) => Promise<string>;
|
|
121
|
-
CreateAuthApiClient: () => ServerAuthApiClient;
|
|
122
|
-
cookiePrefix: string;
|
|
123
|
-
VerifyToken: (token: string) => Promise<JWTPayload | null>;
|
|
124
|
-
SignInUrl: (redirectTo?: string) => Promise<string>;
|
|
125
|
-
};
|
|
126
|
-
declare function handlers(options?: GeekappsAuthConfig): {
|
|
127
|
-
GET: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
128
|
-
POST: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
129
|
-
PATCH: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
130
|
-
DELETE: (request: NextRequest) => Promise<NextResponse<any>>;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Returns true if the current request has a valid access token in cookies.
|
|
134
|
-
* Safe to call in Server Components, Server Actions, and Route Handlers.
|
|
135
|
-
*/
|
|
136
|
-
declare function isAuthenticated(options?: GeekappsAuthConfig): Promise<boolean>;
|
|
137
|
-
|
|
138
|
-
export { GEEKAPPS_AUTH_SERVER_URL, type GeekappsAuthConfig, GeekappsSessionExpiredError, type ServerAuthApiClient, type SessionTokens, type StoredAccount, configureGeekappsAuth, getServiceAccountToken, handlers, isAuthenticated, verifyToken };
|