@agent-native/core 0.158.6 → 0.158.7
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/collab/awareness.d.ts +2 -2
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/auth.js +232 -5
- package/dist/server/better-auth-instance.js +29 -1
- package/package.json +1 -1
|
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
|
|
|
62
62
|
error: string;
|
|
63
63
|
states?: undefined;
|
|
64
64
|
} | {
|
|
65
|
+
error?: undefined;
|
|
65
66
|
states: {
|
|
66
67
|
clientId: number;
|
|
67
68
|
state: string;
|
|
68
69
|
}[];
|
|
69
|
-
error?: undefined;
|
|
70
70
|
}>>;
|
|
71
71
|
/**
|
|
72
72
|
* GET /_agent-native/collab/:docId/users
|
|
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
|
|
|
77
77
|
error: string;
|
|
78
78
|
users?: undefined;
|
|
79
79
|
} | {
|
|
80
|
+
error?: undefined;
|
|
80
81
|
users: {
|
|
81
82
|
clientId: number;
|
|
82
83
|
lastSeen: number;
|
|
83
84
|
}[];
|
|
84
|
-
error?: undefined;
|
|
85
85
|
}>>;
|
|
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
|
|
|
41
41
|
thumbsUpRate: number;
|
|
42
42
|
avgEvalScore: number;
|
|
43
43
|
} | {
|
|
44
|
-
error?: undefined;
|
|
45
|
-
ok?: undefined;
|
|
46
44
|
summary: import("./types.js").TraceSummary;
|
|
47
45
|
spans: import("./types.js").TraceSpan[];
|
|
48
46
|
id?: undefined;
|
|
49
|
-
} | {
|
|
50
47
|
error?: undefined;
|
|
51
48
|
ok?: undefined;
|
|
49
|
+
} | {
|
|
52
50
|
summary?: undefined;
|
|
53
51
|
spans?: undefined;
|
|
54
52
|
id: string;
|
|
55
|
-
|
|
53
|
+
error?: undefined;
|
|
56
54
|
ok?: undefined;
|
|
55
|
+
} | {
|
|
57
56
|
summary?: undefined;
|
|
58
57
|
spans?: undefined;
|
|
59
58
|
id?: undefined;
|
|
60
59
|
error: any;
|
|
60
|
+
ok?: undefined;
|
|
61
61
|
} | {
|
|
62
|
-
error?: undefined;
|
|
63
62
|
summary?: undefined;
|
|
64
63
|
spans?: undefined;
|
|
65
64
|
id?: undefined;
|
|
65
|
+
error?: undefined;
|
|
66
66
|
ok: boolean;
|
|
67
67
|
}>>;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
|
|
|
34
34
|
/** POST /_agent-native/secrets/:key — write a secret. */
|
|
35
35
|
export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
36
36
|
error: string;
|
|
37
|
-
ok?: undefined;
|
|
38
37
|
status?: undefined;
|
|
38
|
+
ok?: undefined;
|
|
39
39
|
} | {
|
|
40
|
-
error?: undefined;
|
|
41
40
|
ok: boolean;
|
|
42
41
|
status: string;
|
|
42
|
+
error?: undefined;
|
|
43
43
|
} | {
|
|
44
|
-
ok?: undefined;
|
|
45
44
|
error: string;
|
|
46
45
|
removed?: undefined;
|
|
46
|
+
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
error?: undefined;
|
|
49
48
|
ok: boolean;
|
|
50
49
|
removed: boolean;
|
|
50
|
+
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — validate an optional candidate value
|
|
54
54
|
* or the current stored value without changing anything.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
57
|
-
ok?: undefined;
|
|
58
57
|
error: string;
|
|
59
58
|
note?: undefined;
|
|
59
|
+
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
error?: undefined;
|
|
62
61
|
ok: boolean;
|
|
63
62
|
note?: undefined;
|
|
64
|
-
} | {
|
|
65
63
|
error?: undefined;
|
|
64
|
+
} | {
|
|
66
65
|
ok: boolean;
|
|
67
66
|
note: string;
|
|
67
|
+
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
-
error?: undefined;
|
|
99
98
|
ok: boolean;
|
|
100
99
|
key: string;
|
|
101
|
-
} | {
|
|
102
100
|
error?: undefined;
|
|
101
|
+
} | {
|
|
103
102
|
ok: boolean;
|
|
104
103
|
removed: boolean;
|
|
104
|
+
error?: undefined;
|
|
105
105
|
}>>;
|
|
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
|
|
|
27
27
|
export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
28
28
|
error: any;
|
|
29
29
|
} | {
|
|
30
|
-
error?: undefined;
|
|
31
30
|
ok: boolean;
|
|
32
31
|
key: string;
|
|
33
32
|
baseUrlKey?: string;
|
|
34
33
|
scope: AgentEngineApiKeyScope;
|
|
34
|
+
error?: undefined;
|
|
35
35
|
}>>;
|
|
36
36
|
export {};
|
package/dist/server/auth.js
CHANGED
|
@@ -1538,6 +1538,162 @@ function escapeHtmlAttr(value) {
|
|
|
1538
1538
|
const DESKTOP_MAGIC_LINK_CALLBACK_PATH = "/_agent-native/auth/magic-link/desktop-callback";
|
|
1539
1539
|
const DESKTOP_MAGIC_LINK_LANDING_PATH = "/_agent-native/auth/magic-link/desktop-landing";
|
|
1540
1540
|
const BETTER_AUTH_MAGIC_LINK_VERIFY_PATH = "/_agent-native/auth/ba/magic-link/verify";
|
|
1541
|
+
function magicLinkDigest(value) {
|
|
1542
|
+
return crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
1543
|
+
}
|
|
1544
|
+
function magicLinkStoredIdentifier(token) {
|
|
1545
|
+
return crypto.createHash("sha256").update(token).digest("base64url");
|
|
1546
|
+
}
|
|
1547
|
+
function redactMagicLinkUrl(value, baseURL) {
|
|
1548
|
+
try {
|
|
1549
|
+
const url = new URL(value, baseURL);
|
|
1550
|
+
for (const key of ["token", "flow_id", "verifier", "state"]) {
|
|
1551
|
+
if (url.searchParams.has(key))
|
|
1552
|
+
url.searchParams.set(key, "[redacted]");
|
|
1553
|
+
}
|
|
1554
|
+
for (const key of [
|
|
1555
|
+
"callbackURL",
|
|
1556
|
+
"newUserCallbackURL",
|
|
1557
|
+
"errorCallbackURL",
|
|
1558
|
+
]) {
|
|
1559
|
+
const callback = url.searchParams.get(key);
|
|
1560
|
+
if (!callback)
|
|
1561
|
+
continue;
|
|
1562
|
+
try {
|
|
1563
|
+
const callbackURL = new URL(callback, url.origin);
|
|
1564
|
+
for (const nestedKey of ["flow_id", "verifier", "state"]) {
|
|
1565
|
+
if (callbackURL.searchParams.has(nestedKey)) {
|
|
1566
|
+
callbackURL.searchParams.set(nestedKey, "[redacted]");
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
url.searchParams.set(key, callbackURL.toString());
|
|
1570
|
+
}
|
|
1571
|
+
catch {
|
|
1572
|
+
url.searchParams.set(key, "[invalid]");
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return `${url.pathname}${url.search}`;
|
|
1576
|
+
}
|
|
1577
|
+
catch {
|
|
1578
|
+
return "[invalid-url]";
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
function magicLinkRequestDetails(event, values, verificationURL) {
|
|
1582
|
+
const token = typeof values.token === "string" ? values.token.trim() : "";
|
|
1583
|
+
const callbackValue = typeof values.callbackURL === "string" ? values.callbackURL : "";
|
|
1584
|
+
let callback;
|
|
1585
|
+
try {
|
|
1586
|
+
callback = callbackValue
|
|
1587
|
+
? new URL(callbackValue, getOrigin(event))
|
|
1588
|
+
: undefined;
|
|
1589
|
+
}
|
|
1590
|
+
catch {
|
|
1591
|
+
callback = undefined;
|
|
1592
|
+
}
|
|
1593
|
+
return {
|
|
1594
|
+
requestMethod: getMethod(event),
|
|
1595
|
+
requestUrl: redactMagicLinkUrl(event.node?.req?.url ?? event.path ?? "", getOrigin(event)),
|
|
1596
|
+
verificationUrl: verificationURL
|
|
1597
|
+
? redactMagicLinkUrl(verificationURL.toString(), getOrigin(event))
|
|
1598
|
+
: undefined,
|
|
1599
|
+
verificationMethod: verificationURL ? "GET" : undefined,
|
|
1600
|
+
tokenPresent: Boolean(token),
|
|
1601
|
+
tokenLength: token.length || undefined,
|
|
1602
|
+
tokenDigest: token ? magicLinkDigest(token) : undefined,
|
|
1603
|
+
expectedStoredIdentifierPrefix: token
|
|
1604
|
+
? magicLinkStoredIdentifier(token).slice(0, 16)
|
|
1605
|
+
: undefined,
|
|
1606
|
+
callbackURLPresent: Boolean(callbackValue),
|
|
1607
|
+
callbackPath: callback?.pathname,
|
|
1608
|
+
hasFlowId: Boolean(callback?.searchParams.get("flow_id")),
|
|
1609
|
+
hasVerifier: Boolean(callback?.searchParams.get("verifier")),
|
|
1610
|
+
hasState: Boolean(callback?.searchParams.get("state") || values.state),
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
async function inspectMagicLinkVerification(auth, token) {
|
|
1614
|
+
const storedIdentifier = magicLinkStoredIdentifier(token);
|
|
1615
|
+
try {
|
|
1616
|
+
const context = await auth.$context;
|
|
1617
|
+
const findVerificationValue = context?.internalAdapter?.findVerificationValue;
|
|
1618
|
+
if (typeof findVerificationValue !== "function") {
|
|
1619
|
+
return {
|
|
1620
|
+
lookup: "adapter-unavailable",
|
|
1621
|
+
lookupKeyPrefix: storedIdentifier.slice(0, 16),
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
const record = await findVerificationValue(storedIdentifier);
|
|
1625
|
+
if (!record) {
|
|
1626
|
+
return {
|
|
1627
|
+
lookup: "absent",
|
|
1628
|
+
lookupKeyPrefix: storedIdentifier.slice(0, 16),
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
const expiresAt = new Date(String(record.expiresAt ?? ""));
|
|
1632
|
+
const expiryState = Number.isFinite(expiresAt.getTime())
|
|
1633
|
+
? expiresAt.getTime() <= Date.now()
|
|
1634
|
+
? "expired"
|
|
1635
|
+
: "valid"
|
|
1636
|
+
: "invalid-expiry";
|
|
1637
|
+
return {
|
|
1638
|
+
lookup: "present",
|
|
1639
|
+
lookupKeyPrefix: storedIdentifier.slice(0, 16),
|
|
1640
|
+
expiryState,
|
|
1641
|
+
expiresAt: Number.isFinite(expiresAt.getTime())
|
|
1642
|
+
? expiresAt.toISOString()
|
|
1643
|
+
: undefined,
|
|
1644
|
+
valuePresent: "value" in record,
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
catch (error) {
|
|
1648
|
+
return {
|
|
1649
|
+
lookup: "lookup-error",
|
|
1650
|
+
lookupKeyPrefix: storedIdentifier.slice(0, 16),
|
|
1651
|
+
errorType: error instanceof Error ? error.constructor.name : "unknown",
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
function logMagicLinkDebug(event, phase, details = {}) {
|
|
1656
|
+
console.info("[agent-native][magic-link]", {
|
|
1657
|
+
phase,
|
|
1658
|
+
app: getOAuthStateAppId(),
|
|
1659
|
+
agentNativeDesktop: /AgentNativeDesktop/i.test(getHeader(event, "user-agent") || ""),
|
|
1660
|
+
...details,
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
function magicLinkResponseError(response, baseURL) {
|
|
1664
|
+
const location = response.headers.get("location");
|
|
1665
|
+
if (!location)
|
|
1666
|
+
return undefined;
|
|
1667
|
+
try {
|
|
1668
|
+
return new URL(location, baseURL).searchParams.get("error") || undefined;
|
|
1669
|
+
// coercion-ok: a malformed redirect cannot contain a diagnostic error code.
|
|
1670
|
+
}
|
|
1671
|
+
catch {
|
|
1672
|
+
return undefined;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function logMagicLinkVerificationResponse(event, source, response, preConsume) {
|
|
1676
|
+
const error = magicLinkResponseError(response, getOrigin(event));
|
|
1677
|
+
const invalidToken = error === "INVALID_TOKEN";
|
|
1678
|
+
logMagicLinkDebug(event, "verify-response", {
|
|
1679
|
+
source,
|
|
1680
|
+
responseStatus: response.status,
|
|
1681
|
+
responseLocation: redactMagicLinkUrl(response.headers.get("location") || "", getOrigin(event)),
|
|
1682
|
+
producer: invalidToken ? "better-auth.magic-link.verify" : undefined,
|
|
1683
|
+
reason: invalidToken ? "consumeVerificationValue returned null" : undefined,
|
|
1684
|
+
preConsume,
|
|
1685
|
+
classification: invalidToken
|
|
1686
|
+
? preConsume?.lookup === "present" && preConsume.expiryState === "valid"
|
|
1687
|
+
? "valid-row-before-consume"
|
|
1688
|
+
: preConsume?.lookup === "present" &&
|
|
1689
|
+
preConsume.expiryState === "expired"
|
|
1690
|
+
? "expired-row"
|
|
1691
|
+
: preConsume?.lookup === "absent"
|
|
1692
|
+
? "row-absent-before-consume"
|
|
1693
|
+
: "unresolved"
|
|
1694
|
+
: undefined,
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1541
1697
|
function desktopMagicLinkVerificationUrl(event, values) {
|
|
1542
1698
|
const value = (key) => typeof values[key] === "string" ? values[key] : "";
|
|
1543
1699
|
const token = value("token").trim();
|
|
@@ -3092,19 +3248,47 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
3092
3248
|
if (getMethod(event) === "POST") {
|
|
3093
3249
|
const body = await readBody(event);
|
|
3094
3250
|
const verificationURL = desktopMagicLinkVerificationUrl(event, body);
|
|
3251
|
+
const requestDetails = magicLinkRequestDetails(event, body, verificationURL);
|
|
3095
3252
|
if (!verificationURL) {
|
|
3253
|
+
logMagicLinkDebug(event, "verify-rejected-before-better-auth", {
|
|
3254
|
+
source: "desktop-landing",
|
|
3255
|
+
...requestDetails,
|
|
3256
|
+
reason: "invalid-desktop-verification-url",
|
|
3257
|
+
});
|
|
3096
3258
|
setResponseStatus(event, 400);
|
|
3097
3259
|
return { error: "Invalid desktop magic-link" };
|
|
3098
3260
|
}
|
|
3261
|
+
const token = typeof body.token === "string" ? body.token.trim() : "";
|
|
3262
|
+
const preConsume = await inspectMagicLinkVerification(auth, token);
|
|
3263
|
+
logMagicLinkDebug(event, "verify-request", {
|
|
3264
|
+
source: "desktop-landing",
|
|
3265
|
+
...requestDetails,
|
|
3266
|
+
preConsume,
|
|
3267
|
+
});
|
|
3099
3268
|
// Verify inside the same request that received the explicit user
|
|
3100
3269
|
// confirmation. A browser redirect would create a second network
|
|
3101
3270
|
// hop where link scanners, redirect handling, or a fresh serverless
|
|
3102
3271
|
// request could consume or lose the one-time token before the
|
|
3103
3272
|
// desktop callback sees the Better Auth session cookie.
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3273
|
+
try {
|
|
3274
|
+
const response = await auth.handler(new Request(verificationURL, {
|
|
3275
|
+
method: "GET",
|
|
3276
|
+
headers: event.headers,
|
|
3277
|
+
}));
|
|
3278
|
+
if (response instanceof Response) {
|
|
3279
|
+
logMagicLinkVerificationResponse(event, "desktop-landing", response, preConsume);
|
|
3280
|
+
}
|
|
3281
|
+
return response;
|
|
3282
|
+
}
|
|
3283
|
+
catch (error) {
|
|
3284
|
+
logMagicLinkDebug(event, "verify-exception", {
|
|
3285
|
+
source: "desktop-landing",
|
|
3286
|
+
...requestDetails,
|
|
3287
|
+
preConsume,
|
|
3288
|
+
errorType: error instanceof Error ? error.constructor.name : "unknown",
|
|
3289
|
+
});
|
|
3290
|
+
throw error;
|
|
3291
|
+
}
|
|
3108
3292
|
}
|
|
3109
3293
|
if (!isReadMethod(event)) {
|
|
3110
3294
|
setResponseStatus(event, 405);
|
|
@@ -3157,6 +3341,17 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
3157
3341
|
message: AUTH_MAGIC_LINK_FALLBACK,
|
|
3158
3342
|
code: code || "callback_error",
|
|
3159
3343
|
});
|
|
3344
|
+
logMagicLinkDebug(event, "callback-error", {
|
|
3345
|
+
source: "desktop-callback",
|
|
3346
|
+
flow: oauthDebugFlowId(flowId),
|
|
3347
|
+
callbackError: code || "callback_error",
|
|
3348
|
+
producer: code === "INVALID_TOKEN"
|
|
3349
|
+
? "better-auth.magic-link.verify"
|
|
3350
|
+
: "desktop-callback",
|
|
3351
|
+
reason: code === "INVALID_TOKEN"
|
|
3352
|
+
? "upstream-verifier-reported-invalid-token"
|
|
3353
|
+
: "callback-carried-error",
|
|
3354
|
+
});
|
|
3160
3355
|
logGoogleOAuthDebug(event, "magic-link-callback-error", {
|
|
3161
3356
|
flowId,
|
|
3162
3357
|
message: callbackError,
|
|
@@ -3224,11 +3419,27 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
3224
3419
|
const isSendVerificationEmail = reqPath.includes("send-verification-email") &&
|
|
3225
3420
|
getMethod(event) === "POST";
|
|
3226
3421
|
const isMagicLinkRequest = reqPath.includes("/sign-in/magic-link") && getMethod(event) === "POST";
|
|
3422
|
+
const isMagicLinkVerification = reqPath.includes("/magic-link/verify") && getMethod(event) === "GET";
|
|
3227
3423
|
const isSignOut = reqPath.includes("sign-out") && getMethod(event) === "POST";
|
|
3228
3424
|
if (isSignOut)
|
|
3229
3425
|
optOutOfAuthDisabledSession(event);
|
|
3230
3426
|
const authRequest = toWebRequest(event);
|
|
3231
3427
|
let requestForAuth = authRequest;
|
|
3428
|
+
let magicLinkPreConsume;
|
|
3429
|
+
if (isMagicLinkVerification) {
|
|
3430
|
+
const verificationURL = new URL(authRequest.url);
|
|
3431
|
+
const values = Object.fromEntries(verificationURL.searchParams.entries());
|
|
3432
|
+
const requestDetails = magicLinkRequestDetails(event, values, verificationURL);
|
|
3433
|
+
const token = typeof values.token === "string" ? values.token.trim() : "";
|
|
3434
|
+
magicLinkPreConsume = token
|
|
3435
|
+
? await inspectMagicLinkVerification(auth, token)
|
|
3436
|
+
: undefined;
|
|
3437
|
+
logMagicLinkDebug(event, "verify-request", {
|
|
3438
|
+
source: "better-auth-catch-all",
|
|
3439
|
+
...requestDetails,
|
|
3440
|
+
preConsume: magicLinkPreConsume,
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3232
3443
|
// Better Auth is also reachable directly, outside the legacy login
|
|
3233
3444
|
// wrapper. Check its password endpoints before handing the request to
|
|
3234
3445
|
// Better Auth so an org policy cannot be bypassed through the raw API.
|
|
@@ -3330,10 +3541,26 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
3330
3541
|
// validation error.
|
|
3331
3542
|
}
|
|
3332
3543
|
}
|
|
3333
|
-
let response
|
|
3544
|
+
let response;
|
|
3545
|
+
try {
|
|
3546
|
+
response = await auth.handler(requestForAuth);
|
|
3547
|
+
}
|
|
3548
|
+
catch (error) {
|
|
3549
|
+
if (isMagicLinkVerification) {
|
|
3550
|
+
logMagicLinkDebug(event, "verify-exception", {
|
|
3551
|
+
source: "better-auth-catch-all",
|
|
3552
|
+
errorType: error instanceof Error ? error.constructor.name : "unknown",
|
|
3553
|
+
preConsume: magicLinkPreConsume,
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3556
|
+
throw error;
|
|
3557
|
+
}
|
|
3334
3558
|
const isResponse = response != null &&
|
|
3335
3559
|
typeof response.status === "number" &&
|
|
3336
3560
|
typeof response.headers?.get === "function";
|
|
3561
|
+
if (isMagicLinkVerification && isResponse) {
|
|
3562
|
+
logMagicLinkVerificationResponse(event, "better-auth-catch-all", response, magicLinkPreConsume);
|
|
3563
|
+
}
|
|
3337
3564
|
if (isResponse && response.status >= 400) {
|
|
3338
3565
|
// The direct Better Auth surface is also reachable from the browser,
|
|
3339
3566
|
// so wrapper-route sanitization alone is not enough to keep adapter
|
|
@@ -1158,7 +1158,35 @@ async function createBetterAuthInstance(config) {
|
|
|
1158
1158
|
storeToken: "hashed",
|
|
1159
1159
|
rateLimit: { window: 60, max: 5 },
|
|
1160
1160
|
disableSignUp,
|
|
1161
|
-
sendMagicLink: async ({ email, url }) => {
|
|
1161
|
+
sendMagicLink: async ({ email, url, token }) => {
|
|
1162
|
+
let urlPath;
|
|
1163
|
+
let urlQueryKeys;
|
|
1164
|
+
try {
|
|
1165
|
+
const parsedURL = new URL(url);
|
|
1166
|
+
urlPath = parsedURL.pathname;
|
|
1167
|
+
urlQueryKeys = [...parsedURL.searchParams.keys()].sort();
|
|
1168
|
+
}
|
|
1169
|
+
catch {
|
|
1170
|
+
// coercion-ok: diagnostics must never make email delivery fail.
|
|
1171
|
+
// Better Auth owns URL construction; keep diagnostics non-fatal.
|
|
1172
|
+
}
|
|
1173
|
+
if (typeof token === "string") {
|
|
1174
|
+
console.info("[agent-native][magic-link]", {
|
|
1175
|
+
phase: "issued",
|
|
1176
|
+
tokenDigest: crypto
|
|
1177
|
+
.createHash("sha256")
|
|
1178
|
+
.update(token)
|
|
1179
|
+
.digest("hex")
|
|
1180
|
+
.slice(0, 16),
|
|
1181
|
+
expectedStoredIdentifierPrefix: crypto
|
|
1182
|
+
.createHash("sha256")
|
|
1183
|
+
.update(token)
|
|
1184
|
+
.digest("base64url")
|
|
1185
|
+
.slice(0, 16),
|
|
1186
|
+
urlPath,
|
|
1187
|
+
urlQueryKeys,
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1162
1190
|
const appBasePath = (process.env.VITE_APP_BASE_PATH ||
|
|
1163
1191
|
process.env.APP_BASE_PATH ||
|
|
1164
1192
|
"").replace(/\/$/, "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.158.
|
|
3
|
+
"version": "0.158.7",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|