@mastra/auth 0.1.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.
@@ -0,0 +1,7 @@
1
+ import * as child_process from 'child_process';
2
+ import * as util from 'util';
3
+
4
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.js
5
+ var execAsync = util.promisify(child_process.exec);
6
+
7
+ export { execAsync };
@@ -0,0 +1,21 @@
1
+ import { execAsync } from './chunk-N62AETLJ.js';
2
+ import { diag } from './chunk-JLXWUSDO.js';
3
+ import { promises } from 'fs';
4
+
5
+ async function getMachineId() {
6
+ try {
7
+ const result = await promises.readFile("/etc/hostid", { encoding: "utf8" });
8
+ return result.trim();
9
+ } catch (e) {
10
+ diag.debug(`error reading machine id: ${e}`);
11
+ }
12
+ try {
13
+ const result = await execAsync("kenv -q smbios.system.uuid");
14
+ return result.stdout.trim();
15
+ } catch (e) {
16
+ diag.debug(`error reading machine id: ${e}`);
17
+ }
18
+ return void 0;
19
+ }
20
+
21
+ export { getMachineId };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var chunk6FSLIWKJ_cjs = require('./chunk-6FSLIWKJ.cjs');
4
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
5
+ var fs = require('fs');
6
+
7
+ async function getMachineId() {
8
+ try {
9
+ const result = await fs.promises.readFile("/etc/hostid", { encoding: "utf8" });
10
+ return result.trim();
11
+ } catch (e) {
12
+ chunkF3KPPQ4I_cjs.diag.debug(`error reading machine id: ${e}`);
13
+ }
14
+ try {
15
+ const result = await chunk6FSLIWKJ_cjs.execAsync("kenv -q smbios.system.uuid");
16
+ return result.stdout.trim();
17
+ } catch (e) {
18
+ chunkF3KPPQ4I_cjs.diag.debug(`error reading machine id: ${e}`);
19
+ }
20
+ return void 0;
21
+ }
22
+
23
+ exports.getMachineId = getMachineId;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var chunk6FSLIWKJ_cjs = require('./chunk-6FSLIWKJ.cjs');
4
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
5
+
6
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-darwin.js
7
+ async function getMachineId() {
8
+ try {
9
+ const result = await chunk6FSLIWKJ_cjs.execAsync('ioreg -rd1 -c "IOPlatformExpertDevice"');
10
+ const idLine = result.stdout.split("\n").find((line) => line.includes("IOPlatformUUID"));
11
+ if (!idLine) {
12
+ return void 0;
13
+ }
14
+ const parts = idLine.split('" = "');
15
+ if (parts.length === 2) {
16
+ return parts[1].slice(0, -1);
17
+ }
18
+ } catch (e) {
19
+ chunkF3KPPQ4I_cjs.diag.debug(`error reading machine id: ${e}`);
20
+ }
21
+ return void 0;
22
+ }
23
+
24
+ exports.getMachineId = getMachineId;
@@ -0,0 +1,22 @@
1
+ import { execAsync } from './chunk-N62AETLJ.js';
2
+ import { diag } from './chunk-JLXWUSDO.js';
3
+
4
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-darwin.js
5
+ async function getMachineId() {
6
+ try {
7
+ const result = await execAsync('ioreg -rd1 -c "IOPlatformExpertDevice"');
8
+ const idLine = result.stdout.split("\n").find((line) => line.includes("IOPlatformUUID"));
9
+ if (!idLine) {
10
+ return void 0;
11
+ }
12
+ const parts = idLine.split('" = "');
13
+ if (parts.length === 2) {
14
+ return parts[1].slice(0, -1);
15
+ }
16
+ } catch (e) {
17
+ diag.debug(`error reading machine id: ${e}`);
18
+ }
19
+ return void 0;
20
+ }
21
+
22
+ export { getMachineId };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
4
+ var fs = require('fs');
5
+
6
+ async function getMachineId() {
7
+ const paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
8
+ for (const path of paths) {
9
+ try {
10
+ const result = await fs.promises.readFile(path, { encoding: "utf8" });
11
+ return result.trim();
12
+ } catch (e) {
13
+ chunkF3KPPQ4I_cjs.diag.debug(`error reading machine id: ${e}`);
14
+ }
15
+ }
16
+ return void 0;
17
+ }
18
+
19
+ exports.getMachineId = getMachineId;
@@ -0,0 +1,17 @@
1
+ import { diag } from './chunk-JLXWUSDO.js';
2
+ import { promises } from 'fs';
3
+
4
+ async function getMachineId() {
5
+ const paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
6
+ for (const path of paths) {
7
+ try {
8
+ const result = await promises.readFile(path, { encoding: "utf8" });
9
+ return result.trim();
10
+ } catch (e) {
11
+ diag.debug(`error reading machine id: ${e}`);
12
+ }
13
+ }
14
+ return void 0;
15
+ }
16
+
17
+ export { getMachineId };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
4
+
5
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-unsupported.js
6
+ async function getMachineId() {
7
+ chunkF3KPPQ4I_cjs.diag.debug("could not read machine-id: unsupported platform");
8
+ return void 0;
9
+ }
10
+
11
+ exports.getMachineId = getMachineId;
@@ -0,0 +1,9 @@
1
+ import { diag } from './chunk-JLXWUSDO.js';
2
+
3
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-unsupported.js
4
+ async function getMachineId() {
5
+ diag.debug("could not read machine-id: unsupported platform");
6
+ return void 0;
7
+ }
8
+
9
+ export { getMachineId };
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var chunk6FSLIWKJ_cjs = require('./chunk-6FSLIWKJ.cjs');
4
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
5
+ var process = require('process');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var process__namespace = /*#__PURE__*/_interopNamespace(process);
26
+
27
+ async function getMachineId() {
28
+ const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
29
+ let command = "%windir%\\System32\\REG.exe";
30
+ if (process__namespace.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process__namespace.env) {
31
+ command = "%windir%\\sysnative\\cmd.exe /c " + command;
32
+ }
33
+ try {
34
+ const result = await chunk6FSLIWKJ_cjs.execAsync(`${command} ${args}`);
35
+ const parts = result.stdout.split("REG_SZ");
36
+ if (parts.length === 2) {
37
+ return parts[1].trim();
38
+ }
39
+ } catch (e) {
40
+ chunkF3KPPQ4I_cjs.diag.debug(`error reading machine id: ${e}`);
41
+ }
42
+ return void 0;
43
+ }
44
+
45
+ exports.getMachineId = getMachineId;
@@ -0,0 +1,23 @@
1
+ import { execAsync } from './chunk-N62AETLJ.js';
2
+ import { diag } from './chunk-JLXWUSDO.js';
3
+ import * as process from 'process';
4
+
5
+ async function getMachineId() {
6
+ const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
7
+ let command = "%windir%\\System32\\REG.exe";
8
+ if (process.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process.env) {
9
+ command = "%windir%\\sysnative\\cmd.exe /c " + command;
10
+ }
11
+ try {
12
+ const result = await execAsync(`${command} ${args}`);
13
+ const parts = result.stdout.split("REG_SZ");
14
+ if (parts.length === 2) {
15
+ return parts[1].trim();
16
+ }
17
+ } catch (e) {
18
+ diag.debug(`error reading machine id: ${e}`);
19
+ }
20
+ return void 0;
21
+ }
22
+
23
+ export { getMachineId };
package/dist/index.cjs ADDED
@@ -0,0 +1,380 @@
1
+ 'use strict';
2
+
3
+ var chunkF3KPPQ4I_cjs = require('./chunk-F3KPPQ4I.cjs');
4
+ var jwt = require('jsonwebtoken');
5
+ var jwksClient = require('jwks-rsa');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var jwt__default = /*#__PURE__*/_interopDefault(jwt);
10
+ var jwksClient__default = /*#__PURE__*/_interopDefault(jwksClient);
11
+
12
+ async function decodeToken(accessToken) {
13
+ const decoded = jwt__default.default.decode(accessToken, { complete: true });
14
+ return decoded;
15
+ }
16
+ function getTokenIssuer(decoded) {
17
+ if (!decoded) throw new Error("Invalid token");
18
+ if (!decoded.payload || typeof decoded.payload !== "object") throw new Error("Invalid token payload");
19
+ if (!decoded.payload.iss) throw new Error("Invalid token header");
20
+ return decoded.payload.iss;
21
+ }
22
+ async function verifyHmac(accessToken, secret) {
23
+ const decoded = jwt__default.default.decode(accessToken, { complete: true });
24
+ if (!decoded) throw new Error("Invalid token");
25
+ return jwt__default.default.verify(accessToken, secret);
26
+ }
27
+ async function verifyJwks(accessToken, jwksUri) {
28
+ const decoded = jwt__default.default.decode(accessToken, { complete: true });
29
+ if (!decoded) throw new Error("Invalid token");
30
+ const client = jwksClient__default.default({ jwksUri });
31
+ const key = await client.getSigningKey(decoded.header.kid);
32
+ const signingKey = key.getPublicKey();
33
+ return jwt__default.default.verify(accessToken, signingKey);
34
+ }
35
+
36
+ // ../core/dist/chunk-EWDGXKOQ.js
37
+ function hasActiveTelemetry(tracerName = "default-tracer") {
38
+ try {
39
+ return !!chunkF3KPPQ4I_cjs.trace.getTracer(tracerName);
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ function getBaggageValues(ctx) {
45
+ const currentBaggage = chunkF3KPPQ4I_cjs.propagation.getBaggage(ctx);
46
+ const requestId = currentBaggage?.getEntry("http.request_id")?.value;
47
+ const componentName = currentBaggage?.getEntry("componentName")?.value;
48
+ const runId = currentBaggage?.getEntry("runId")?.value;
49
+ return {
50
+ requestId,
51
+ componentName,
52
+ runId
53
+ };
54
+ }
55
+ function withSpan(options) {
56
+ return function(_target, propertyKey, descriptor) {
57
+ if (!descriptor || typeof descriptor === "number") return;
58
+ const originalMethod = descriptor.value;
59
+ const methodName = String(propertyKey);
60
+ descriptor.value = function(...args) {
61
+ if (options?.skipIfNoTelemetry && !hasActiveTelemetry(options?.tracerName)) {
62
+ return originalMethod.apply(this, args);
63
+ }
64
+ const tracer = chunkF3KPPQ4I_cjs.trace.getTracer(options?.tracerName ?? "default-tracer");
65
+ let spanName;
66
+ let spanKind;
67
+ if (typeof options === "string") {
68
+ spanName = options;
69
+ } else if (options) {
70
+ spanName = options.spanName || methodName;
71
+ spanKind = options.spanKind;
72
+ } else {
73
+ spanName = methodName;
74
+ }
75
+ const span = tracer.startSpan(spanName, { kind: spanKind });
76
+ let ctx = chunkF3KPPQ4I_cjs.trace.setSpan(chunkF3KPPQ4I_cjs.context.active(), span);
77
+ args.forEach((arg, index) => {
78
+ try {
79
+ span.setAttribute(`${spanName}.argument.${index}`, JSON.stringify(arg));
80
+ } catch {
81
+ span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
82
+ }
83
+ });
84
+ const { requestId, componentName, runId } = getBaggageValues(ctx);
85
+ if (requestId) {
86
+ span.setAttribute("http.request_id", requestId);
87
+ }
88
+ if (componentName) {
89
+ span.setAttribute("componentName", componentName);
90
+ span.setAttribute("runId", runId);
91
+ } else if (this && this.name) {
92
+ span.setAttribute("componentName", this.name);
93
+ span.setAttribute("runId", this.runId);
94
+ ctx = chunkF3KPPQ4I_cjs.propagation.setBaggage(
95
+ ctx,
96
+ chunkF3KPPQ4I_cjs.propagation.createBaggage({
97
+ // @ts-ignore
98
+ componentName: { value: this.name },
99
+ // @ts-ignore
100
+ runId: { value: this.runId },
101
+ // @ts-ignore
102
+ "http.request_id": { value: requestId }
103
+ })
104
+ );
105
+ }
106
+ let result;
107
+ try {
108
+ result = chunkF3KPPQ4I_cjs.context.with(ctx, () => originalMethod.apply(this, args));
109
+ if (result instanceof Promise) {
110
+ return result.then((resolvedValue) => {
111
+ try {
112
+ span.setAttribute(`${spanName}.result`, JSON.stringify(resolvedValue));
113
+ } catch {
114
+ span.setAttribute(`${spanName}.result`, "[Not Serializable]");
115
+ }
116
+ return resolvedValue;
117
+ }).finally(() => span.end());
118
+ }
119
+ try {
120
+ span.setAttribute(`${spanName}.result`, JSON.stringify(result));
121
+ } catch {
122
+ span.setAttribute(`${spanName}.result`, "[Not Serializable]");
123
+ }
124
+ return result;
125
+ } catch (error) {
126
+ span.setStatus({
127
+ code: chunkF3KPPQ4I_cjs.SpanStatusCode.ERROR,
128
+ message: error instanceof Error ? error.message : "Unknown error"
129
+ });
130
+ if (error instanceof Error) {
131
+ span.recordException(error);
132
+ }
133
+ throw error;
134
+ } finally {
135
+ if (!(result instanceof Promise)) {
136
+ span.end();
137
+ }
138
+ }
139
+ };
140
+ return descriptor;
141
+ };
142
+ }
143
+ function InstrumentClass(options) {
144
+ return function(target) {
145
+ const methods = Object.getOwnPropertyNames(target.prototype);
146
+ methods.forEach((method) => {
147
+ if (options?.excludeMethods?.includes(method) || method === "constructor") return;
148
+ if (options?.methodFilter && !options.methodFilter(method)) return;
149
+ const descriptor = Object.getOwnPropertyDescriptor(target.prototype, method);
150
+ if (descriptor && typeof descriptor.value === "function") {
151
+ Object.defineProperty(
152
+ target.prototype,
153
+ method,
154
+ withSpan({
155
+ spanName: options?.prefix ? `${options.prefix}.${method}` : method,
156
+ skipIfNoTelemetry: true,
157
+ spanKind: options?.spanKind || chunkF3KPPQ4I_cjs.SpanKind.INTERNAL,
158
+ tracerName: options?.tracerName
159
+ })(target, method, descriptor)
160
+ );
161
+ }
162
+ });
163
+ return target;
164
+ };
165
+ }
166
+
167
+ // ../core/dist/chunk-XXVGT7SJ.js
168
+ var RegisteredLogger = {
169
+ LLM: "LLM"};
170
+ var LogLevel = {
171
+ DEBUG: "debug",
172
+ INFO: "info",
173
+ WARN: "warn",
174
+ ERROR: "error"};
175
+ var MastraLogger = class {
176
+ name;
177
+ level;
178
+ transports;
179
+ constructor(options = {}) {
180
+ this.name = options.name || "Mastra";
181
+ this.level = options.level || LogLevel.ERROR;
182
+ this.transports = new Map(Object.entries(options.transports || {}));
183
+ }
184
+ getTransports() {
185
+ return this.transports;
186
+ }
187
+ async getLogs(transportId) {
188
+ if (!transportId || !this.transports.has(transportId)) {
189
+ return [];
190
+ }
191
+ return this.transports.get(transportId).getLogs() ?? [];
192
+ }
193
+ async getLogsByRunId({ transportId, runId }) {
194
+ if (!transportId || !this.transports.has(transportId) || !runId) {
195
+ return [];
196
+ }
197
+ return this.transports.get(transportId).getLogsByRunId({ runId }) ?? [];
198
+ }
199
+ };
200
+ var ConsoleLogger = class extends MastraLogger {
201
+ constructor(options = {}) {
202
+ super(options);
203
+ }
204
+ debug(message, ...args) {
205
+ if (this.level === LogLevel.DEBUG) {
206
+ console.debug(message, ...args);
207
+ }
208
+ }
209
+ info(message, ...args) {
210
+ if (this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
211
+ console.info(message, ...args);
212
+ }
213
+ }
214
+ warn(message, ...args) {
215
+ if (this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
216
+ console.warn(message, ...args);
217
+ }
218
+ }
219
+ error(message, ...args) {
220
+ if (this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
221
+ console.error(message, ...args);
222
+ }
223
+ }
224
+ async getLogs(_transportId) {
225
+ return [];
226
+ }
227
+ async getLogsByRunId(_args) {
228
+ return [];
229
+ }
230
+ };
231
+
232
+ // ../core/dist/chunk-JOCKZ2US.js
233
+ var MastraBase = class {
234
+ component = RegisteredLogger.LLM;
235
+ logger;
236
+ name;
237
+ telemetry;
238
+ constructor({ component, name }) {
239
+ this.component = component || RegisteredLogger.LLM;
240
+ this.name = name;
241
+ this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });
242
+ }
243
+ /**
244
+ * Set the logger for the agent
245
+ * @param logger
246
+ */
247
+ __setLogger(logger) {
248
+ this.logger = logger;
249
+ if (this.component !== RegisteredLogger.LLM) {
250
+ this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
251
+ }
252
+ }
253
+ /**
254
+ * Set the telemetry for the
255
+ * @param telemetry
256
+ */
257
+ __setTelemetry(telemetry) {
258
+ this.telemetry = telemetry;
259
+ if (this.component !== RegisteredLogger.LLM) {
260
+ this.logger.debug(`Telemetry updated [component=${this.component}] [name=${this.telemetry.name}]`);
261
+ }
262
+ }
263
+ /**
264
+ * Get the telemetry on the vector
265
+ * @returns telemetry
266
+ */
267
+ __getTelemetry() {
268
+ return this.telemetry;
269
+ }
270
+ /*
271
+ get experimental_telemetry config
272
+ */
273
+ get experimental_telemetry() {
274
+ return this.telemetry ? {
275
+ // tracer: this.telemetry.tracer,
276
+ tracer: this.telemetry.getBaggageTracer(),
277
+ isEnabled: !!this.telemetry.tracer
278
+ } : void 0;
279
+ }
280
+ };
281
+
282
+ // ../core/dist/chunk-C6A6W6XS.js
283
+ var __create = Object.create;
284
+ var __defProp = Object.defineProperty;
285
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
286
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
287
+ var __typeError = (msg) => {
288
+ throw TypeError(msg);
289
+ };
290
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
291
+ enumerable: true,
292
+ configurable: true,
293
+ writable: true,
294
+ value
295
+ }) : obj[key] = value;
296
+ var __name = (target, value) => __defProp(target, "name", {
297
+ value,
298
+ configurable: true
299
+ });
300
+ var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
301
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
302
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
303
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({
304
+ kind: __decoratorStrings[kind],
305
+ name,
306
+ metadata,
307
+ addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null))
308
+ });
309
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
310
+ var __runInitializers = (array, flags, self, value) => {
311
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) fns[i].call(self) ;
312
+ return value;
313
+ };
314
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
315
+ var it, done, ctx, k = flags & 7, p = false;
316
+ var j = 0;
317
+ var extraInitializers = array[j] || (array[j] = []);
318
+ var desc = k && ((target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(target , name));
319
+ __name(target, name);
320
+ for (var i = decorators.length - 1; i >= 0; i--) {
321
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
322
+ it = (0, decorators[i])(target, ctx), done._ = 1;
323
+ __expectFn(it) && (target = it);
324
+ }
325
+ return __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
326
+ };
327
+
328
+ // ../core/dist/server/index.js
329
+ var _MastraAuthProvider_decorators;
330
+ var _init;
331
+ var _a;
332
+ _MastraAuthProvider_decorators = [InstrumentClass({
333
+ prefix: "auth",
334
+ excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
335
+ })];
336
+ var MastraAuthProvider = class extends (_a = MastraBase) {
337
+ constructor(options) {
338
+ super({
339
+ component: "AUTH",
340
+ name: options?.name
341
+ });
342
+ if (options?.authorizeUser) {
343
+ this.authorizeUser = options.authorizeUser.bind(this);
344
+ }
345
+ }
346
+ registerOptions(opts) {
347
+ if (opts?.authorizeUser) {
348
+ this.authorizeUser = opts.authorizeUser.bind(this);
349
+ }
350
+ }
351
+ };
352
+ MastraAuthProvider = /* @__PURE__ */ ((_) => {
353
+ _init = __decoratorStart(_a);
354
+ MastraAuthProvider = __decorateElement(_init, 0, "MastraAuthProvider", _MastraAuthProvider_decorators, MastraAuthProvider);
355
+ __runInitializers(_init, 1, MastraAuthProvider);
356
+ return MastraAuthProvider;
357
+ })();
358
+ var MastraJwtAuth = class extends MastraAuthProvider {
359
+ secret;
360
+ constructor(options) {
361
+ super({ name: options?.name ?? "jwt" });
362
+ this.secret = options?.secret ?? process.env.JWT_AUTH_SECRET ?? "";
363
+ if (!this.secret) {
364
+ throw new Error("JWT auth secret is required");
365
+ }
366
+ this.registerOptions(options);
367
+ }
368
+ async authenticateToken(token) {
369
+ return jwt__default.default.verify(token, this.secret);
370
+ }
371
+ async authorizeUser(user) {
372
+ return !!user;
373
+ }
374
+ };
375
+
376
+ exports.MastraJwtAuth = MastraJwtAuth;
377
+ exports.decodeToken = decodeToken;
378
+ exports.getTokenIssuer = getTokenIssuer;
379
+ exports.verifyHmac = verifyHmac;
380
+ exports.verifyJwks = verifyJwks;
@@ -0,0 +1,6 @@
1
+ export { decodeToken } from './_tsup-dts-rollup.cjs';
2
+ export { getTokenIssuer } from './_tsup-dts-rollup.cjs';
3
+ export { verifyHmac } from './_tsup-dts-rollup.cjs';
4
+ export { verifyJwks } from './_tsup-dts-rollup.cjs';
5
+ export { JwtPayload } from './_tsup-dts-rollup.cjs';
6
+ export { MastraJwtAuth } from './_tsup-dts-rollup.cjs';
@@ -0,0 +1,6 @@
1
+ export { decodeToken } from './_tsup-dts-rollup.js';
2
+ export { getTokenIssuer } from './_tsup-dts-rollup.js';
3
+ export { verifyHmac } from './_tsup-dts-rollup.js';
4
+ export { verifyJwks } from './_tsup-dts-rollup.js';
5
+ export { JwtPayload } from './_tsup-dts-rollup.js';
6
+ export { MastraJwtAuth } from './_tsup-dts-rollup.js';