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

    xHyroM

    04/07/2023, 1:34 PM
    hey, is there any function for getting bindings?
  • x

    xHyroM

    04/07/2023, 1:34 PM
    i need them somewhere else than fetch function
  • h

    HardAtWork

    04/07/2023, 1:38 PM
    You can pass them into the scope you need them in?
  • x

    xHyroM

    04/07/2023, 1:46 PM
    yeh i fixed it
  • x

    xHyroM

    04/07/2023, 1:46 PM
    do you now why i get
    Copy code
    bot:dev: [mf:err] POST /: NotSupportedError: Unrecognized name.
    bot:dev:     at new DOMException (node:internal/per_context/domexception:53:5)
    bot:dev:     at __node_internal_ (node:internal/util:609:10)
    bot:dev:     at normalizeAlgorithm (node:internal/crypto/util:203:15)
    bot:dev:     at signVerify (node:internal/crypto/webcrypto:636:15)
    bot:dev:     at SubtleCrypto.verify (node:internal/crypto/webcrypto:682:10)
    bot:dev:     at Proxy.verify (C:\Users\Jozef Steinhübl\Workspace\TypeScript\roles-bot\node_modules\.pnpm\@miniflare+core@2.10.0\node_modules\@miniflare\core\src\standards\crypto.ts:193:27)
    bot:dev:     at processTicksAndRejections (node:internal/process/task_queues:95:5)
    bot:dev:     at oi (C:\Users\Jozef Steinhübl\Workspace\TypeScript\roles-bot\packages\bot\dist\worker.mjs:1:67473)
    bot:dev:     at Object.fetch (C:\Users\Jozef Steinhübl\Workspace\TypeScript\roles-bot\packages\bot\dist\worker.mjs:1:67710)
    bot:dev:     at ServiceWorkerGlobalScope.[kDispatchFetch] (C:\Users\Jozef Steinhübl\Workspace\TypeScript\roles-bot\node_modules\.pnpm\@miniflare+core@2.10.0\node_modules\@miniflare\core\src\standards\event.ts:385:13)
  • x

    xHyroM

    04/07/2023, 1:46 PM
    Copy code
    js
    // from https://gist.github.com/devsnek/77275f6e3f810a9545440931ed314dc1
    
    "use strict";
    
    function hex2bin(hex: string) {
        const buf = new Uint8Array(Math.ceil(hex.length / 2));
        for (let i = 0; i < buf.length; i++) {
            buf[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
        }
        return buf;
    }
    
    const encoder = new TextEncoder();
    
    export async function verify(request: Request, env: Env) {
        const subtle = await crypto.subtle.importKey(
            "raw",
            hex2bin(env.publicKey),
            {
                name: "NODE-ED25519",
                namedCurve: "NODE-ED25519",
            },
            true,
            ["verify"],
        );
    
        // rome-ignore lint/style/noNonNullAssertion: its fine
        const signature = hex2bin(request.headers.get("X-Signature-Ed25519")!);
        const timestamp = request.headers.get("X-Signature-Timestamp");
        const unknown = await request.clone().text();
    
        return await crypto.subtle.verify(
            "NODE-ED25519",
            subtle,
            signature,
            encoder.encode(timestamp + unknown),
        );
    }
  • h

    HardAtWork

    04/07/2023, 1:50 PM
    That doesn't appear to be a valid encryption algorithm for WebCrypto: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/verify#parameters
  • x

    xHyroM

    04/07/2023, 1:50 PM
    it works fine on cf workers
  • h

    HardAtWork

    04/07/2023, 1:51 PM
    Oh, oops: > Non-standard EdDSA is supported for the Ed25519 curve. Since this algorithm is non-standard, a few things to keep in mind while using it:
  • w

    Walshy | Pages

    04/07/2023, 1:51 PM
    yeah NODE-ED25519 is supported in Workers
  • h

    HardAtWork

    04/07/2023, 1:51 PM
    Nvm
  • x

    xHyroM

    04/07/2023, 1:53 PM
    node v18 just have
    Ed25519
  • w

    Walshy | Pages

    04/07/2023, 1:53 PM
    I'd report this to Miniflare's repo
  • x

    xHyroM

    04/07/2023, 1:53 PM
    ill just do check if miniflare is used for now
  • w

    Walshy | Pages

    04/07/2023, 1:53 PM
    yeah it should be fine
  • x

    xHyroM

    04/07/2023, 1:54 PM
    does cf workers supports Ed25519 or i need to keep NODE-ED25519
  • x

    xHyroM

    04/07/2023, 1:54 PM
    with globalThis.MINIFLARE check
  • w

    Walshy | Pages

    04/07/2023, 1:55 PM
    NODE-ED25519
  • k

    kulotskinakalbo

    04/07/2023, 2:47 PM
    how can i fix this issue? "from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
    w
    • 2
    • 4
  • s

    steeldragon

    04/07/2023, 3:52 PM
    Will workers have JSPI when that is ready?
  • f

    Fabian

    04/07/2023, 4:12 PM
    Just coincidentally found out that custom Worker domains support multi-level subdomains with free SSL cert, but Cloudflare DNS only supports one level. Is this expected? (And drifting off of the channel topic but if I were to buy certificate manager, is this 10$ extra per-domain and does every additional cert incur cost? I'd be completely fine with a Let's Encrypt cert, since Worker certs seem to be issued from Let's Encrypt)
  • c

    Chaika

    04/07/2023, 4:15 PM
    Yes, Worker Custom Domains issue an adv. cert that allows that. Same for CF Pages and a few other products. They don't support wildcards though. ACM gives you 100 adv. certs, and you can pick the specific CA to use (Digicert, LE, or GTS), and I believe the cipher/a few other things as well that you can't normally
  • u

    Unsmart | Tech debt

    04/07/2023, 4:16 PM
    Do note that certs issues from workers custom domains will count towards your ACM quota if you do buy ACM but if you do not have ACM it is just freely given out
  • f

    Fabian

    04/07/2023, 4:16 PM
    Are the 100 certs bound to the domain I am buying ACM through or will ACM be enabled globally on my account?
  • u

    Unsmart | Tech debt

    04/07/2023, 4:17 PM
    ACM is per domain unless you have account level ACM through enterprise
  • f

    Fabian

    04/07/2023, 4:17 PM
    Alright, thanks :)
  • a

    advaith

    04/07/2023, 7:32 PM
    does cloudflared support ubuntu 22.10
  • s

    Skye

    04/07/2023, 7:37 PM
    It should do
  • c

    Cyb3r-Jok3

    04/07/2023, 7:38 PM
    ^ Cloudflared doesn't have any external dependencies
  • a

    advaith

    04/07/2023, 7:38 PM
    https://pkg.cloudflare.com/index.html doesnt list that version
1...238123822383...2509Latest