hunk.code_window:     }
       return await Promise.all(providerPromises);
     }
  
hunk.labels: keep replace replace keep keep
hunk.file_path: packages/nest/src/services/notifire.service.ts
hunk.type: replace
file: import { createParamDecorator, UnauthorizedException } from '@nestjs/common';
  import * as jwt from 'jsonwebtoken';
  
  export const UserSession = createParamDecorator((data, ctx) => {
    let req;
    if (ctx.getType() === 'graphql') {
      req = ctx.getArgs()[2].req;
    } else {
      req = ctx.switchToHttp().getRequest();
    }
  
    if (req.user) return req.user;
  
    if (req.headers) {
      if (req.headers.authorization) {
        const tokenParts = req.headers.authorization.split(' ');
        if (tokenParts[0] !== 'Bearer') throw new UnauthorizedException('bad_token');
        if (!tokenParts[1]) throw new UnauthorizedException('bad_token');
  
        const user = jwt.decode(tokenParts[1]);
        return user;
      }
    }
  
    return null;
  });
  
  export const SubscriberSession = createParamDecorator((data, ctx) => {
    let req;
    if (ctx.getType() === 'graphql') {
      req = ctx.getArgs()[2].req;
    } else {
      req = ctx.switchToHttp().getRequest();
    }
  
    if (req.user) return req.user;
  
    if (req.headers) {
      if (req.headers.authorization) {
        const tokenParts = req.headers.authorization.split(' ');
        if (tokenParts[0] !== 'Bearer') throw new UnauthorizedException('bad_token');
        if (!tokenParts[1]) throw new UnauthorizedException('bad_token');
  
        const user = jwt.decode(tokenParts[1]);
        return user;
      }
    }
  
    return null;
  });
  