https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • r

    redux1997

    05/08/2023, 12:52 PM
    On Miniflare this is working but not on Wokers
  • r

    redux1997

    05/08/2023, 12:55 PM
    export default { async fetch(request, env, ctx) { // Fetch from origin server. let response = await fetch(request); // Create an identity TransformStream (a.k.a. a pipe). // The readable side will become our new response body. let { readable, writable } = new TransformStream(); // Start pumping the body. NOTE: No await! response.body.pipeTo(writable); // ... and deliver our Response while that’s running. return new Response(readable, response); } }
  • r

    redux1997

    05/08/2023, 12:59 PM
    This code works fine but if instead of response.body readable I have custom Readable then its not working
  • a

    AlHill

    05/08/2023, 3:50 PM
    I'm trying to send a multipart/form-data to a worker and it's working fine... but the field which has a blob doesn't appear.
  • a

    AlHill

    05/08/2023, 3:51 PM
    The compatibility date of the worker is recent and I have checked the blob is there before sending it
  • d

    dave

    05/08/2023, 4:20 PM
    IMO it's well worth paying for a domain. https://discord.com/channels/595317990191398933/812577823599755274/1011267655132524544
  • d

    dave

    05/08/2023, 4:41 PM
    https://discord.com/channels/595317990191398933/909458221419356210/1070550453198262332
  • e

    Erisa | Support Engineer

    05/08/2023, 4:48 PM
    or #1104040620948992090
  • d

    dave

    05/08/2023, 5:06 PM
    Any tips on how I can avoid timing attacks when I'm accessing a remote DB from a Worker, and returning the result to the user?
  • k

    kian

    05/08/2023, 5:21 PM
    Depends what the timing attack is
  • k

    kian

    05/08/2023, 5:21 PM
    Are they providing an authentication token that you're checking?
  • d

    dave

    05/08/2023, 6:00 PM
    yep. I'm doing: 1. Generating a JWT to login to supabase in my Worker 2. Doing an SQL query to see if they have an API key, and using that key for a HMAC check. The issue is I'm worried the SQL query will return faster if there's no real user.
  • j

    Jeff Wu | Notional

    05/08/2023, 6:22 PM
    i'm having problems with this error:
    Copy code
    RESPONSE: {
      "result": null,
      "success": false,
      "errors": [
        {
          "code": 10021,
          "message": "Error: Script startup exceeded CPU time limit.\n"
        }
      ],
      "messages": []
    }
  • j

    Jeff Wu | Notional

    05/08/2023, 6:23 PM
    i've narrowed it down to one my depedencies but i'm not sure how i can get the startup time down
  • j

    Jeff Wu | Notional

    05/08/2023, 6:24 PM
    i believe it is this dependency: https://github.com/graphprotocol/graph-client/tree/main
  • j

    Jeff Wu | Notional

    05/08/2023, 6:24 PM
    it uses this graphql-mesh thing inside: https://the-guild.dev/graphql/mesh/docs/handlers/graphql#config-api-reference
  • j

    Jeff Wu | Notional

    05/08/2023, 6:25 PM
    does anyone have tips on how to profile or analyze what is causing a slow startup time?
  • s

    sathoro

    05/08/2023, 7:19 PM
    what exactly are you HMAC checking?
  • j

    Jeff Wu | Notional

    05/08/2023, 7:24 PM
    ok i resolved this using
    await import(...)
    inside a function, maybe that will help someone else
  • d

    dave

    05/08/2023, 7:37 PM
    still thinking everything though on how to handle API keys.. but the issue is that the timing attack shows up before I even do the check.
  • s

    sathoro

    05/08/2023, 7:38 PM
    hmm I don't really understand the problem
  • d

    dave

    05/08/2023, 7:40 PM
    so you use our API by providing
    sathoro@testing.email.ai.moda
    as your AWS access ID, and
    randomvaluethatweprovidedyouawhileago
    as your AWS secret key. If an attacker gives
    sathoro@testing.email.ai.moda
    but with an invalid AWS secret key, they would still know that you're a customer of ours.
  • s

    sathoro

    05/08/2023, 7:41 PM
    can't they check that by just trying to register an account with you?
  • d

    dave

    05/08/2023, 7:42 PM
    nope! We instantly return as soon as you register
  • s

    sathoro

    05/08/2023, 7:42 PM
    but what happens if I have an account and somebody else tries to register
    sathoro@testing.email.ai.moda
    ?
  • d

    dave

    05/08/2023, 7:42 PM
    nothing 🙂
  • s

    sathoro

    05/08/2023, 7:43 PM
    what do you do if there is no account?
  • d

    dave

    05/08/2023, 7:43 PM
    we create the account.
  • d

    dave

    05/08/2023, 7:44 PM
    Copy code
    typescript
    export const registerEndpoint: Handler<
      AuthApiContext,
      string,
      { out: { json: SendOtpType } }
    > = (c) => {
      const { email: input_email } = c.req.valid('json');
      const decoded_email = decodeURIComponent(input_email);
      console.debug(`decoded_email: ${decoded_email}`);
    
      if(!validateEmail(decoded_email)) {
        return c.json({ success: false, message: 'Invalid email' });
      }
    
      const created_prom = getBillingId(decoded_email).then(async (billing_id) => {
        const supabase_client_admin = c.get('supabase_client_admin')
    
        return supabase_client_admin.auth.admin.createUser({
          email: decoded_email,
          user_metadata: {
            billing_id: billing_id
          }
        })
      })
    
      c.executionCtx.waitUntil(created_prom);
    
      created_prom.then((res) => {
        console.debug(`res: ${JSON.stringify(res)}`);
      }).catch((err) => {
        console.error(`err: ${JSON.stringify(err)}`);
      })
    
      return c.json({ success: true, message: 'Email has been registered.' }, 202);
    }
  • d

    dave

    05/08/2023, 7:44 PM
    that is basically the code we use
1...244424452446...2509Latest