hazo_auth 10.4.6 → 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.
- package/SETUP_CHECKLIST.md +3 -3
- package/cli-src/lib/auth/nextauth_config.ts +5 -4
- package/cli-src/lib/oauth_routes.ts +13 -0
- package/cli-src/lib/services/google_token_service.ts +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/auth/nextauth_config.d.ts.map +1 -1
- package/dist/lib/auth/nextauth_config.js +5 -4
- package/dist/lib/oauth_routes.d.ts +9 -0
- package/dist/lib/oauth_routes.d.ts.map +1 -0
- package/dist/lib/oauth_routes.js +9 -0
- package/dist/lib/services/google_token_service.d.ts.map +1 -1
- package/dist/lib/services/google_token_service.js +19 -2
- package/package.json +1 -1
package/SETUP_CHECKLIST.md
CHANGED
|
@@ -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
|
|
950
|
+
- Development: `http://localhost:<YOUR_PORT>`
|
|
951
951
|
- Production: `https://yourdomain.com`
|
|
952
|
-
8. Add **Authorized redirect URIs
|
|
953
|
-
- Development: `http://localhost
|
|
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(
|
|
106
|
-
url.includes(
|
|
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}
|
|
122
|
+
return `${baseUrl}${FACEBOOK_OAUTH_CALLBACK_PATH}`;
|
|
122
123
|
}
|
|
123
|
-
return `${baseUrl}
|
|
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;
|
|
@@ -90,12 +90,22 @@ export const _cryptoLoader = {
|
|
|
90
90
|
|
|
91
91
|
async function load_crypto_module() {
|
|
92
92
|
let cryptoModule: typeof import("hazo_secure/crypto") | null;
|
|
93
|
+
let importError: string | null = null;
|
|
93
94
|
try {
|
|
94
95
|
cryptoModule = await _cryptoLoader.load();
|
|
95
|
-
} catch {
|
|
96
|
+
} catch (err) {
|
|
97
|
+
importError = err instanceof Error ? err.message : String(err);
|
|
96
98
|
cryptoModule = null;
|
|
97
99
|
}
|
|
98
|
-
if (!cryptoModule)
|
|
100
|
+
if (!cryptoModule) {
|
|
101
|
+
const logger = create_app_logger();
|
|
102
|
+
logger.error("google_token_service_crypto_unavailable", {
|
|
103
|
+
filename: "google_token_service.ts",
|
|
104
|
+
reason: importError ?? "import returned null",
|
|
105
|
+
fix: "Install hazo_secure (npm install hazo_secure) and add 'hazo_secure' to serverExternalPackages in next.config.ts",
|
|
106
|
+
});
|
|
107
|
+
throw new GoogleTokenStorageUnconfigured();
|
|
108
|
+
}
|
|
99
109
|
return cryptoModule;
|
|
100
110
|
}
|
|
101
111
|
|
|
@@ -119,9 +129,16 @@ export async function store_google_oauth_token(
|
|
|
119
129
|
await (keys as unknown as { current(): Promise<unknown> }).current();
|
|
120
130
|
} catch (err) {
|
|
121
131
|
const msg = err instanceof Error ? err.message : String(err);
|
|
132
|
+
const currentKeyId = process.env.HAZO_AUTH_OAUTH_KEY_CURRENT;
|
|
133
|
+
const missingVars: string[] = [];
|
|
134
|
+
if (!currentKeyId) missingVars.push("HAZO_AUTH_OAUTH_KEY_CURRENT");
|
|
135
|
+
else if (!process.env[`HAZO_AUTH_OAUTH_KEY_${currentKeyId.toUpperCase()}`])
|
|
136
|
+
missingVars.push(`HAZO_AUTH_OAUTH_KEY_${currentKeyId.toUpperCase()}`);
|
|
122
137
|
logger.error("google_token_service_key_provider_failed", {
|
|
123
138
|
filename: "google_token_service.ts",
|
|
124
139
|
error: msg,
|
|
140
|
+
missing_env_vars: missingVars.length ? missingVars : "unknown — check HAZO_AUTH_OAUTH_KEY_CURRENT and HAZO_AUTH_OAUTH_KEY_<ID>",
|
|
141
|
+
fix: "Set HAZO_AUTH_OAUTH_KEY_CURRENT=<key-id> and HAZO_AUTH_OAUTH_KEY_<KEY-ID>=<base64-aes-key> in your environment",
|
|
125
142
|
});
|
|
126
143
|
throw new GoogleTokenStorageUnconfigured();
|
|
127
144
|
}
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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;
|
|
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;AAetD,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,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,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(
|
|
64
|
-
url.includes(
|
|
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}
|
|
77
|
+
return `${baseUrl}${FACEBOOK_OAUTH_CALLBACK_PATH}`;
|
|
77
78
|
}
|
|
78
|
-
return `${baseUrl}
|
|
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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/google_token_service.ts"],"names":[],"mappings":"AASA,qBAAa,8BAA+B,SAAQ,KAAK;;CAOxD;AAID,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,CAAA;CAAE,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAmCF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;gBACd,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC;CACvD,CAAC;
|
|
1
|
+
{"version":3,"file":"google_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/google_token_service.ts"],"names":[],"mappings":"AASA,qBAAa,8BAA+B,SAAQ,KAAK;;CAOxD;AAID,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,CAAA;CAAE,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAmCF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;gBACd,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC;CACvD,CAAC;AAyBF;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAiFf;AAID;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA6I5B;AAID;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6D1C;AAID;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAexF"}
|
|
@@ -45,14 +45,23 @@ export const _cryptoLoader = {
|
|
|
45
45
|
};
|
|
46
46
|
async function load_crypto_module() {
|
|
47
47
|
let cryptoModule;
|
|
48
|
+
let importError = null;
|
|
48
49
|
try {
|
|
49
50
|
cryptoModule = await _cryptoLoader.load();
|
|
50
51
|
}
|
|
51
|
-
catch (
|
|
52
|
+
catch (err) {
|
|
53
|
+
importError = err instanceof Error ? err.message : String(err);
|
|
52
54
|
cryptoModule = null;
|
|
53
55
|
}
|
|
54
|
-
if (!cryptoModule)
|
|
56
|
+
if (!cryptoModule) {
|
|
57
|
+
const logger = create_app_logger();
|
|
58
|
+
logger.error("google_token_service_crypto_unavailable", {
|
|
59
|
+
filename: "google_token_service.ts",
|
|
60
|
+
reason: importError !== null && importError !== void 0 ? importError : "import returned null",
|
|
61
|
+
fix: "Install hazo_secure (npm install hazo_secure) and add 'hazo_secure' to serverExternalPackages in next.config.ts",
|
|
62
|
+
});
|
|
55
63
|
throw new GoogleTokenStorageUnconfigured();
|
|
64
|
+
}
|
|
56
65
|
return cryptoModule;
|
|
57
66
|
}
|
|
58
67
|
// section: store
|
|
@@ -71,9 +80,17 @@ export async function store_google_oauth_token(params) {
|
|
|
71
80
|
}
|
|
72
81
|
catch (err) {
|
|
73
82
|
const msg = err instanceof Error ? err.message : String(err);
|
|
83
|
+
const currentKeyId = process.env.HAZO_AUTH_OAUTH_KEY_CURRENT;
|
|
84
|
+
const missingVars = [];
|
|
85
|
+
if (!currentKeyId)
|
|
86
|
+
missingVars.push("HAZO_AUTH_OAUTH_KEY_CURRENT");
|
|
87
|
+
else if (!process.env[`HAZO_AUTH_OAUTH_KEY_${currentKeyId.toUpperCase()}`])
|
|
88
|
+
missingVars.push(`HAZO_AUTH_OAUTH_KEY_${currentKeyId.toUpperCase()}`);
|
|
74
89
|
logger.error("google_token_service_key_provider_failed", {
|
|
75
90
|
filename: "google_token_service.ts",
|
|
76
91
|
error: msg,
|
|
92
|
+
missing_env_vars: missingVars.length ? missingVars : "unknown — check HAZO_AUTH_OAUTH_KEY_CURRENT and HAZO_AUTH_OAUTH_KEY_<ID>",
|
|
93
|
+
fix: "Set HAZO_AUTH_OAUTH_KEY_CURRENT=<key-id> and HAZO_AUTH_OAUTH_KEY_<KEY-ID>=<base64-aes-key> in your environment",
|
|
77
94
|
});
|
|
78
95
|
throw new GoogleTokenStorageUnconfigured();
|
|
79
96
|
}
|
package/package.json
CHANGED