najm-auth 3.3.2 → 3.4.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/README.md CHANGED
@@ -97,7 +97,11 @@ FRONTEND_URL=https://app.example.com
97
97
  GOOGLE_CLIENT_ID=<google-web-client-id>
98
98
  GOOGLE_CLIENT_SECRET=<google-web-client-secret>
99
99
  # Optional for a split frontend/API deployment. Otherwise FRONTEND_URL is used.
100
- GOOGLE_CALLBACK_URL=https://app.example.com/api/auth/oauth/google/callback
100
+ GOOGLE_CALLBACK_URL=https://app.example.com/api/auth/oauth/google/callback
101
+ # Optional GitHub sign-in
102
+ GITHUB_CLIENT_ID=<github-oauth-app-client-id>
103
+ GITHUB_CLIENT_SECRET=<github-oauth-app-client-secret>
104
+ GITHUB_CALLBACK_URL=https://app.example.com/api/auth/oauth/github/callback
101
105
  ```
102
106
 
103
107
  > ⚠️ **Security:** Generate secrets with `openssl rand -base64 32`
@@ -129,10 +133,10 @@ auth({
129
133
  database?: string // Default: 'default'
130
134
  blacklistPrefix?: string // Default: 'auth:blacklist:'
131
135
 
132
- // Registration
133
- defaultRole?: string | null // Auto-assign role to new users
134
- publicRegistration?: boolean // Default: true; mounts POST /auth/register
135
- bcryptRounds?: number // Default: 10 (valid: 4-31)
136
+ // Registration
137
+ defaultRole?: string | null // Auto-assign role to new users
138
+ publicRegistration?: boolean // Default: true; mounts POST /auth/register
139
+ bcryptRounds?: number // Default: 10 (valid: 4-31)
136
140
 
137
141
  // Frontend
138
142
  frontendUrl?: string // Password reset link base URL
@@ -152,7 +156,7 @@ auth({
152
156
  }
153
157
  }
154
158
 
155
- // Optional Google OpenID Connect
159
+ // Optional external identity providers
156
160
  oauth?: {
157
161
  google?: true | {
158
162
  clientId?: string // Or GOOGLE_CLIENT_ID
@@ -162,8 +166,17 @@ auth({
162
166
  errorRedirectPath?: string // Default: /login
163
167
  allowSignup?: boolean // Default: true
164
168
  autoLinkVerifiedEmail?: boolean // Default: false
165
- allowedHostedDomains?: string[] // Validates the Google hd claim
166
- }
169
+ allowedHostedDomains?: string[] // Validates the Google hd claim
170
+ }
171
+ github?: true | {
172
+ clientId?: string // Or GITHUB_CLIENT_ID
173
+ clientSecret?: string // Or GITHUB_CLIENT_SECRET
174
+ callbackUrl?: string // Or GITHUB_CALLBACK_URL
175
+ frontendCallbackPath?: string // Default: /auth/oauth/callback
176
+ errorRedirectPath?: string // Default: /login
177
+ allowSignup?: boolean // Default: true
178
+ autoLinkVerifiedEmail?: boolean // Default: false
179
+ }
167
180
  }
168
181
 
169
182
  // Dependencies (forwarded to plugins)
@@ -182,7 +195,7 @@ All routes are prefixed with `/auth` and auto-registered by the plugin.
182
195
 
183
196
  | Method | Path | Description | Auth |
184
197
  |--------|------|-------------|------|
185
- | `POST` | `/auth/register` | Register new user (omitted when `publicRegistration: false`) | None |
198
+ | `POST` | `/auth/register` | Register new user (omitted when `publicRegistration: false`) | None |
186
199
  | `POST` | `/auth/login` | Login with email/password | None |
187
200
  | `POST` | `/auth/refresh` | Refresh access token (cookie) | None (uses refresh cookie) |
188
201
  | `POST` | `/auth/session/recover` | Reissue signed session without token rotation | Refresh cookie + recovery header |
@@ -195,12 +208,12 @@ All routes are prefixed with `/auth` and auto-registered by the plugin.
195
208
  | `POST` | `/auth/oauth/google/link` | Link Google to the current user | ✅ Required |
196
209
  | `GET` | `/auth/credential-setup/setup` | Read the pending setup session | Setup cookie |
197
210
  | `POST` | `/auth/credential-setup/change` | Replace the temporary credential | Setup cookie |
198
- | `POST` | `/auth/credential-setup/cancel` | Abandon the setup session | Setup cookie |
199
-
200
- Applications with an approval-owned onboarding flow should set
201
- `publicRegistration: false`. This removes the unauthenticated route while
202
- retaining `AuthService.registerUser()`, `provisionUser()`, and other internal
203
- account-management APIs for trusted application services.
211
+ | `POST` | `/auth/credential-setup/cancel` | Abandon the setup session | Setup cookie |
212
+
213
+ Applications with an approval-owned onboarding flow should set
214
+ `publicRegistration: false`. This removes the unauthenticated route while
215
+ retaining `AuthService.registerUser()`, `provisionUser()`, and other internal
216
+ account-management APIs for trusted application services.
204
217
 
205
218
  ### Identity presets
206
219
 
@@ -333,8 +346,22 @@ import { GoogleLoginButton } from 'najm-auth/client/react';
333
346
  Google accounts are keyed by Google's stable `sub` claim. If an existing Najm
334
347
  user has the same email but is not linked, sign-in fails with
335
348
  `oauth_account_link_required` by default. After password login, call
336
- `client.linkOAuthAccount('google')` to prove control of both accounts. Setting
337
- `autoLinkVerifiedEmail: true` opts into verified-email linking.
349
+ `client.linkOAuthAccount('google')` to prove control of both accounts. Setting
350
+ `autoLinkVerifiedEmail: true` opts into verified-email linking.
351
+
352
+ ### GitHub Sign-In
353
+
354
+ Enable GitHub with `oauth: { github: true }`. Credentials come from
355
+ `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`; the callback defaults to
356
+ `${FRONTEND_URL}/api/auth/oauth/github/callback`. Register that exact callback
357
+ on the GitHub OAuth App, and set `GITHUB_CALLBACK_URL` only for a split-origin
358
+ deployment. GitHub login uses authorization code plus PKCE, requests
359
+ `user:email`, requires a verified primary email, and keys the durable provider
360
+ link by GitHub's numeric user ID.
361
+
362
+ The client exposes `loginWithGitHub()`, `useGitHubLogin()`, and the headless
363
+ `GitHubLoginButton`; the generic `linkOAuthAccount('github')` method links an
364
+ authenticated Najm user.
338
365
 
339
366
  ### Admin Routes (all require `@isAdmin()`)
340
367
 
@@ -637,7 +664,7 @@ credential_setup_requirements
637
664
  Existing databases must generate and run a migration after upgrading so the
638
665
  new `oauth_accounts`, `credential_setup_sessions`, and
639
666
  `credential_setup_requirements` tables exist. Custom `AuthSchema` objects may
640
- omit `oauthAccounts` while OAuth is disabled, but Google configuration fails
667
+ omit `oauthAccounts` while OAuth is disabled, but provider configuration fails
641
668
  fast unless the custom schema supplies it. Both credential-setup tables are
642
669
  required of a custom schema, because the setup flow is always mounted.
643
670
 
@@ -1,4 +1,4 @@
1
- import { R as RetryConfig, a as RequestOptions, A as AuthUser, b as AuthClientConfig, L as LoginCredentials, c as LoginResult, O as OAuthProvider, d as OAuthLoginOptions, e as AuthState, f as AuthEvent, g as AuthEventHandler } from './types-BaSfgxqE.js';
1
+ import { R as RetryConfig, a as RequestOptions, A as AuthUser, b as AuthClientConfig, L as LoginCredentials, c as LoginResult, O as OAuthProvider, d as OAuthLoginOptions, e as AuthState, f as AuthEvent, g as AuthEventHandler } from './types-CI2t8wpJ.js';
2
2
 
3
3
  interface FetchClientConfig {
4
4
  baseURL: string;
@@ -63,6 +63,7 @@ declare class NajmAuthClient {
63
63
  getOAuthLoginUrl(provider: OAuthProvider, options?: OAuthLoginOptions): string;
64
64
  loginWithOAuth(provider: OAuthProvider, options?: OAuthLoginOptions): void;
65
65
  loginWithGoogle(options?: OAuthLoginOptions): void;
66
+ loginWithGitHub(options?: OAuthLoginOptions): void;
66
67
  linkOAuthAccount(provider: OAuthProvider, options?: OAuthLoginOptions): Promise<void>;
67
68
  completeOAuthLogin(): Promise<AuthUser>;
68
69
  logout(): Promise<void>;
@@ -1,6 +1,6 @@
1
- export { F as FetchClient, H as HydrateSession, N as NajmAuthClient, c as createAuthClient } from '../NajmAuthClient-BBl-GRis.js';
2
- import { D as DecodedToken, T as TabSyncMessage, S as SyncPayload } from '../types-BaSfgxqE.js';
3
- export { b as AuthClientConfig, h as AuthError, f as AuthEvent, g as AuthEventHandler, i as AuthEventMap, e as AuthState, A as AuthUser, j as AuthenticatedLogin, C as CredentialSetupPending, L as LoginCredentials, c as LoginResult, d as OAuthLoginOptions, O as OAuthProvider, a as RequestOptions, R as RetryConfig, k as ServerResponse, l as TokenPair } from '../types-BaSfgxqE.js';
1
+ export { F as FetchClient, H as HydrateSession, N as NajmAuthClient, c as createAuthClient } from '../NajmAuthClient-BygfBCpF.js';
2
+ import { D as DecodedToken, T as TabSyncMessage, S as SyncPayload } from '../types-CI2t8wpJ.js';
3
+ export { b as AuthClientConfig, h as AuthError, f as AuthEvent, g as AuthEventHandler, i as AuthEventMap, e as AuthState, A as AuthUser, j as AuthenticatedLogin, C as CredentialSetupPending, L as LoginCredentials, c as LoginResult, d as OAuthLoginOptions, O as OAuthProvider, a as RequestOptions, R as RetryConfig, k as ServerResponse, l as TokenPair } from '../types-CI2t8wpJ.js';
4
4
 
5
5
  /**
6
6
  * Decode a JWT token payload without verification.
@@ -334,6 +334,9 @@ var NajmAuthClient = class _NajmAuthClient {
334
334
  loginWithGoogle(options) {
335
335
  this.loginWithOAuth("google", options);
336
336
  }
337
+ loginWithGitHub(options) {
338
+ this.loginWithOAuth("github", options);
339
+ }
337
340
  async linkOAuthAccount(provider, options = {}) {
338
341
  const query = options.returnTo ? `?${new URLSearchParams({ returnTo: this.validateReturnTo(options.returnTo) })}` : "";
339
342
  const res = await this.api.post(
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, ReactElement } from 'react';
3
- import { N as NajmAuthClient, H as HydrateSession } from '../../NajmAuthClient-BBl-GRis.js';
4
- import { e as AuthState, A as AuthUser, c as LoginResult, h as AuthError, L as LoginCredentials, d as OAuthLoginOptions, f as AuthEvent, i as AuthEventMap } from '../../types-BaSfgxqE.js';
3
+ import { N as NajmAuthClient, H as HydrateSession } from '../../NajmAuthClient-BygfBCpF.js';
4
+ import { e as AuthState, A as AuthUser, c as LoginResult, h as AuthError, L as LoginCredentials, d as OAuthLoginOptions, f as AuthEvent, i as AuthEventMap } from '../../types-CI2t8wpJ.js';
5
5
 
6
6
  interface AuthProviderProps {
7
7
  client: NajmAuthClient;
@@ -177,6 +177,17 @@ interface UseGoogleLoginReturn {
177
177
  }
178
178
  declare function useGoogleLogin(options?: UseGoogleLoginOptions): UseGoogleLoginReturn;
179
179
 
180
+ interface UseGitHubLoginOptions {
181
+ onError?: (error: AuthError | Error) => void;
182
+ }
183
+ interface UseGitHubLoginReturn {
184
+ loginWithGitHub: (options?: OAuthLoginOptions) => void;
185
+ linkGitHub: (options?: OAuthLoginOptions) => Promise<void>;
186
+ isRedirecting: boolean;
187
+ error: AuthError | Error | null;
188
+ }
189
+ declare function useGitHubLogin(options?: UseGitHubLoginOptions): UseGitHubLoginReturn;
190
+
180
191
  interface UseOAuthCallbackOptions {
181
192
  onSuccess?: (user: AuthUser) => void;
182
193
  onError?: (error: AuthError | Error) => void;
@@ -571,6 +582,15 @@ declare function GoogleLoginButton({ children, returnTo, onError }: GoogleLoginB
571
582
  disabled?: boolean;
572
583
  }, string | react.JSXElementConstructor<any>>;
573
584
 
585
+ interface GitHubLoginButtonProps extends OAuthLoginOptions {
586
+ children: ReactNode;
587
+ onError?: (error: Error) => void;
588
+ }
589
+ declare function GitHubLoginButton({ children, returnTo, onError }: GitHubLoginButtonProps): ReactElement<{
590
+ onClick?: (event: unknown) => void;
591
+ disabled?: boolean;
592
+ }, string | react.JSXElementConstructor<any>>;
593
+
574
594
  interface OAuthCallbackProps {
575
595
  fallback?: ReactNode;
576
596
  errorFallback?: ReactNode | ((props: {
@@ -580,4 +600,4 @@ interface OAuthCallbackProps {
580
600
  }
581
601
  declare function OAuthCallback({ fallback, errorFallback, defaultRedirect, }: OAuthCallbackProps): react.JSX.Element;
582
602
 
583
- export { AuthBoundary, type AuthEventEntry, AuthGate, AuthLoading, AuthProvider, Can, GoogleLoginButton, IfAuth, LoginButton, OAuthCallback, PermissionList, Protected, RedirectToLogin, Role, type SessionStatus, SignOutButton, SignedIn, SignedOut, UserAvatar, UserEmail, UserName, UserRole, useAuth, useAuthClient, useAuthEvent, useAuthEvents, useChangePassword, useForgotPassword, useGoogleLogin, useLogin, useLogout, useOAuthCallback, usePermissions, useRegister, useResetPassword, useSession, useUser };
603
+ export { AuthBoundary, type AuthEventEntry, AuthGate, AuthLoading, AuthProvider, Can, GitHubLoginButton, GoogleLoginButton, IfAuth, LoginButton, OAuthCallback, PermissionList, Protected, RedirectToLogin, Role, type SessionStatus, SignOutButton, SignedIn, SignedOut, UserAvatar, UserEmail, UserName, UserRole, useAuth, useAuthClient, useAuthEvent, useAuthEvents, useChangePassword, useForgotPassword, useGitHubLogin, useGoogleLogin, useLogin, useLogout, useOAuthCallback, usePermissions, useRegister, useResetPassword, useSession, useUser };
@@ -354,14 +354,48 @@ function useGoogleLogin(options) {
354
354
  }
355
355
  __name(useGoogleLogin, "useGoogleLogin");
356
356
 
357
+ // src/client/react/useGitHubLogin.ts
358
+ import { useCallback as useCallback8, useState as useState10 } from "react";
359
+ function useGitHubLogin(options) {
360
+ const client = useAuthClient();
361
+ const [isRedirecting, setIsRedirecting] = useState10(false);
362
+ const [error, setError] = useState10(null);
363
+ const fail = useCallback8((value) => {
364
+ const next = value instanceof Error ? value : new Error(String(value));
365
+ setIsRedirecting(false);
366
+ setError(next);
367
+ options?.onError?.(next);
368
+ }, [options?.onError]);
369
+ const loginWithGitHub = useCallback8((loginOptions) => {
370
+ setError(null);
371
+ setIsRedirecting(true);
372
+ try {
373
+ client.loginWithGitHub(loginOptions);
374
+ } catch (value) {
375
+ fail(value);
376
+ }
377
+ }, [client, fail]);
378
+ const linkGitHub = useCallback8(async (loginOptions) => {
379
+ setError(null);
380
+ setIsRedirecting(true);
381
+ try {
382
+ await client.linkOAuthAccount("github", loginOptions);
383
+ } catch (value) {
384
+ fail(value);
385
+ }
386
+ }, [client, fail]);
387
+ return { loginWithGitHub, linkGitHub, isRedirecting, error };
388
+ }
389
+ __name(useGitHubLogin, "useGitHubLogin");
390
+
357
391
  // src/client/react/useOAuthCallback.ts
358
- import { useCallback as useCallback8, useRef as useRef3, useState as useState10 } from "react";
392
+ import { useCallback as useCallback9, useRef as useRef3, useState as useState11 } from "react";
359
393
  function useOAuthCallback(options) {
360
394
  const client = useAuthClient();
361
395
  const promise = useRef3(null);
362
- const [isLoading, setIsLoading] = useState10(false);
363
- const [error, setError] = useState10(null);
364
- const complete = useCallback8(async () => {
396
+ const [isLoading, setIsLoading] = useState11(false);
397
+ const [error, setError] = useState11(null);
398
+ const complete = useCallback9(async () => {
365
399
  if (promise.current) return promise.current;
366
400
  setIsLoading(true);
367
401
  setError(null);
@@ -398,7 +432,7 @@ function useAuthEvent(event, handler) {
398
432
  __name(useAuthEvent, "useAuthEvent");
399
433
 
400
434
  // src/client/react/useAuthEvents.ts
401
- import { useEffect as useEffect4, useRef as useRef5, useState as useState11 } from "react";
435
+ import { useEffect as useEffect4, useRef as useRef5, useState as useState12 } from "react";
402
436
  var ALL_EVENTS = [
403
437
  "login",
404
438
  "logout",
@@ -411,7 +445,7 @@ var ALL_EVENTS = [
411
445
  function useAuthEvents(opts) {
412
446
  const client = useAuthClient();
413
447
  const max = opts?.maxEntries ?? 100;
414
- const [entries, setEntries] = useState11([]);
448
+ const [entries, setEntries] = useState12([]);
415
449
  const maxRef = useRef5(max);
416
450
  maxRef.current = max;
417
451
  useEffect4(() => {
@@ -714,6 +748,27 @@ function GoogleLoginButton({ children, returnTo, onError }) {
714
748
  }
715
749
  __name(GoogleLoginButton, "GoogleLoginButton");
716
750
 
751
+ // src/client/react/GitHubLoginButton.tsx
752
+ import { Children as Children4, cloneElement as cloneElement4, isValidElement as isValidElement4 } from "react";
753
+ function GitHubLoginButton({ children, returnTo, onError }) {
754
+ const { loginWithGitHub, isRedirecting } = useGitHubLogin({ onError });
755
+ const child = Children4.only(children);
756
+ if (!isValidElement4(child)) {
757
+ throw new Error("<GitHubLoginButton> expects a single React element as its child");
758
+ }
759
+ const element = child;
760
+ return cloneElement4(element, {
761
+ onClick: /* @__PURE__ */ __name((event) => {
762
+ element.props.onClick?.(event);
763
+ if (!event?.defaultPrevented) {
764
+ loginWithGitHub({ returnTo });
765
+ }
766
+ }, "onClick"),
767
+ disabled: Boolean(element.props.disabled || isRedirecting)
768
+ });
769
+ }
770
+ __name(GitHubLoginButton, "GitHubLoginButton");
771
+
717
772
  // src/client/react/OAuthCallback.tsx
718
773
  import { useEffect as useEffect7 } from "react";
719
774
  import { Fragment as Fragment14, jsx as jsx16 } from "react/jsx-runtime";
@@ -755,6 +810,7 @@ export {
755
810
  AuthLoading,
756
811
  AuthProvider,
757
812
  Can,
813
+ GitHubLoginButton,
758
814
  GoogleLoginButton,
759
815
  IfAuth,
760
816
  LoginButton,
@@ -776,6 +832,7 @@ export {
776
832
  useAuthEvents,
777
833
  useChangePassword,
778
834
  useForgotPassword,
835
+ useGitHubLogin,
779
836
  useGoogleLogin,
780
837
  useLogin,
781
838
  useLogout,
@@ -1,9 +1,9 @@
1
- import { A as AuthUser, R as RetryConfig } from '../../types-BaSfgxqE.js';
2
- import { F as FetchClient, N as NajmAuthClient } from '../../NajmAuthClient-BBl-GRis.js';
1
+ import { A as AuthUser, R as RetryConfig } from '../../types-CI2t8wpJ.js';
2
+ import { F as FetchClient, N as NajmAuthClient } from '../../NajmAuthClient-BygfBCpF.js';
3
3
  import { ProxySessionMode } from '../edge.js';
4
4
  export { withAuthMiddleware } from '../edge.js';
5
- import { G as GetSessionConfig, S as ServerSession$1 } from '../../getSession-BthP85UA.js';
6
- export { A as AuthConfigError, a as AuthTransportError, N as NoSessionError, g as getSession } from '../../getSession-BthP85UA.js';
5
+ import { G as GetSessionConfig, S as ServerSession$1 } from '../../getSession-DBX8XpsR.js';
6
+ export { A as AuthConfigError, a as AuthTransportError, N as NoSessionError, g as getSession } from '../../getSession-DBX8XpsR.js';
7
7
  import { S as SessionRecoveryFailure } from '../../sessionRecovery-D5Fa0yZ1.js';
8
8
  export { a as SessionRecoveryErrorDetails, b as SessionRecoveryFailureReason } from '../../sessionRecovery-D5Fa0yZ1.js';
9
9
  import 'next/server';
@@ -1045,6 +1045,9 @@ var NajmAuthClient = class _NajmAuthClient {
1045
1045
  loginWithGoogle(options) {
1046
1046
  this.loginWithOAuth("google", options);
1047
1047
  }
1048
+ loginWithGitHub(options) {
1049
+ this.loginWithOAuth("github", options);
1050
+ }
1048
1051
  async linkOAuthAccount(provider, options = {}) {
1049
1052
  const query = options.returnTo ? `?${new URLSearchParams({ returnTo: this.validateReturnTo(options.returnTo) })}` : "";
1050
1053
  const res = await this.api.post(
@@ -1,5 +1,5 @@
1
- import { S as ServerSession } from '../../getSession-BthP85UA.js';
2
- import '../../types-BaSfgxqE.js';
1
+ import { S as ServerSession } from '../../getSession-DBX8XpsR.js';
2
+ import '../../types-CI2t8wpJ.js';
3
3
  import '../../sessionRecovery-D5Fa0yZ1.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as AuthUser } from './types-BaSfgxqE.js';
1
+ import { A as AuthUser } from './types-CI2t8wpJ.js';
2
2
  import { S as SessionRecoveryFailure } from './sessionRecovery-D5Fa0yZ1.js';
3
3
 
4
4
  interface ServerSession {
package/dist/index.d.ts CHANGED
@@ -109,7 +109,7 @@ interface SessionCookieConfig {
109
109
  /** HMAC secret. Falls back to NAJM_SESSION_SECRET, then jwt.accessSecret. */
110
110
  secret?: string;
111
111
  }
112
- type OAuthProvider = 'google';
112
+ type OAuthProvider = 'google' | 'github';
113
113
  interface GoogleOAuthConfig {
114
114
  /** Google OAuth web client ID. Falls back to GOOGLE_CLIENT_ID. */
115
115
  clientId?: string;
@@ -131,12 +131,33 @@ interface GoogleOAuthConfig {
131
131
  /** Optional Google Workspace hosted-domain allowlist. */
132
132
  allowedHostedDomains?: string[];
133
133
  }
134
+ interface GitHubOAuthConfig {
135
+ /** GitHub OAuth App client ID. Falls back to GITHUB_CLIENT_ID. */
136
+ clientId?: string;
137
+ /** GitHub OAuth App client secret. Falls back to GITHUB_CLIENT_SECRET. */
138
+ clientSecret?: string;
139
+ /**
140
+ * Absolute backend callback URL registered in GitHub. Falls back to
141
+ * GITHUB_CALLBACK_URL, then `${frontendUrl}/api/auth/oauth/github/callback`.
142
+ */
143
+ callbackUrl?: string;
144
+ /** Frontend route that completes the Najm client session. */
145
+ frontendCallbackPath?: string;
146
+ /** Frontend route that receives stable OAuth errors. */
147
+ errorRedirectPath?: string;
148
+ /** Create a Najm user for a new GitHub identity (default: true). */
149
+ allowSignup?: boolean;
150
+ /** Link an existing user by verified email (default: false). */
151
+ autoLinkVerifiedEmail?: boolean;
152
+ }
134
153
  interface OAuthConfig {
135
154
  /**
136
155
  * Enable Google with environment defaults (`google: true`), or override
137
156
  * individual settings for split-origin deployments and policy changes.
138
157
  */
139
158
  google?: true | GoogleOAuthConfig;
159
+ /** Enable GitHub with environment defaults, or override provider settings. */
160
+ github?: true | GitHubOAuthConfig;
140
161
  }
141
162
  interface ResolvedGoogleOAuthConfig {
142
163
  clientId: string;
@@ -148,8 +169,18 @@ interface ResolvedGoogleOAuthConfig {
148
169
  autoLinkVerifiedEmail: boolean;
149
170
  allowedHostedDomains: string[];
150
171
  }
172
+ interface ResolvedGitHubOAuthConfig {
173
+ clientId: string;
174
+ clientSecret: string;
175
+ callbackUrl: string;
176
+ frontendCallbackPath: string;
177
+ errorRedirectPath: string;
178
+ allowSignup: boolean;
179
+ autoLinkVerifiedEmail: boolean;
180
+ }
151
181
  interface ResolvedOAuthConfig {
152
182
  google?: ResolvedGoogleOAuthConfig;
183
+ github?: ResolvedGitHubOAuthConfig;
153
184
  }
154
185
  /**
155
186
  * Complete auth plugin configuration (internal)
@@ -723,7 +754,6 @@ declare class UserValidator {
723
754
  * Check if user exists by email
724
755
  */
725
756
  checkUserExistsByEmail(email: string): Promise<{
726
- password: string;
727
757
  id: string;
728
758
  name: string;
729
759
  createdAt: string;
@@ -732,8 +762,9 @@ declare class UserValidator {
732
762
  emailVerified: boolean;
733
763
  phone: string;
734
764
  phoneVerified: boolean;
765
+ password: string;
735
766
  image: string;
736
- status: "active" | "pending" | "inactive";
767
+ status: "active" | "inactive" | "pending";
737
768
  roleId: string;
738
769
  lastLogin: string;
739
770
  failedLoginAttempts: number;
@@ -745,7 +776,6 @@ declare class UserValidator {
745
776
  * Check if email exists in database
746
777
  */
747
778
  checkEmailExists(email: string): Promise<{
748
- password: string;
749
779
  id: string;
750
780
  name: string;
751
781
  createdAt: string;
@@ -754,8 +784,9 @@ declare class UserValidator {
754
784
  emailVerified: boolean;
755
785
  phone: string;
756
786
  phoneVerified: boolean;
787
+ password: string;
757
788
  image: string;
758
- status: "active" | "pending" | "inactive";
789
+ status: "active" | "inactive" | "pending";
759
790
  roleId: string;
760
791
  lastLogin: string;
761
792
  failedLoginAttempts: number;
@@ -1281,8 +1312,8 @@ declare const createUserDto: z.ZodObject<{
1281
1312
  emailVerified: z.ZodDefault<z.ZodBoolean>;
1282
1313
  status: z.ZodOptional<z.ZodEnum<{
1283
1314
  active: "active";
1284
- pending: "pending";
1285
1315
  inactive: "inactive";
1316
+ pending: "pending";
1286
1317
  }>>;
1287
1318
  }, z.core.$strip>;
1288
1319
  declare const updateUserDto: z.ZodObject<{
@@ -1294,8 +1325,8 @@ declare const updateUserDto: z.ZodObject<{
1294
1325
  emailVerified: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1295
1326
  status: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
1296
1327
  active: "active";
1297
- pending: "pending";
1298
1328
  inactive: "inactive";
1329
+ pending: "pending";
1299
1330
  }>>>;
1300
1331
  }, z.core.$strip>;
1301
1332
  declare const registerDto: z.ZodObject<{
@@ -1678,7 +1709,6 @@ declare class AuthController {
1678
1709
  constructor(authService: AuthService);
1679
1710
  loginUser(body: LoginDto): Promise<LoginResult>;
1680
1711
  inviteUser(body: InviteUserDto): Promise<Omit<{
1681
- password: string;
1682
1712
  id: string;
1683
1713
  name: string;
1684
1714
  createdAt: string;
@@ -1687,8 +1717,9 @@ declare class AuthController {
1687
1717
  emailVerified: boolean;
1688
1718
  phone: string;
1689
1719
  phoneVerified: boolean;
1720
+ password: string;
1690
1721
  image: string;
1691
- status: "active" | "pending" | "inactive";
1722
+ status: "active" | "inactive" | "pending";
1692
1723
  roleId: string;
1693
1724
  lastLogin: string;
1694
1725
  failedLoginAttempts: number;
@@ -1711,7 +1742,6 @@ declare class AuthController {
1711
1742
  message: string;
1712
1743
  }>;
1713
1744
  userProfile(authorization?: string): Promise<Omit<{
1714
- password: string;
1715
1745
  id: string;
1716
1746
  name: string;
1717
1747
  createdAt: string;
@@ -1720,8 +1750,9 @@ declare class AuthController {
1720
1750
  emailVerified: boolean;
1721
1751
  phone: string;
1722
1752
  phoneVerified: boolean;
1753
+ password: string;
1723
1754
  image: string;
1724
- status: "active" | "pending" | "inactive";
1755
+ status: "active" | "inactive" | "pending";
1725
1756
  roleId: string;
1726
1757
  lastLogin: string;
1727
1758
  failedLoginAttempts: number;
@@ -2802,4 +2833,4 @@ declare const authSeed: (config: AuthSeedConfig) => Record<string, SeedEntry>;
2802
2833
  */
2803
2834
  declare function seedAuthData(config: SeedAuthDataConfig): Promise<SeedAuthDataResult>;
2804
2835
 
2805
- export { AUTH_CONFIG, AUTH_CORE_MODULE, en as AUTH_EN, AUTH_LOCALES, AUTH_LOGIN_RATE_LIMIT_ENV, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthLoginRateLimitConfig, type AuthPluginConfig, AuthQueries, type AuthRateLimitEnvironment, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, AuthSessionService, type AuthUser, CREDENTIAL_SETUP_CODES, CREDENTIAL_SETUP_MODULE, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type CredentialSetupChangeDto, type CredentialSetupCode, type CredentialSetupConfig, CredentialSetupController, type CredentialSetupOptions, type CredentialSetupPasswordOptions, type CredentialSetupPending, CredentialSetupRepository, CredentialSetupRequirementRepository, type CredentialSetupRequirementRow, CredentialSetupRequirementService, CredentialSetupService, type CredentialSetupSessionInfo, type CredentialSetupStarted, DEFAULT_AUTH_LOGIN_RATE_LIMIT, DEFAULT_CREDENTIAL_SETUP_COOKIE_NAME, DEFAULT_CREDENTIAL_SETUP_TTL_MS, type DefineRolesOptions, type EmailParam, EncryptionService, type GoogleOAuthConfig, IdentityConfig, type IdentityResolver, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, type LoginResult, NewPermission, NewRoleEntity, NewUser, type OAuthConfig, type OAuthProvider, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, PASSWORD_SETUP_PURPOSE, PUBLIC_REGISTRATION_MODULE, PasswordSetupService, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, type ProvisionUserWithPasswordInput, type ProvisionUserWithSetupInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type RegisterDto, RegistrationController, type ResetPasswordDto, type ResolvedCredentialSetupConfig, ResolvedIdentityConfig, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, TemporaryCredentialInput, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authIdentityRateLimitKey, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createIdentityResolver, createPermissionDto, createRoleDto, createTokenDto, createUserDto, credentialSetupChangeDto, credentialSetupError, defaultCredentialSetupPasswordSchema, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmailIdentifier, isEmpty, isFile, isPath, join, languageParam, loginDto, normalizeAuthIdentifier, normalizeSetupPurpose, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, registerDto, resetPasswordDto, resolveAuthLoginRateLimitConfig, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };
2836
+ export { AUTH_CONFIG, AUTH_CORE_MODULE, en as AUTH_EN, AUTH_LOCALES, AUTH_LOGIN_RATE_LIMIT_ENV, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthLoginRateLimitConfig, type AuthPluginConfig, AuthQueries, type AuthRateLimitEnvironment, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, AuthSessionService, type AuthUser, CREDENTIAL_SETUP_CODES, CREDENTIAL_SETUP_MODULE, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type CredentialSetupChangeDto, type CredentialSetupCode, type CredentialSetupConfig, CredentialSetupController, type CredentialSetupOptions, type CredentialSetupPasswordOptions, type CredentialSetupPending, CredentialSetupRepository, CredentialSetupRequirementRepository, type CredentialSetupRequirementRow, CredentialSetupRequirementService, CredentialSetupService, type CredentialSetupSessionInfo, type CredentialSetupStarted, DEFAULT_AUTH_LOGIN_RATE_LIMIT, DEFAULT_CREDENTIAL_SETUP_COOKIE_NAME, DEFAULT_CREDENTIAL_SETUP_TTL_MS, type DefineRolesOptions, type EmailParam, EncryptionService, type GitHubOAuthConfig, type GoogleOAuthConfig, IdentityConfig, type IdentityResolver, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, type LoginResult, NewPermission, NewRoleEntity, NewUser, type OAuthConfig, type OAuthProvider, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, PASSWORD_SETUP_PURPOSE, PUBLIC_REGISTRATION_MODULE, PasswordSetupService, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, type ProvisionUserWithPasswordInput, type ProvisionUserWithSetupInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type RegisterDto, RegistrationController, type ResetPasswordDto, type ResolvedCredentialSetupConfig, ResolvedIdentityConfig, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, TemporaryCredentialInput, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authIdentityRateLimitKey, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createIdentityResolver, createPermissionDto, createRoleDto, createTokenDto, createUserDto, credentialSetupChangeDto, credentialSetupError, defaultCredentialSetupPasswordSchema, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmailIdentifier, isEmpty, isFile, isPath, join, languageParam, loginDto, normalizeAuthIdentifier, normalizeSetupPurpose, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, registerDto, resetPasswordDto, resolveAuthLoginRateLimitConfig, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };