@mastra/server 1.0.4 → 1.1.0-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/CHANGELOG.md +169 -0
- package/a2a/store.d.ts +1 -0
- package/auth.d.ts +1 -0
- package/dist/{chunk-3REGEJEN.js → chunk-24SISJRB.js} +6 -6
- package/dist/chunk-24SISJRB.js.map +1 -0
- package/dist/{chunk-UK4FZWNW.cjs → chunk-2HAVULC2.cjs} +52 -53
- package/dist/chunk-2HAVULC2.cjs.map +1 -0
- package/dist/{chunk-MPUVSOEU.cjs → chunk-2HOMKKY4.cjs} +21 -15
- package/dist/chunk-2HOMKKY4.cjs.map +1 -0
- package/dist/{chunk-HCVDHEDD.cjs → chunk-37DO73XV.cjs} +217 -167
- package/dist/chunk-37DO73XV.cjs.map +1 -0
- package/dist/chunk-3AZY5AWI.js +689 -0
- package/dist/chunk-3AZY5AWI.js.map +1 -0
- package/dist/{chunk-KKY4MSZO.js → chunk-3OIJLD3O.js} +30 -11
- package/dist/chunk-3OIJLD3O.js.map +1 -0
- package/dist/{chunk-2CLS2PYJ.js → chunk-3QUACCLU.js} +398 -56
- package/dist/chunk-3QUACCLU.js.map +1 -0
- package/dist/{chunk-T4SPG2GP.cjs → chunk-4HFYR562.cjs} +4 -4
- package/dist/chunk-4HFYR562.cjs.map +1 -0
- package/dist/{chunk-2CYGIE3E.js → chunk-4JAEBN6N.js} +212 -86
- package/dist/chunk-4JAEBN6N.js.map +1 -0
- package/dist/{chunk-AVRO3FIN.cjs → chunk-4LVJBXI2.cjs} +97 -4
- package/dist/chunk-4LVJBXI2.cjs.map +1 -0
- package/dist/{chunk-PNZQCQY4.cjs → chunk-6G2RQWKA.cjs} +15 -15
- package/dist/chunk-6G2RQWKA.cjs.map +1 -0
- package/dist/chunk-6KC345IN.cjs +708 -0
- package/dist/chunk-6KC345IN.cjs.map +1 -0
- package/dist/{chunk-4EYONQIW.cjs → chunk-7D3UAMQM.cjs} +4 -4
- package/dist/chunk-7D3UAMQM.cjs.map +1 -0
- package/dist/{chunk-I27H7BEB.js → chunk-7XIMPDJV.js} +9 -6
- package/dist/chunk-7XIMPDJV.js.map +1 -0
- package/dist/{chunk-33CKPQS4.cjs → chunk-A2K5ZL47.cjs} +36 -16
- package/dist/chunk-A2K5ZL47.cjs.map +1 -0
- package/dist/chunk-AAHPYUEC.cjs +211 -0
- package/dist/chunk-AAHPYUEC.cjs.map +1 -0
- package/dist/{chunk-NUO7HPOV.cjs → chunk-AN42MFD5.cjs} +235 -109
- package/dist/chunk-AN42MFD5.cjs.map +1 -0
- package/dist/{chunk-4DJ7EJRB.cjs → chunk-AV3VZ6S3.cjs} +25 -21
- package/dist/chunk-AV3VZ6S3.cjs.map +1 -0
- package/dist/{chunk-GHQZIEPS.js → chunk-C4NZAUUW.js} +104 -54
- package/dist/chunk-C4NZAUUW.js.map +1 -0
- package/dist/{chunk-7S7ALPCY.js → chunk-D5VCL56B.js} +97 -5
- package/dist/chunk-D5VCL56B.js.map +1 -0
- package/dist/chunk-DD7LYNHB.js +596 -0
- package/dist/chunk-DD7LYNHB.js.map +1 -0
- package/dist/{chunk-XB27LCKO.js → chunk-DHDVJ5II.js} +15 -9
- package/dist/chunk-DHDVJ5II.js.map +1 -0
- package/dist/{chunk-GNCALVLC.js → chunk-ED6NQBHF.js} +23 -4
- package/dist/chunk-ED6NQBHF.js.map +1 -0
- package/dist/{chunk-YK63KHHB.cjs → chunk-EKFYZUPC.cjs} +513 -168
- package/dist/chunk-EKFYZUPC.cjs.map +1 -0
- package/dist/{chunk-5VDI75UV.js → chunk-EV5H2JQU.js} +5 -4
- package/dist/chunk-EV5H2JQU.js.map +1 -0
- package/dist/{chunk-4R2Z655M.js → chunk-F2WTCJ5C.js} +145 -67
- package/dist/chunk-F2WTCJ5C.js.map +1 -0
- package/dist/{chunk-H34VRYSF.js → chunk-FCPLBTHB.js} +26 -27
- package/dist/chunk-FCPLBTHB.js.map +1 -0
- package/dist/{chunk-IVGQTL3T.js → chunk-FQX5SQO7.js} +36 -28
- package/dist/chunk-FQX5SQO7.js.map +1 -0
- package/dist/{chunk-FWSKVWS7.cjs → chunk-FRRHYZR6.cjs} +4 -4
- package/dist/chunk-FRRHYZR6.cjs.map +1 -0
- package/dist/{chunk-YN3FWKVQ.js → chunk-GUG6KRAJ.js} +10 -13
- package/dist/chunk-GUG6KRAJ.js.map +1 -0
- package/dist/{chunk-N4EIZSG2.js → chunk-GXUBQJ74.js} +15 -11
- package/dist/chunk-GXUBQJ74.js.map +1 -0
- package/dist/chunk-H66LLFDL.js +1 -1
- package/dist/chunk-H66LLFDL.js.map +1 -1
- package/dist/{chunk-QPFYN6B5.cjs → chunk-HDGF45K7.cjs} +17 -14
- package/dist/chunk-HDGF45K7.cjs.map +1 -0
- package/dist/{chunk-P3H4AZKI.cjs → chunk-HZINLMHL.cjs} +15 -15
- package/dist/chunk-HZINLMHL.cjs.map +1 -0
- package/dist/{chunk-DVSCJECS.js → chunk-IS3HHGL4.js} +6 -6
- package/dist/chunk-IS3HHGL4.js.map +1 -0
- package/dist/{chunk-XCEQ4GQW.cjs → chunk-JLFFAYTC.cjs} +53 -90
- package/dist/chunk-JLFFAYTC.cjs.map +1 -0
- package/dist/{chunk-WJ6DNHLW.cjs → chunk-JRM3DWRM.cjs} +34 -24
- package/dist/chunk-JRM3DWRM.cjs.map +1 -0
- package/dist/{chunk-LF2ZLOFP.js → chunk-K2SXZLA3.cjs} +285 -3
- package/dist/chunk-K2SXZLA3.cjs.map +1 -0
- package/dist/{chunk-XOUK3IYU.js → chunk-K4HSW5ZF.js} +4 -4
- package/dist/chunk-K4HSW5ZF.js.map +1 -0
- package/dist/{chunk-GU4EWMZB.cjs → chunk-LFNP3ACE.js} +244 -4
- package/dist/chunk-LFNP3ACE.js.map +1 -0
- package/dist/chunk-LFTVDHOD.js +200 -0
- package/dist/chunk-LFTVDHOD.js.map +1 -0
- package/dist/{chunk-ZQ2G6QKS.cjs → chunk-MZRJNOYJ.cjs} +175 -97
- package/dist/chunk-MZRJNOYJ.cjs.map +1 -0
- package/dist/{chunk-G2AMUTU4.js → chunk-OS7SAIRA.js} +6 -6
- package/dist/chunk-OS7SAIRA.js.map +1 -0
- package/dist/{chunk-L2E5RUVT.cjs → chunk-PWXUI3OG.cjs} +15 -15
- package/dist/chunk-PWXUI3OG.cjs.map +1 -0
- package/dist/{chunk-CLAEGIP5.cjs → chunk-QOVLJFLX.cjs} +14 -17
- package/dist/chunk-QOVLJFLX.cjs.map +1 -0
- package/dist/chunk-QXDNFBJQ.js +220 -0
- package/dist/chunk-QXDNFBJQ.js.map +1 -0
- package/dist/{chunk-EUBTCHQC.js → chunk-RIX6WEJ2.js} +4 -4
- package/dist/chunk-RIX6WEJ2.js.map +1 -0
- package/dist/{chunk-CGIGPJRU.js → chunk-RW66MHXI.js} +37 -70
- package/dist/chunk-RW66MHXI.js.map +1 -0
- package/dist/chunk-S4SLHUJ7.cjs +253 -0
- package/dist/chunk-S4SLHUJ7.cjs.map +1 -0
- package/dist/{chunk-7XPMKW4Y.cjs → chunk-SONAXR2M.cjs} +12 -9
- package/dist/chunk-SONAXR2M.cjs.map +1 -0
- package/dist/{chunk-FLLJIPD4.cjs → chunk-T5KH32UA.cjs} +6 -5
- package/dist/chunk-T5KH32UA.cjs.map +1 -0
- package/dist/{chunk-3FEYUHHJ.js → chunk-TCWPL26W.js} +10 -7
- package/dist/chunk-TCWPL26W.js.map +1 -0
- package/dist/chunk-TGDBGIDA.cjs +623 -0
- package/dist/chunk-TGDBGIDA.cjs.map +1 -0
- package/dist/chunk-USR6JK77.js +62 -0
- package/dist/chunk-USR6JK77.js.map +1 -0
- package/dist/{chunk-6MP2S6VI.cjs → chunk-VNHOYZ56.cjs} +56 -48
- package/dist/chunk-VNHOYZ56.cjs.map +1 -0
- package/dist/chunk-VX3VN7FN.cjs +1 -1
- package/dist/chunk-VX3VN7FN.cjs.map +1 -1
- package/dist/{chunk-AV3CN5ZR.cjs → chunk-WHC6S3VY.cjs} +36 -17
- package/dist/chunk-WHC6S3VY.cjs.map +1 -0
- package/dist/{chunk-5NFRDYFN.js → chunk-XKLJYRAA.js} +4 -4
- package/dist/chunk-XKLJYRAA.js.map +1 -0
- package/dist/{chunk-TMS4LS2J.js → chunk-XUSAKRLX.js} +26 -16
- package/dist/chunk-XUSAKRLX.js.map +1 -0
- package/dist/chunk-ZKMVCV4G.cjs +71 -0
- package/dist/chunk-ZKMVCV4G.cjs.map +1 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/server/01-custom-adapters.md +10 -10
- package/dist/docs/server/02-reference.md +22 -8
- package/dist/server/auth/helpers.d.ts +8 -1
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +42 -131
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.js +1 -125
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/path-pattern.d.ts +43 -0
- package/dist/server/auth/path-pattern.d.ts.map +1 -0
- package/dist/server/constants.d.ts +51 -0
- package/dist/server/constants.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -9
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-versions.cjs +60 -0
- package/dist/server/handlers/agent-versions.cjs.map +1 -0
- package/dist/server/handlers/agent-versions.d.ts +479 -0
- package/dist/server/handlers/agent-versions.d.ts.map +1 -0
- package/dist/server/handlers/agent-versions.js +3 -0
- package/dist/server/handlers/agent-versions.js.map +1 -0
- package/dist/server/handlers/agents.cjs +40 -28
- package/dist/server/handlers/agents.d.ts +58 -5
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.d.ts.map +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp.cjs +9 -9
- package/dist/server/handlers/mcp.d.ts +22 -0
- package/dist/server/handlers/mcp.d.ts.map +1 -1
- package/dist/server/handlers/mcp.js +1 -1
- package/dist/server/handlers/memory.cjs +25 -25
- package/dist/server/handlers/memory.d.ts +25 -1
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +5 -5
- package/dist/server/handlers/observability.d.ts +1 -0
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/processors.cjs +4 -4
- package/dist/server/handlers/processors.d.ts.map +1 -1
- package/dist/server/handlers/processors.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +6 -6
- package/dist/server/handlers/stored-agents.d.ts +33 -5
- package/dist/server/handlers/stored-agents.d.ts.map +1 -1
- package/dist/server/handlers/stored-agents.js +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.d.ts +3 -3
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +21 -5
- package/dist/server/handlers/utils.d.ts +26 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +13 -13
- package/dist/server/handlers/vector.d.ts.map +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -8
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +24 -24
- package/dist/server/handlers/workflows.d.ts +2 -0
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +80 -0
- package/dist/server/handlers/workspace.cjs.map +1 -0
- package/dist/server/handlers/workspace.d.ts +591 -0
- package/dist/server/handlers/workspace.d.ts.map +1 -0
- package/dist/server/handlers/workspace.js +3 -0
- package/dist/server/handlers/workspace.js.map +1 -0
- package/dist/server/handlers.cjs +24 -24
- package/dist/server/handlers.js +12 -12
- package/dist/server/schemas/agent-versions.d.ts +1646 -0
- package/dist/server/schemas/agent-versions.d.ts.map +1 -0
- package/dist/server/schemas/agents.d.ts +30 -19
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/memory.d.ts +83 -31
- package/dist/server/schemas/memory.d.ts.map +1 -1
- package/dist/server/schemas/stored-agents.d.ts +66 -8
- package/dist/server/schemas/stored-agents.d.ts.map +1 -1
- package/dist/server/schemas/workspace.d.ts +1107 -0
- package/dist/server/schemas/workspace.d.ts.map +1 -0
- package/dist/server/server-adapter/index.cjs +298 -160
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +56 -2
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +158 -23
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/openapi-utils.d.ts +10 -0
- package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/index.d.ts +3 -1
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/route-builder.d.ts +2 -1
- package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-agents.d.ts +1 -1
- package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workspace.d.ts +8 -0
- package/dist/server/server-adapter/routes/workspace.d.ts.map +1 -0
- package/dist/server/utils.d.ts +13 -0
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/{token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs → token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs} +9 -9
- package/dist/token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs.map +1 -0
- package/dist/{token-6GSAFR2W-VLY2XUPA-NCSASMWN.js → token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js} +6 -6
- package/dist/token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js.map +1 -0
- package/dist/{token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs → token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs} +9 -9
- package/dist/token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs.map +1 -0
- package/dist/{token-6GSAFR2W-KVDFAJ2M-VW443KIA.js → token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js} +6 -6
- package/dist/token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js.map +1 -0
- package/dist/{token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs → token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs} +9 -9
- package/dist/token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs.map +1 -0
- package/dist/{token-6GSAFR2W-K2BTU23I-NW33N3NU.js → token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js} +6 -6
- package/dist/token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js.map +1 -0
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js +8 -0
- package/dist/{token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js.map → token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js.map} +1 -1
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs +10 -0
- package/dist/{token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs.map → token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs.map} +1 -1
- package/dist/token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js +8 -0
- package/dist/{token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js.map → token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js.map} +1 -1
- package/dist/token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs +10 -0
- package/dist/{token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs.map → token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs.map} +1 -1
- package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs +10 -0
- package/dist/{token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs.map → token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs.map} +1 -1
- package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js +8 -0
- package/dist/{token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js.map → token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js.map} +1 -1
- package/handlers/server/handlers.d.ts +1 -0
- package/handlers.d.ts +1 -0
- package/package.json +9 -7
- package/server-adapter.d.ts +1 -0
- package/dist/chunk-2CLS2PYJ.js.map +0 -1
- package/dist/chunk-2CYGIE3E.js.map +0 -1
- package/dist/chunk-33CKPQS4.cjs.map +0 -1
- package/dist/chunk-3FEYUHHJ.js.map +0 -1
- package/dist/chunk-3REGEJEN.js.map +0 -1
- package/dist/chunk-4DJ7EJRB.cjs.map +0 -1
- package/dist/chunk-4EYONQIW.cjs.map +0 -1
- package/dist/chunk-4R2Z655M.js.map +0 -1
- package/dist/chunk-5NFRDYFN.js.map +0 -1
- package/dist/chunk-5VDI75UV.js.map +0 -1
- package/dist/chunk-5W4RPVTK.cjs +0 -49
- package/dist/chunk-5W4RPVTK.cjs.map +0 -1
- package/dist/chunk-6MP2S6VI.cjs.map +0 -1
- package/dist/chunk-7S7ALPCY.js.map +0 -1
- package/dist/chunk-7XPMKW4Y.cjs.map +0 -1
- package/dist/chunk-AV3CN5ZR.cjs.map +0 -1
- package/dist/chunk-AVRO3FIN.cjs.map +0 -1
- package/dist/chunk-BRI4GUZ2.cjs +0 -280
- package/dist/chunk-BRI4GUZ2.cjs.map +0 -1
- package/dist/chunk-CGIGPJRU.js.map +0 -1
- package/dist/chunk-CLAEGIP5.cjs.map +0 -1
- package/dist/chunk-DVSCJECS.js.map +0 -1
- package/dist/chunk-EUBTCHQC.js.map +0 -1
- package/dist/chunk-FLLJIPD4.cjs.map +0 -1
- package/dist/chunk-FWSKVWS7.cjs.map +0 -1
- package/dist/chunk-G2AMUTU4.js.map +0 -1
- package/dist/chunk-GHQZIEPS.js.map +0 -1
- package/dist/chunk-GNCALVLC.js.map +0 -1
- package/dist/chunk-GU4EWMZB.cjs.map +0 -1
- package/dist/chunk-H34VRYSF.js.map +0 -1
- package/dist/chunk-HCVDHEDD.cjs.map +0 -1
- package/dist/chunk-I27H7BEB.js.map +0 -1
- package/dist/chunk-IVGQTL3T.js.map +0 -1
- package/dist/chunk-KKY4MSZO.js.map +0 -1
- package/dist/chunk-L2E5RUVT.cjs.map +0 -1
- package/dist/chunk-LF2ZLOFP.js.map +0 -1
- package/dist/chunk-MPUVSOEU.cjs.map +0 -1
- package/dist/chunk-N4EIZSG2.js.map +0 -1
- package/dist/chunk-NUO7HPOV.cjs.map +0 -1
- package/dist/chunk-P3H4AZKI.cjs.map +0 -1
- package/dist/chunk-PNZQCQY4.cjs.map +0 -1
- package/dist/chunk-QPFYN6B5.cjs.map +0 -1
- package/dist/chunk-T4SPG2GP.cjs.map +0 -1
- package/dist/chunk-TMS4LS2J.js.map +0 -1
- package/dist/chunk-UK4FZWNW.cjs.map +0 -1
- package/dist/chunk-WJ6DNHLW.cjs.map +0 -1
- package/dist/chunk-WLGJVDH4.js +0 -242
- package/dist/chunk-WLGJVDH4.js.map +0 -1
- package/dist/chunk-XB27LCKO.js.map +0 -1
- package/dist/chunk-XCEQ4GQW.cjs.map +0 -1
- package/dist/chunk-XOUK3IYU.js.map +0 -1
- package/dist/chunk-XWGAT2DA.js +0 -44
- package/dist/chunk-XWGAT2DA.js.map +0 -1
- package/dist/chunk-YK63KHHB.cjs.map +0 -1
- package/dist/chunk-YN3FWKVQ.js.map +0 -1
- package/dist/chunk-ZQ2G6QKS.cjs.map +0 -1
- package/dist/token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs.map +0 -1
- package/dist/token-6GSAFR2W-K2BTU23I-NW33N3NU.js.map +0 -1
- package/dist/token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs.map +0 -1
- package/dist/token-6GSAFR2W-KVDFAJ2M-VW443KIA.js.map +0 -1
- package/dist/token-6GSAFR2W-VLY2XUPA-NCSASMWN.js.map +0 -1
- package/dist/token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs.map +0 -1
- package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs +0 -10
- package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js +0 -8
- package/dist/token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs +0 -10
- package/dist/token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js +0 -8
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs +0 -10
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js +0 -8
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/server/auth/defaults.ts
|
|
4
|
+
var defaultAuthConfig = {
|
|
5
|
+
protected: ["/api/*"],
|
|
6
|
+
public: ["/api"],
|
|
7
|
+
// Simple rule system
|
|
8
|
+
rules: [
|
|
9
|
+
// Admin users can do anything
|
|
10
|
+
{
|
|
11
|
+
condition: (user) => {
|
|
12
|
+
if (typeof user === "object" && user !== null) {
|
|
13
|
+
if ("isAdmin" in user) {
|
|
14
|
+
return !!user.isAdmin;
|
|
15
|
+
}
|
|
16
|
+
if ("role" in user) {
|
|
17
|
+
return user.role === "admin";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
allow: true
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/server/auth/path-pattern.ts
|
|
28
|
+
function parse(input, loose) {
|
|
29
|
+
if (input instanceof RegExp) return { keys: false, pattern: input };
|
|
30
|
+
let c;
|
|
31
|
+
let o;
|
|
32
|
+
let tmp;
|
|
33
|
+
let ext;
|
|
34
|
+
const keys = [];
|
|
35
|
+
let pattern = "";
|
|
36
|
+
const arr = input.split("/");
|
|
37
|
+
arr[0] || arr.shift();
|
|
38
|
+
while (tmp = arr.shift()) {
|
|
39
|
+
c = tmp[0];
|
|
40
|
+
if (c === "*") {
|
|
41
|
+
keys.push(c);
|
|
42
|
+
pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
|
|
43
|
+
} else if (c === ":") {
|
|
44
|
+
o = tmp.indexOf("?", 1);
|
|
45
|
+
ext = tmp.indexOf(".", 1);
|
|
46
|
+
keys.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
|
|
47
|
+
pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
|
|
48
|
+
if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
|
|
49
|
+
} else {
|
|
50
|
+
pattern += "/" + tmp;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
keys,
|
|
55
|
+
pattern: new RegExp("^" + pattern + ("/?$"), "i")
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/server/auth/helpers.ts
|
|
60
|
+
var isProtectedCustomRoute = (path, method, customRouteAuthConfig) => {
|
|
61
|
+
if (!customRouteAuthConfig) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const exactRouteKey = `${method}:${path}`;
|
|
65
|
+
if (customRouteAuthConfig.has(exactRouteKey)) {
|
|
66
|
+
return customRouteAuthConfig.get(exactRouteKey) === true;
|
|
67
|
+
}
|
|
68
|
+
const allRouteKey = `ALL:${path}`;
|
|
69
|
+
if (customRouteAuthConfig.has(allRouteKey)) {
|
|
70
|
+
return customRouteAuthConfig.get(allRouteKey) === true;
|
|
71
|
+
}
|
|
72
|
+
for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {
|
|
73
|
+
const colonIndex = routeKey.indexOf(":");
|
|
74
|
+
if (colonIndex === -1) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const routeMethod = routeKey.substring(0, colonIndex);
|
|
78
|
+
const routePattern = routeKey.substring(colonIndex + 1);
|
|
79
|
+
if (routeMethod !== method && routeMethod !== "ALL") {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (pathMatchesPattern(path, routePattern)) {
|
|
83
|
+
return requiresAuth === true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
var isDevPlaygroundRequest = (path, method, getHeader, authConfig, customRouteAuthConfig) => {
|
|
89
|
+
const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
|
|
90
|
+
return process.env.MASTRA_DEV === "true" && // Allow if path doesn't match protected patterns AND is not a protected custom route
|
|
91
|
+
(!isAnyMatch(path, method, protectedAccess) && !isProtectedCustomRoute(path, method, customRouteAuthConfig) || // Or if has playground header
|
|
92
|
+
getHeader("x-mastra-dev-playground") === "true");
|
|
93
|
+
};
|
|
94
|
+
var isCustomRoutePublic = (path, method, customRouteAuthConfig) => {
|
|
95
|
+
if (!customRouteAuthConfig) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const exactRouteKey = `${method}:${path}`;
|
|
99
|
+
if (customRouteAuthConfig.has(exactRouteKey)) {
|
|
100
|
+
return !customRouteAuthConfig.get(exactRouteKey);
|
|
101
|
+
}
|
|
102
|
+
const allRouteKey = `ALL:${path}`;
|
|
103
|
+
if (customRouteAuthConfig.has(allRouteKey)) {
|
|
104
|
+
return !customRouteAuthConfig.get(allRouteKey);
|
|
105
|
+
}
|
|
106
|
+
for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {
|
|
107
|
+
const colonIndex = routeKey.indexOf(":");
|
|
108
|
+
if (colonIndex === -1) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const routeMethod = routeKey.substring(0, colonIndex);
|
|
112
|
+
const routePattern = routeKey.substring(colonIndex + 1);
|
|
113
|
+
if (routeMethod !== method && routeMethod !== "ALL") {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (pathMatchesPattern(path, routePattern)) {
|
|
117
|
+
return !requiresAuth;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
};
|
|
122
|
+
var isProtectedPath = (path, method, authConfig, customRouteAuthConfig) => {
|
|
123
|
+
const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
|
|
124
|
+
return isAnyMatch(path, method, protectedAccess) || !isCustomRoutePublic(path, method, customRouteAuthConfig);
|
|
125
|
+
};
|
|
126
|
+
var canAccessPublicly = (path, method, authConfig) => {
|
|
127
|
+
const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
|
|
128
|
+
return isAnyMatch(path, method, publicAccess);
|
|
129
|
+
};
|
|
130
|
+
var isAnyMatch = (path, method, patterns) => {
|
|
131
|
+
if (!patterns) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
for (const patternPathOrMethod of patterns) {
|
|
135
|
+
if (patternPathOrMethod instanceof RegExp) {
|
|
136
|
+
if (patternPathOrMethod.test(path)) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (typeof patternPathOrMethod === "string" && pathMatchesPattern(path, patternPathOrMethod)) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {
|
|
144
|
+
const [pattern, methodOrMethods] = patternPathOrMethod;
|
|
145
|
+
if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
};
|
|
152
|
+
var pathMatchesPattern = (path, pattern) => {
|
|
153
|
+
const { pattern: regex } = parse(pattern);
|
|
154
|
+
return regex.test(path);
|
|
155
|
+
};
|
|
156
|
+
var pathMatchesRule = (path, rulePath) => {
|
|
157
|
+
if (!rulePath) return true;
|
|
158
|
+
if (typeof rulePath === "string") {
|
|
159
|
+
return pathMatchesPattern(path, rulePath);
|
|
160
|
+
}
|
|
161
|
+
if (rulePath instanceof RegExp) {
|
|
162
|
+
return rulePath.test(path);
|
|
163
|
+
}
|
|
164
|
+
if (Array.isArray(rulePath)) {
|
|
165
|
+
return rulePath.some((p) => pathMatchesPattern(path, p));
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
};
|
|
169
|
+
var matchesOrIncludes = (values, value) => {
|
|
170
|
+
if (typeof values === "string") {
|
|
171
|
+
return values === value;
|
|
172
|
+
}
|
|
173
|
+
if (Array.isArray(values)) {
|
|
174
|
+
return values.includes(value);
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
};
|
|
178
|
+
var checkRules = async (rules, path, method, user) => {
|
|
179
|
+
for (const i in rules || []) {
|
|
180
|
+
const rule = rules?.[i];
|
|
181
|
+
if (!pathMatchesRule(path, rule.path)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (rule.methods && !matchesOrIncludes(rule.methods, method)) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const condition = rule.condition;
|
|
188
|
+
if (typeof condition === "function") {
|
|
189
|
+
const allowed = await Promise.resolve().then(() => condition(user)).catch(() => false);
|
|
190
|
+
if (allowed) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
} else if (rule.allow) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
exports.canAccessPublicly = canAccessPublicly;
|
|
201
|
+
exports.checkRules = checkRules;
|
|
202
|
+
exports.defaultAuthConfig = defaultAuthConfig;
|
|
203
|
+
exports.isCustomRoutePublic = isCustomRoutePublic;
|
|
204
|
+
exports.isDevPlaygroundRequest = isDevPlaygroundRequest;
|
|
205
|
+
exports.isProtectedCustomRoute = isProtectedCustomRoute;
|
|
206
|
+
exports.isProtectedPath = isProtectedPath;
|
|
207
|
+
exports.matchesOrIncludes = matchesOrIncludes;
|
|
208
|
+
exports.pathMatchesPattern = pathMatchesPattern;
|
|
209
|
+
exports.pathMatchesRule = pathMatchesRule;
|
|
210
|
+
//# sourceMappingURL=chunk-AAHPYUEC.cjs.map
|
|
211
|
+
//# sourceMappingURL=chunk-AAHPYUEC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/auth/defaults.ts","../src/server/auth/path-pattern.ts","../src/server/auth/helpers.ts"],"names":[],"mappings":";;;AAGO,IAAM,iBAAA,GAAsC;AAAA,EACjD,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,EACpB,MAAA,EAAQ,CAAC,MAAM,CAAA;AAAA;AAAA,EAEf,KAAA,EAAO;AAAA;AAAA,IAEL;AAAA,MACE,WAAW,CAAA,IAAA,KAAQ;AACjB,QAAA,IAAI,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,IAAA,EAAM;AAC7C,UAAA,IAAI,aAAa,IAAA,EAAM;AACrB,YAAA,OAAO,CAAC,CAAC,IAAA,CAA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O,cAAc,UAAA,EAAY;AACnC,MAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,OAAA,EAAQ,CACnC,IAAA,CAAK,MAAM,SAAA,CAAU,IAAI,CAAC,CAAA,CAC1B,KAAA,CAAM,MAAM,KAAK,CAAA;AAEpB,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF,CAAA,MAAA,IAAW,KAAK,KAAA,EAAO;AACrB,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AAGA,EAAA,OAAO,KAAA;AACT","file":"chunk-AAHPYUEC.cjs","sourcesContent":["import type { MastraAuthConfig } from '@mastra/core/server';\n\n// Default configuration that can be extended by clients\nexport const defaultAuthConfig: MastraAuthConfig = {\n protected: ['/api/*'],\n public: ['/api'],\n // Simple rule system\n rules: [\n // Admin users can do anything\n {\n condition: user => {\n if (typeof user === 'object' && user !== null) {\n if ('isAdmin' in user) {\n return !!user.isAdmin;\n }\n\n if ('role' in user) {\n return user.role === 'admin';\n }\n }\n return false;\n },\n allow: true,\n },\n ],\n};\n","/**\n * Path pattern matching utility\n * Inlined from regexparam v3.0.0 (MIT License)\n * https://github.com/lukeed/regexparam\n *\n * Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport interface ParsedPattern {\n keys: string[] | false;\n pattern: RegExp;\n}\n\n/**\n * Parse a route pattern into a RegExp\n * Supports:\n * - Named parameters: /users/:id\n * - Optional parameters: /users/:id?\n * - Wildcards: /files/*\n * - Mixed patterns: /api/:version/users/:id\n */\nexport function parse(input: string | RegExp, loose?: boolean): ParsedPattern {\n if (input instanceof RegExp) return { keys: false, pattern: input };\n\n let c: string;\n let o: number;\n let tmp: string | undefined;\n let ext: number;\n const keys: string[] = [];\n let pattern = '';\n const arr = input.split('/');\n\n arr[0] || arr.shift();\n\n while ((tmp = arr.shift())) {\n c = tmp[0]!;\n if (c === '*') {\n keys.push(c);\n pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';\n } else if (c === ':') {\n o = tmp.indexOf('?', 1);\n ext = tmp.indexOf('.', 1);\n keys.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));\n pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';\n if (!!~ext) pattern += (!!~o ? '?' : '') + '\\\\' + tmp.substring(ext);\n } else {\n pattern += '/' + tmp;\n }\n }\n\n return {\n keys: keys,\n pattern: new RegExp('^' + pattern + (loose ? '(?=$|/)' : '/?$'), 'i'),\n };\n}\n\n/**\n * Test if a path matches a pattern\n */\nexport function matchPath(path: string, pattern: string | RegExp): boolean {\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n}\n","import type { MastraAuthConfig } from '@mastra/core/server';\n\nimport { defaultAuthConfig } from './defaults';\nimport { parse } from './path-pattern';\n\n/**\n * Check if a route is a registered custom route that requires authentication.\n * Returns true only if the route is explicitly registered with requiresAuth: true.\n * Returns false if the route is not in the config or has requiresAuth: false.\n */\nexport const isProtectedCustomRoute = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig) {\n return false;\n }\n\n // Check exact match first (fast path for static routes)\n const exactRouteKey = `${method}:${path}`;\n if (customRouteAuthConfig.has(exactRouteKey)) {\n return customRouteAuthConfig.get(exactRouteKey) === true;\n }\n\n // Check exact match for ALL method\n const allRouteKey = `ALL:${path}`;\n if (customRouteAuthConfig.has(allRouteKey)) {\n return customRouteAuthConfig.get(allRouteKey) === true;\n }\n\n // Check pattern matches for dynamic routes (e.g., '/users/:id')\n for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {\n const colonIndex = routeKey.indexOf(':');\n if (colonIndex === -1) {\n continue; // Skip malformed keys\n }\n\n const routeMethod = routeKey.substring(0, colonIndex);\n const routePattern = routeKey.substring(colonIndex + 1);\n\n // Check if method matches (exact match or ALL)\n if (routeMethod !== method && routeMethod !== 'ALL') {\n continue;\n }\n\n // Check if path matches the pattern\n if (pathMatchesPattern(path, routePattern)) {\n return requiresAuth === true;\n }\n }\n\n return false; // Not in config = not a protected custom route\n};\n\n/**\n * Check if request is from dev playground\n * @param getHeader - Function to get header value from request\n * @param customRouteAuthConfig - Map of custom route auth configurations\n */\nexport const isDevPlaygroundRequest = (\n path: string,\n method: string,\n getHeader: (name: string) => string | undefined,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return (\n process.env.MASTRA_DEV === 'true' &&\n // Allow if path doesn't match protected patterns AND is not a protected custom route\n ((!isAnyMatch(path, method, protectedAccess) && !isProtectedCustomRoute(path, method, customRouteAuthConfig)) ||\n // Or if has playground header\n getHeader('x-mastra-dev-playground') === 'true')\n );\n};\n\nexport const isCustomRoutePublic = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig) {\n return false;\n }\n\n // Check exact match first (fast path for static routes)\n const exactRouteKey = `${method}:${path}`;\n if (customRouteAuthConfig.has(exactRouteKey)) {\n return !customRouteAuthConfig.get(exactRouteKey); // True when route opts out of auth\n }\n\n // Check exact match for ALL method\n const allRouteKey = `ALL:${path}`;\n if (customRouteAuthConfig.has(allRouteKey)) {\n return !customRouteAuthConfig.get(allRouteKey);\n }\n\n // Check pattern matches for dynamic routes (e.g., '/users/:id')\n for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {\n const colonIndex = routeKey.indexOf(':');\n if (colonIndex === -1) {\n continue; // Skip malformed keys\n }\n\n const routeMethod = routeKey.substring(0, colonIndex);\n const routePattern = routeKey.substring(colonIndex + 1);\n\n // Check if method matches (exact match or ALL)\n if (routeMethod !== method && routeMethod !== 'ALL') {\n continue;\n }\n\n // Check if path matches the pattern\n if (pathMatchesPattern(path, routePattern)) {\n return !requiresAuth; // True when route opts out of auth\n }\n }\n\n return false;\n};\n\nexport const isProtectedPath = (\n path: string,\n method: string,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return isAnyMatch(path, method, protectedAccess) || !isCustomRoutePublic(path, method, customRouteAuthConfig);\n};\n\nexport const canAccessPublicly = (path: string, method: string, authConfig: MastraAuthConfig): boolean => {\n // Check if this path+method combination is publicly accessible\n const publicAccess = [...(defaultAuthConfig.public || []), ...(authConfig.public || [])];\n\n return isAnyMatch(path, method, publicAccess);\n};\n\nconst isAnyMatch = (\n path: string,\n method: string,\n patterns: MastraAuthConfig['protected'] | MastraAuthConfig['public'],\n): boolean => {\n if (!patterns) {\n return false;\n }\n\n for (const patternPathOrMethod of patterns) {\n if (patternPathOrMethod instanceof RegExp) {\n if (patternPathOrMethod.test(path)) {\n return true;\n }\n }\n\n if (typeof patternPathOrMethod === 'string' && pathMatchesPattern(path, patternPathOrMethod)) {\n return true;\n }\n\n if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {\n const [pattern, methodOrMethods] = patternPathOrMethod;\n if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nexport const pathMatchesPattern = (path: string, pattern: string): boolean => {\n // Use regexparam for battle-tested path matching\n // Supports:\n // - Exact paths: '/api/users'\n // - Wildcards: '/api/agents/*' matches '/api/agents/123'\n // - Path parameters: '/users/:id' matches '/users/123'\n // - Optional parameters: '/users/:id?' matches '/users' and '/users/123'\n // - Mixed patterns: '/api/:version/users/:id/profile'\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n};\n\nexport const pathMatchesRule = (path: string, rulePath: string | RegExp | string[] | undefined): boolean => {\n if (!rulePath) return true; // No path specified means all paths\n\n if (typeof rulePath === 'string') {\n return pathMatchesPattern(path, rulePath);\n }\n\n if (rulePath instanceof RegExp) {\n return rulePath.test(path);\n }\n\n if (Array.isArray(rulePath)) {\n return rulePath.some(p => pathMatchesPattern(path, p));\n }\n\n return false;\n};\n\nexport const matchesOrIncludes = (values: string | string[], value: string): boolean => {\n if (typeof values === 'string') {\n return values === value;\n }\n\n if (Array.isArray(values)) {\n return values.includes(value);\n }\n\n return false;\n};\n\n// Check authorization rules\nexport const checkRules = async (\n rules: MastraAuthConfig['rules'],\n path: string,\n method: string,\n user: unknown,\n): Promise<boolean> => {\n // Go through rules in order (first match wins)\n for (const i in rules || []) {\n const rule = rules?.[i]!;\n // Check if rule applies to this path\n if (!pathMatchesRule(path, rule.path)) {\n continue;\n }\n\n // Check if rule applies to this method\n if (rule.methods && !matchesOrIncludes(rule.methods, method)) {\n continue;\n }\n\n // Rule matches, check conditions\n const condition = rule.condition;\n if (typeof condition === 'function') {\n const allowed = await Promise.resolve()\n .then(() => condition(user))\n .catch(() => false);\n\n if (allowed) {\n return true;\n }\n } else if (rule.allow) {\n return true;\n }\n }\n\n // No matching rules, deny by default\n return false;\n};\n"]}
|