@mastra/auth-cloud 1.2.7-alpha.0 → 1.2.8-alpha.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/dist/_types/@internal_auth/dist/_types/@internal_core/dist/base/index.d.ts +2 -5
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/{index-Biaf3BmX.d.ts → index-TNVgGNjs.d.ts} +1 -5
- package/dist/_types/@internal_auth/dist/session/index.d.ts +9 -0
- package/dist/index.cjs +20 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -37
- package/dist/index.js.map +1 -1
- package/package.json +12 -13
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as IMastraLogger, u as RegisteredLogger } from "../index-
|
|
2
|
-
|
|
3
|
-
declare class MastraBase {
|
|
1
|
+
import { i as IMastraLogger, u as RegisteredLogger } from "../index-TNVgGNjs.js";
|
|
2
|
+
export declare class MastraBase {
|
|
4
3
|
#private;
|
|
5
4
|
component: RegisteredLogger;
|
|
6
5
|
protected logger: IMastraLogger;
|
|
@@ -26,6 +25,4 @@ declare class MastraBase {
|
|
|
26
25
|
*/
|
|
27
26
|
__setLogger(logger: IMastraLogger): void;
|
|
28
27
|
}
|
|
29
|
-
//#endregion
|
|
30
|
-
export { MastraBase };
|
|
31
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Transform } from "stream";
|
|
2
|
-
//#region src/logger/adapter.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* OpenTelemetry-compatible trace correlation fields, injected at the top
|
|
5
4
|
* level of a logger's native record.
|
|
@@ -91,8 +90,6 @@ declare function exportTrackedException(ctx: LoggerAdapterContext | undefined, e
|
|
|
91
90
|
* so the derived record preserves all context from the native call.
|
|
92
91
|
*/
|
|
93
92
|
declare function buildLogRecordData(args: unknown[]): Record<string, unknown> | undefined;
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/logger/index.d.ts
|
|
96
93
|
declare const RegisteredLogger: {
|
|
97
94
|
readonly AGENT: 'AGENT';
|
|
98
95
|
readonly OBSERVABILITY: 'OBSERVABILITY';
|
|
@@ -314,6 +311,5 @@ declare class ConsoleLogger extends MastraLogger {
|
|
|
314
311
|
hasMore: boolean;
|
|
315
312
|
}>;
|
|
316
313
|
}
|
|
317
|
-
//#endregion
|
|
318
314
|
export { buildLogRecordData as _, LogFilter as a, LoggerTransport as c, createCustomTransport as d, AdaptableLogger as f, TraceFields as g, LoggerAdapterOptions as h, IMastraLogger as i, MastraLogger as l, LoggerAdapterContext as m, ConsoleLogger as n, LogFilterContext as o, AdapterLogSink as p, ConsoleLoggerOptions as r, LogLevel as s, BaseLogMessage as t, RegisteredLogger as u, exportTrackedException as v, isAdaptableLogger as y };
|
|
319
|
-
//# sourceMappingURL=index-
|
|
315
|
+
//# sourceMappingURL=index-TNVgGNjs.d.ts.map
|
|
@@ -24,6 +24,15 @@ export interface ISessionProvider<TSession extends Session = Session> {
|
|
|
24
24
|
getSessionIdFromRequest(request: Request): string | null;
|
|
25
25
|
getSessionHeaders(session: TSession): Record<string, string>;
|
|
26
26
|
getClearSessionHeaders(): Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Optional: `Set-Cookie` values expiring legacy copies of the session cookie
|
|
29
|
+
* (for example one an earlier release scoped to a shared parent `Domain`).
|
|
30
|
+
* A browser only deletes a cookie whose exact `(name, Domain, Path)` match,
|
|
31
|
+
* so servers append these to every response that sets or clears the session
|
|
32
|
+
* cookie; otherwise a stale shared-domain copy keeps being sent to every
|
|
33
|
+
* sibling host until it expires.
|
|
34
|
+
*/
|
|
35
|
+
getLegacySessionClearCookies?(): string[];
|
|
27
36
|
}
|
|
28
37
|
export { MemorySessionProvider, type MemorySessionProviderOptions } from './memory.js';
|
|
29
38
|
export { CookieSessionProvider, type CookieSessionProviderOptions } from './cookie.js';
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let crypto$1 = require("crypto");
|
|
3
|
-
|
|
3
|
+
// src/error.ts
|
|
4
4
|
/**
|
|
5
5
|
* Error class for authentication-related failures.
|
|
6
6
|
* Uses a code discriminator for programmatic error handling.
|
|
@@ -75,8 +75,7 @@ var AuthError = class AuthError extends Error {
|
|
|
75
75
|
return new AuthError("cloud_api_error", message, options);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
|
|
79
|
-
//#region src/oauth/state.ts
|
|
78
|
+
// src/oauth/state.ts
|
|
80
79
|
/**
|
|
81
80
|
* OAuth state parameter encoding/decoding.
|
|
82
81
|
*
|
|
@@ -138,8 +137,7 @@ function validateReturnTo(returnTo, requestOrigin) {
|
|
|
138
137
|
} catch {}
|
|
139
138
|
return "/";
|
|
140
139
|
}
|
|
141
|
-
|
|
142
|
-
//#region src/oauth/network.ts
|
|
140
|
+
// src/oauth/network.ts
|
|
143
141
|
/**
|
|
144
142
|
* Network utilities for OAuth flow.
|
|
145
143
|
*
|
|
@@ -169,8 +167,7 @@ async function fetchWithRetry(url, options) {
|
|
|
169
167
|
}
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
|
-
|
|
173
|
-
//#region src/pkce/error.ts
|
|
170
|
+
// src/pkce/error.ts
|
|
174
171
|
/**
|
|
175
172
|
* Error class for PKCE-related failures.
|
|
176
173
|
* Uses a code discriminator for programmatic error handling.
|
|
@@ -204,8 +201,7 @@ var PKCEError = class PKCEError extends Error {
|
|
|
204
201
|
return new PKCEError("INVALID", "PKCE verifier cookie is malformed or invalid.", cause);
|
|
205
202
|
}
|
|
206
203
|
};
|
|
207
|
-
|
|
208
|
-
//#region src/pkce/cookie.ts
|
|
204
|
+
// src/pkce/cookie.ts
|
|
209
205
|
/**
|
|
210
206
|
* PKCE cookie storage utilities.
|
|
211
207
|
* Handles serialization, parsing, and clearing of PKCE verifier cookies.
|
|
@@ -264,8 +260,7 @@ function parsePKCECookie(cookieHeader) {
|
|
|
264
260
|
function clearPKCECookie() {
|
|
265
261
|
return `${PKCE_COOKIE_NAME}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
|
|
266
262
|
}
|
|
267
|
-
|
|
268
|
-
//#region src/pkce/pkce.ts
|
|
263
|
+
// src/pkce/pkce.ts
|
|
269
264
|
/**
|
|
270
265
|
* PKCE (Proof Key for Code Exchange) cryptographic utilities.
|
|
271
266
|
* Implements RFC 7636 S256 challenge method.
|
|
@@ -297,8 +292,7 @@ function computeCodeChallenge(verifier) {
|
|
|
297
292
|
function generateState() {
|
|
298
293
|
return Buffer.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16))).toString("base64url");
|
|
299
294
|
}
|
|
300
|
-
|
|
301
|
-
//#region src/oauth/oauth.ts
|
|
295
|
+
// src/oauth/oauth.ts
|
|
302
296
|
/**
|
|
303
297
|
* OAuth authorization flow functions.
|
|
304
298
|
*
|
|
@@ -401,8 +395,7 @@ async function handleCallback(options) {
|
|
|
401
395
|
cookies: [clearCookie]
|
|
402
396
|
};
|
|
403
397
|
}
|
|
404
|
-
|
|
405
|
-
//#region src/session/cookie.ts
|
|
398
|
+
// src/session/cookie.ts
|
|
406
399
|
/**
|
|
407
400
|
* Session cookie utilities.
|
|
408
401
|
* Handles setting, parsing, and clearing of session cookies.
|
|
@@ -421,7 +414,7 @@ const SESSION_COOKIE_NAME = "mastra_cloud_session";
|
|
|
421
414
|
* @returns Set-Cookie header value
|
|
422
415
|
*/
|
|
423
416
|
function setSessionCookie(token, isProduction) {
|
|
424
|
-
let cookie = `${SESSION_COOKIE_NAME}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age
|
|
417
|
+
let cookie = `${SESSION_COOKIE_NAME}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=86400`;
|
|
425
418
|
if (isProduction) cookie += "; Secure";
|
|
426
419
|
return cookie;
|
|
427
420
|
}
|
|
@@ -443,8 +436,7 @@ function parseSessionCookie(cookieHeader) {
|
|
|
443
436
|
function clearSessionCookie() {
|
|
444
437
|
return `${SESSION_COOKIE_NAME}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
|
|
445
438
|
}
|
|
446
|
-
|
|
447
|
-
//#region src/session/session.ts
|
|
439
|
+
// src/session/session.ts
|
|
448
440
|
/**
|
|
449
441
|
* Session lifecycle functions.
|
|
450
442
|
* Handles token verification, session validation, and logout.
|
|
@@ -539,8 +531,7 @@ function getLogoutUrl(cloudBaseUrl, postLogoutRedirectUri, idTokenHint) {
|
|
|
539
531
|
url.searchParams.set("id_token_hint", idTokenHint);
|
|
540
532
|
return url.toString();
|
|
541
533
|
}
|
|
542
|
-
|
|
543
|
-
//#region src/client.ts
|
|
534
|
+
// src/client.ts
|
|
544
535
|
/**
|
|
545
536
|
* MastraCloudAuth client class.
|
|
546
537
|
* Facade composing OAuth and session modules into unified API.
|
|
@@ -671,8 +662,7 @@ var MastraCloudAuth = class {
|
|
|
671
662
|
return clearSessionCookie();
|
|
672
663
|
}
|
|
673
664
|
};
|
|
674
|
-
|
|
675
|
-
//#region ../../packages/_internals/auth/dist/types/index.js
|
|
665
|
+
// ../../packages/_internals/auth/dist/types/index.js
|
|
676
666
|
function headerFromPlainObject(headers, name) {
|
|
677
667
|
const normalizedName = name.toLowerCase();
|
|
678
668
|
const matchingKey = Object.keys(headers).find((key) => key.toLowerCase() === normalizedName);
|
|
@@ -692,8 +682,7 @@ function getRequestHeader(request, name) {
|
|
|
692
682
|
if (headers && typeof headers === "object") return headerFromPlainObject(headers, name);
|
|
693
683
|
return null;
|
|
694
684
|
}
|
|
695
|
-
|
|
696
|
-
//#region ../../packages/_internal-core/dist/logger/index.js
|
|
685
|
+
// ../../packages/_internal-core/dist/logger/index.js
|
|
697
686
|
/**
|
|
698
687
|
* Export a tracked exception through the adapter sink, mirroring the
|
|
699
688
|
* DualLogger dual-write shape (`errorId`/`domain`/`category`/`details`/`cause`
|
|
@@ -926,8 +915,7 @@ var ConsoleLogger = class ConsoleLogger extends MastraLogger {
|
|
|
926
915
|
};
|
|
927
916
|
}
|
|
928
917
|
};
|
|
929
|
-
|
|
930
|
-
//#region ../../packages/_internal-core/dist/base/index.js
|
|
918
|
+
// ../../packages/_internal-core/dist/base/index.js
|
|
931
919
|
var MastraBase = class {
|
|
932
920
|
component = RegisteredLogger.LLM;
|
|
933
921
|
logger;
|
|
@@ -961,8 +949,7 @@ var MastraBase = class {
|
|
|
961
949
|
this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
|
|
962
950
|
}
|
|
963
951
|
};
|
|
964
|
-
|
|
965
|
-
//#region ../../packages/_internals/auth/dist/provider/index.js
|
|
952
|
+
// ../../packages/_internals/auth/dist/provider/index.js
|
|
966
953
|
var MastraAuthProvider = class extends MastraBase {
|
|
967
954
|
protected;
|
|
968
955
|
public;
|
|
@@ -974,7 +961,7 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
974
961
|
if (options?.authorizeUser) this.authorizeUser = options.authorizeUser.bind(this);
|
|
975
962
|
this.protected = options?.protected;
|
|
976
963
|
this.public = options?.public;
|
|
977
|
-
this.mapUserToResourceId = options
|
|
964
|
+
if (options?.mapUserToResourceId) this.mapUserToResourceId = options.mapUserToResourceId;
|
|
978
965
|
}
|
|
979
966
|
registerOptions(opts) {
|
|
980
967
|
if (opts?.authorizeUser) this.authorizeUser = opts.authorizeUser.bind(this);
|
|
@@ -983,8 +970,7 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
983
970
|
if (opts?.public) this.public = opts.public;
|
|
984
971
|
}
|
|
985
972
|
};
|
|
986
|
-
|
|
987
|
-
//#region ../../packages/_internals/auth/dist/ee-btY6vXIW.js
|
|
973
|
+
// ../../packages/_internals/auth/dist/ee-CnZdF0Vm.js
|
|
988
974
|
/**
|
|
989
975
|
* FGA enforcement utility for checking fine-grained authorization.
|
|
990
976
|
*
|
|
@@ -1093,8 +1079,7 @@ function resolvePermissionsFromMapping(roles, mapping) {
|
|
|
1093
1079
|
* @license Mastra Enterprise License - see ee/LICENSE
|
|
1094
1080
|
* @packageDocumentation
|
|
1095
1081
|
*/
|
|
1096
|
-
|
|
1097
|
-
//#region src/auth-provider.ts
|
|
1082
|
+
// src/auth-provider.ts
|
|
1098
1083
|
/**
|
|
1099
1084
|
* Mastra Cloud authentication provider for server integration.
|
|
1100
1085
|
*
|
|
@@ -1297,7 +1282,7 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
|
|
|
1297
1282
|
*/
|
|
1298
1283
|
async createSession(userId, metadata) {
|
|
1299
1284
|
const now = /* @__PURE__ */ new Date();
|
|
1300
|
-
const expiresAt = new Date(now.getTime() +
|
|
1285
|
+
const expiresAt = new Date(now.getTime() + 864e5);
|
|
1301
1286
|
return {
|
|
1302
1287
|
id: metadata?.accessToken ?? crypto.randomUUID(),
|
|
1303
1288
|
userId,
|
|
@@ -1395,8 +1380,7 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
|
|
|
1395
1380
|
return null;
|
|
1396
1381
|
}
|
|
1397
1382
|
};
|
|
1398
|
-
|
|
1399
|
-
//#region src/rbac/rbac-provider.ts
|
|
1383
|
+
// src/rbac/rbac-provider.ts
|
|
1400
1384
|
/**
|
|
1401
1385
|
* RBAC provider for Mastra Cloud authentication.
|
|
1402
1386
|
*
|
|
@@ -1513,7 +1497,6 @@ var MastraRBACCloud = class {
|
|
|
1513
1497
|
return permissions.some((required) => userPermissions.some((p) => matchesPermission(p, required)));
|
|
1514
1498
|
}
|
|
1515
1499
|
};
|
|
1516
|
-
//#endregion
|
|
1517
1500
|
exports.AuthError = AuthError;
|
|
1518
1501
|
exports.MastraCloudAuth = MastraCloudAuth;
|
|
1519
1502
|
exports.MastraCloudAuthProvider = MastraCloudAuthProvider;
|