harmonyV

AuthContext

Jan 2nd, 2026
158
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { ContextProvider, RequestData } from "genkit/context";
  2. import { UserFacingError } from "genkit/beta";
  3. import * as jwt from "jsonwebtoken";
  4. import jwksClient from "jwks-rsa";
  5.  
  6. // Initialize the JWKS client with caching
  7. // Replace <PROJECT_ID> with your actual Supabase Project ID or use an env var
  8. const SUPABASE_PROJECT_ID = process.env.SUPABASE_PROJECT_ID;
  9. const jwksUri =
  10.     `https://${SUPABASE_PROJECT_ID}.supabase.co/auth/v1/.well-known/jwks.json`;
  11.  
  12. const client = jwksClient({
  13.     jwksUri: jwksUri,
  14.     cache: true,
  15.     rateLimit: true,
  16.     jwksRequestsPerMinute: 5,
  17. });
  18.  
  19. // Helper to retrieve the signing key based on the 'kid' in the JWT header
  20. const getKey: jwt.GetPublicKeyOrSecret = (header, callback) => {
  21.     client.getSigningKey(header.kid, (err, key) => {
  22.         if (err) {
  23.             callback(err);
  24.         } else {
  25.             const signingKey = key?.getPublicKey();
  26.             callback(null, signingKey);
  27.         }
  28.     });
  29. };
  30.  
  31. export const supabaseAuthContextProvider: ContextProvider<any> = async (
  32.     req: RequestData,
  33. ): Promise<any> => {
  34.     const authHeader = req.headers["authorization"];
  35.     if (!authHeader) {
  36.         throw new UserFacingError("UNAUTHENTICATED", "Missing Header");
  37.     }
  38.  
  39.     const [scheme, token] = authHeader.split(" ");
  40.     if (scheme.toLowerCase() !== "bearer" || !token) {
  41.         throw new UserFacingError("INVALID_ARGUMENT", "Malformed Header");
  42.     }
  43.  
  44.     return new Promise((resolve, reject) => {
  45.         jwt.verify(token, getKey, {
  46.             algorithms: ["ES256", "RS256"], // Supabase uses ES256 for ECC
  47.             issuer: `https://${SUPABASE_PROJECT_ID}.supabase.co/auth/v1`,
  48.         }, (err, decoded: any) => {
  49.             if (err) {
  50.                 console.error("JWT Verification Error:", err.message);
  51.                 return reject(
  52.                     new UserFacingError("PERMISSION_DENIED", "Invalid Token"),
  53.                 );
  54.             }
  55.  
  56.             // Supabase JWTs usually have 'authenticated' as the audience (aud)
  57.             if (decoded.aud !== "authenticated") {
  58.                 return reject(
  59.                     new UserFacingError(
  60.                         "PERMISSION_DENIED",
  61.                         "Invalid Audience",
  62.                     ),
  63.                 );
  64.             }
  65.  
  66.             resolve({
  67.                 auth: {
  68.                     isAuthenticated: true,
  69.                     userId: decoded.sub,
  70.                     email: decoded.email,
  71.                 },
  72.             });
  73.         });
  74.     });
  75. };
  76.  
Advertisement
Comments
  • User was banned
  • User was banned
  • Vormilir
    129 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
Add Comment
Please, Sign In to add comment