@farm.js/auth0 0.1.35 → 0.1.36
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.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AA+BhG,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;IACzE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EA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js
CHANGED
|
@@ -2,13 +2,13 @@ import { createHash, createHmac, randomBytes, timingSafeEqual } from "node:crypt
|
|
|
2
2
|
import { defineIntegration, integrationRoute } from "@farm.js/core";
|
|
3
3
|
import { describeIntegrationOriginRejection, resolveIntegrationAllowedOrigins, validateIntegrationRequestOrigin, } from "@farm.js/core/integrations";
|
|
4
4
|
import { clearRequestCookie, createPathInferredClientApi, createDocumentNavigationMatchers, createRequestCookie, getOrigin, getReturnTo, integrationConfig, normalizeMatchers, parseCookieHeaderMap, resolveCallbackSettings, } from "@farm.js/integration-utils";
|
|
5
|
+
import { resolveDevelopmentSecret } from "@farm.js/integration-utils/dev-secret";
|
|
5
6
|
import { auth0Client } from "./client.js";
|
|
6
|
-
const DEV_SECRET = "farmjs-auth0-development-secret-2026";
|
|
7
7
|
// The built server re-evaluates farm.config.ts at runtime to instantiate
|
|
8
8
|
// integrations, and Farm does not force NODE_ENV=production into that process.
|
|
9
9
|
// Treating an absent NODE_ENV as "development" would silently sign production
|
|
10
|
-
// sessions with
|
|
11
|
-
// use
|
|
10
|
+
// sessions with a development secret, so only an explicit dev/test value may
|
|
11
|
+
// use one. `farm dev` runs through Vite, which sets NODE_ENV="development".
|
|
12
12
|
function isExplicitDevelopmentEnv() {
|
|
13
13
|
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
14
14
|
}
|
|
@@ -34,13 +34,15 @@ function resolveEnv(input) {
|
|
|
34
34
|
const domain = normalizeDomain(input.domain ?? process.env.AUTH0_DOMAIN ?? "");
|
|
35
35
|
const clientId = input.clientId ?? process.env.AUTH0_CLIENT_ID ?? "";
|
|
36
36
|
const clientSecret = input.clientSecret ?? process.env.AUTH0_CLIENT_SECRET ?? "";
|
|
37
|
-
const secret = input.secret ??
|
|
37
|
+
const secret = input.secret ??
|
|
38
|
+
process.env.AUTH0_SECRET ??
|
|
39
|
+
(isExplicitDevelopmentEnv() ? resolveDevelopmentSecret("auth0") : "");
|
|
38
40
|
const appBaseUrl = input.appBaseUrl ?? process.env.APP_BASE_URL ?? undefined;
|
|
39
41
|
if (!domain || !clientId) {
|
|
40
42
|
throw new Error("Auth0 integration requires AUTH0_DOMAIN and AUTH0_CLIENT_ID.");
|
|
41
43
|
}
|
|
42
44
|
if (!secret) {
|
|
43
|
-
throw new Error("Auth0 integration requires AUTH0_SECRET. A development-only
|
|
45
|
+
throw new Error("Auth0 integration requires AUTH0_SECRET. A generated development-only secret is used " +
|
|
44
46
|
'only when NODE_ENV is "development" or "test"; set AUTH0_SECRET to a random 32-byte ' +
|
|
45
47
|
"value in every other environment.");
|
|
46
48
|
}
|
|
@@ -371,11 +373,14 @@ export function auth0(input = {}) {
|
|
|
371
373
|
const user = await createUserProfile(domain, tokenResponse.access_token, tokenResponse.id_token);
|
|
372
374
|
const issuedAt = Date.now();
|
|
373
375
|
const tokenLifetime = Math.max(tokenResponse.expires_in || 3600, 60);
|
|
374
|
-
const
|
|
376
|
+
const sessionLifetime = Math.min(tokenLifetime, sessionMaxAge ?? tokenLifetime);
|
|
377
|
+
const expiresAt = issuedAt + sessionLifetime * 1000;
|
|
375
378
|
const sessionId = randomBytes(16).toString("hex");
|
|
376
379
|
const headers = new Headers();
|
|
377
380
|
headers.append("set-cookie", createRequestCookie(sessionCookieName, signValue({ user, expiresAt, sessionId, issuedAt }, secret, "session"), request, {
|
|
378
|
-
|
|
381
|
+
// The lifetime itself, not expiresAt minus a later clock read, so the
|
|
382
|
+
// cookie's Max-Age is exact and never a second short.
|
|
383
|
+
maxAge: sessionLifetime,
|
|
379
384
|
}));
|
|
380
385
|
headers.append("set-cookie", clearRequestCookie(stateCookieName, request));
|
|
381
386
|
headers.set("location", new URL(statePayload.returnTo || "/dashboard", origin).toString());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm.js/auth0",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"description": "Auth0 integration for Farm.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@farm.js/
|
|
33
|
-
"@farm.js/
|
|
32
|
+
"@farm.js/core": "0.1.36",
|
|
33
|
+
"@farm.js/integration-utils": "0.1.36"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc",
|