{"version":3,"file":"get-session.cjs","sourceRoot":"","sources":["../../../src/middleware/multichain/get-session.ts"],"names":[],"mappings":";;;AACA,mFAG6C;AAI7C,uCAA2C;AAS3C;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,QAAwB,EACxB,KAA6B;IAE7B,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAC5B,yDAA6B,EAC7B,4CAAgB,CACoB,CAAC;IAEvC,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,wBAAgB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnE,OAAO,EAAE,aAAa,EAAE,CAAC;AAC3B,CAAC;AAZD,8CAYC","sourcesContent":["import type { Caip25CaveatValue } from '@metamask/chain-agnostic-permission';\nimport {\n  Caip25CaveatType,\n  Caip25EndowmentPermissionName,\n} from '@metamask/chain-agnostic-permission';\nimport type { Caveat } from '@metamask/permission-controller';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\n\nimport { getSessionScopes } from './utils';\n\nexport type GetSessionHandlerHooks = {\n  getCaveat: (\n    permission: string,\n    caveatType: string,\n  ) => Caveat<string, Json> | undefined;\n};\n\n/**\n * A handler that implements a simplified version of `wallet_getSession`.\n *\n * @param _request - Incoming JSON-RPC request. Ignored for this specific\n * handler.\n * @param hooks - The method hooks.\n * @returns The JSON-RPC response.\n */\nexport function getSessionHandler(\n  _request: JsonRpcRequest,\n  hooks: GetSessionHandlerHooks,\n) {\n  const caveat = hooks.getCaveat(\n    Caip25EndowmentPermissionName,\n    Caip25CaveatType,\n  ) as Caveat<string, Caip25CaveatValue>;\n\n  const sessionScopes = caveat ? getSessionScopes(caveat.value) : {};\n\n  return { sessionScopes };\n}\n"]}