hazo_auth 10.4.7 → 10.4.8

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.
@@ -947,10 +947,10 @@ Google OAuth Sign-In allows users to authenticate with their Google accounts. Th
947
947
  5. Configure OAuth consent screen if prompted
948
948
  6. Set **Application type** to "Web application"
949
949
  7. Add **Authorized JavaScript origins**:
950
- - Development: `http://localhost:3000`
950
+ - Development: `http://localhost:<YOUR_PORT>`
951
951
  - Production: `https://yourdomain.com`
952
- 8. Add **Authorized redirect URIs**:
953
- - Development: `http://localhost:3000/api/auth/callback/google`
952
+ 8. Add **Authorized redirect URIs** — the path is fixed and exported as `GOOGLE_NEXTAUTH_CALLBACK_PATH` from `hazo_auth`:
953
+ - Development: `http://localhost:<YOUR_PORT>/api/auth/callback/google`
954
954
  - Production: `https://yourdomain.com/api/auth/callback/google`
955
955
  9. Copy the **Client ID** and **Client Secret**
956
956
 
@@ -12,6 +12,7 @@ import { handle_google_oauth_login } from "../services/oauth_service.js";
12
12
  import { get_hazo_connect_instance } from "../hazo_connect_instance.server.js";
13
13
  import { create_app_logger } from "../app_logger.js";
14
14
  import { store_google_oauth_token, GoogleTokenStorageUnconfigured } from "../services/google_token_service.js";
15
+ import { GOOGLE_OAUTH_CALLBACK_PATH, FACEBOOK_OAUTH_CALLBACK_PATH } from "../oauth_routes.js";
15
16
 
16
17
  // section: types
17
18
  export type NextAuthCallbackUser = {
@@ -102,8 +103,8 @@ export function get_nextauth_config(): AuthOptions {
102
103
  // Always redirect to our custom callback after sign-in to set hazo_auth cookies
103
104
  // The callbackUrl from signIn() comes through as `url`
104
105
  if (
105
- url.includes("/api/hazo_auth/oauth/google/callback") ||
106
- url.includes("/api/hazo_auth/oauth/facebook/callback")
106
+ url.includes(GOOGLE_OAUTH_CALLBACK_PATH) ||
107
+ url.includes(FACEBOOK_OAUTH_CALLBACK_PATH)
107
108
  ) {
108
109
  return url;
109
110
  }
@@ -118,9 +119,9 @@ export function get_nextauth_config(): AuthOptions {
118
119
 
119
120
  // Default: redirect to our custom OAuth callback to set cookies
120
121
  if (url.includes("facebook")) {
121
- return `${baseUrl}/api/hazo_auth/oauth/facebook/callback`;
122
+ return `${baseUrl}${FACEBOOK_OAUTH_CALLBACK_PATH}`;
122
123
  }
123
- return `${baseUrl}/api/hazo_auth/oauth/google/callback`;
124
+ return `${baseUrl}${GOOGLE_OAUTH_CALLBACK_PATH}`;
124
125
  },
125
126
  /**
126
127
  * Sign-in callback - handle user creation/linking for Google OAuth
@@ -0,0 +1,13 @@
1
+ // file_description: Fixed OAuth route paths exported for consumer apps and internal use
2
+
3
+ /** NextAuth's built-in OAuth redirect URI — register this in Google Cloud Console. */
4
+ export const GOOGLE_NEXTAUTH_CALLBACK_PATH = "/api/auth/callback/google" as const;
5
+
6
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Google sign-in. */
7
+ export const GOOGLE_OAUTH_CALLBACK_PATH = "/api/hazo_auth/oauth/google/callback" as const;
8
+
9
+ /** NextAuth's built-in OAuth redirect URI — register this in Facebook Developer Console. */
10
+ export const FACEBOOK_NEXTAUTH_CALLBACK_PATH = "/api/auth/callback/facebook" as const;
11
+
12
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Facebook sign-in. */
13
+ export const FACEBOOK_OAUTH_CALLBACK_PATH = "/api/hazo_auth/oauth/facebook/callback" as const;
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export { AuthenticationRequiredError, TenantRequiredError, TenantAccessDeniedErr
6
6
  export type { LegalDoc, LegalAcceptanceRecord, LegalAcceptanceMap } from './lib/legal/legal_docs_types';
7
7
  export { cn, merge_class_names } from "./lib/utils.js";
8
8
  export { HAZO_AUTH_PERMISSIONS, ALL_ADMIN_PERMISSIONS, GLOBAL_ADMIN_PERMISSION } from "./lib/constants.js";
9
+ export { GOOGLE_NEXTAUTH_CALLBACK_PATH, GOOGLE_OAUTH_CALLBACK_PATH, FACEBOOK_NEXTAUTH_CALLBACK_PATH, FACEBOOK_OAUTH_CALLBACK_PATH, } from "./lib/oauth_routes.js";
9
10
  export { requestGoogleScopes } from "./lib/auth/request_google_scopes.js";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oBAAoB,CAAC;AAGnC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGxG,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oBAAoB,CAAC;AAGnC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGxG,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -14,5 +14,6 @@ export { AuthenticationRequiredError, TenantRequiredError, TenantAccessDeniedErr
14
14
  export { cn, merge_class_names } from "./lib/utils.js";
15
15
  // section: constant_exports
16
16
  export { HAZO_AUTH_PERMISSIONS, ALL_ADMIN_PERMISSIONS, GLOBAL_ADMIN_PERMISSION } from "./lib/constants.js";
17
+ export { GOOGLE_NEXTAUTH_CALLBACK_PATH, GOOGLE_OAUTH_CALLBACK_PATH, FACEBOOK_NEXTAUTH_CALLBACK_PATH, FACEBOOK_OAUTH_CALLBACK_PATH, } from "./lib/oauth_routes.js";
17
18
  // section: google_oauth_exports
18
19
  export { requestGoogleScopes } from "./lib/auth/request_google_scopes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"nextauth_config.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/nextauth_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAW,MAAM,WAAW,CAAC;AActD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM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CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAwQjD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAW7C"}
@@ -8,6 +8,7 @@ import { handle_google_oauth_login } from "../services/oauth_service.js";
8
8
  import { get_hazo_connect_instance } from "../hazo_connect_instance.server.js";
9
9
  import { create_app_logger } from "../app_logger.js";
10
10
  import { store_google_oauth_token, GoogleTokenStorageUnconfigured } from "../services/google_token_service.js";
11
+ import { GOOGLE_OAUTH_CALLBACK_PATH, FACEBOOK_OAUTH_CALLBACK_PATH } from "../oauth_routes.js";
11
12
  // section: config
12
13
  /**
13
14
  * Gets NextAuth.js configuration with enabled OAuth providers
@@ -60,8 +61,8 @@ export function get_nextauth_config() {
60
61
  console.log("[NextAuth redirect callback]", { url, baseUrl });
61
62
  // Always redirect to our custom callback after sign-in to set hazo_auth cookies
62
63
  // The callbackUrl from signIn() comes through as `url`
63
- if (url.includes("/api/hazo_auth/oauth/google/callback") ||
64
- url.includes("/api/hazo_auth/oauth/facebook/callback")) {
64
+ if (url.includes(GOOGLE_OAUTH_CALLBACK_PATH) ||
65
+ url.includes(FACEBOOK_OAUTH_CALLBACK_PATH)) {
65
66
  return url;
66
67
  }
67
68
  // If URL is relative or same origin, allow it
@@ -73,9 +74,9 @@ export function get_nextauth_config() {
73
74
  }
74
75
  // Default: redirect to our custom OAuth callback to set cookies
75
76
  if (url.includes("facebook")) {
76
- return `${baseUrl}/api/hazo_auth/oauth/facebook/callback`;
77
+ return `${baseUrl}${FACEBOOK_OAUTH_CALLBACK_PATH}`;
77
78
  }
78
- return `${baseUrl}/api/hazo_auth/oauth/google/callback`;
79
+ return `${baseUrl}${GOOGLE_OAUTH_CALLBACK_PATH}`;
79
80
  },
80
81
  /**
81
82
  * Sign-in callback - handle user creation/linking for Google OAuth
@@ -0,0 +1,9 @@
1
+ /** NextAuth's built-in OAuth redirect URI — register this in Google Cloud Console. */
2
+ export declare const GOOGLE_NEXTAUTH_CALLBACK_PATH: "/api/auth/callback/google";
3
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Google sign-in. */
4
+ export declare const GOOGLE_OAUTH_CALLBACK_PATH: "/api/hazo_auth/oauth/google/callback";
5
+ /** NextAuth's built-in OAuth redirect URI — register this in Facebook Developer Console. */
6
+ export declare const FACEBOOK_NEXTAUTH_CALLBACK_PATH: "/api/auth/callback/facebook";
7
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Facebook sign-in. */
8
+ export declare const FACEBOOK_OAUTH_CALLBACK_PATH: "/api/hazo_auth/oauth/facebook/callback";
9
+ //# sourceMappingURL=oauth_routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth_routes.d.ts","sourceRoot":"","sources":["../../src/lib/oauth_routes.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,eAAO,MAAM,6BAA6B,EAAG,2BAAoC,CAAC;AAElF,iGAAiG;AACjG,eAAO,MAAM,0BAA0B,EAAG,sCAA+C,CAAC;AAE1F,4FAA4F;AAC5F,eAAO,MAAM,+BAA+B,EAAG,6BAAsC,CAAC;AAEtF,mGAAmG;AACnG,eAAO,MAAM,4BAA4B,EAAG,wCAAiD,CAAC"}
@@ -0,0 +1,9 @@
1
+ // file_description: Fixed OAuth route paths exported for consumer apps and internal use
2
+ /** NextAuth's built-in OAuth redirect URI — register this in Google Cloud Console. */
3
+ export const GOOGLE_NEXTAUTH_CALLBACK_PATH = "/api/auth/callback/google";
4
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Google sign-in. */
5
+ export const GOOGLE_OAUTH_CALLBACK_PATH = "/api/hazo_auth/oauth/google/callback";
6
+ /** NextAuth's built-in OAuth redirect URI — register this in Facebook Developer Console. */
7
+ export const FACEBOOK_NEXTAUTH_CALLBACK_PATH = "/api/auth/callback/facebook";
8
+ /** hazo_auth's custom post-auth handler — creates the hazo_auth session after Facebook sign-in. */
9
+ export const FACEBOOK_OAUTH_CALLBACK_PATH = "/api/hazo_auth/oauth/facebook/callback";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "10.4.7",
3
+ "version": "10.4.8",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",