text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const sessionKeyProvider_1 = require("./sessionKeyProvider");
  /**
   * Uses data.session.session_id as a key
   * to store user sessions
   */
  function sessionMiddleware(storage, { keyProvider = sessionKeyProvider_1.sessionKeyUserIdProvider } = {}) {
      return async (context, next) => {
          const id = await keyProvider(context);
          const session = await storage.getOrCreate(id);
          const sessionContext = Object.assign({}, context, { session });
          return next ? next(sessionContext) : sessionContext;
      };
  }
  exports.sessionMiddleware = sessionMiddleware;
  