MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

importing from deno.land fails caused by missing dep "src/dom.ts" #460

Closed ingoradatz closed 1 year ago

ingoradatz commented 1 year ago

Describe the issue

When I try the vendor the deno package it fails with

error: Module not found "https://deno.land/x/simplewebauthn@v8.3.2/packages/typescript-types/src/dom.ts".
    at https://deno.land/x/simplewebauthn@v8.3.2/packages/typescript-types/src/index.ts:23:8`

Reproduction Steps

  1. Open terminal with deno already installed
  2. enter the deno project folder
  3. $> deno vendor https://deno.land/x/simplewebauthn/deno/server.ts --no-config --force
  4. See error

Expected behavior

It should download the simplewebauthn package to the vendor/deno.land/x folder

Additional context

The packages/typescript-types/src/dom.ts file is normally automatically generated when simplewebauthn is packaged for uploading to deno.land? Maybe a CI-Problem?

MasterKale commented 1 year ago

Huh, I suppose it's unsurprising that you're getting a "Module not found" error here because dom.ts doesn't actually exist:

Screenshot 2023-10-23 at 10 12 21 PM

https://deno.land/x/simplewebauthn@v8.3.2/packages/typescript-types/src?source

Back when I only published to NPM this file would get generated and bundled into the published package. I guess I need to start tracking this file and periodically keeping it up-to-date so that it's available in Deno...

I wonder how I got this far with thinking this would work. I'm admittedly new to Deno development myself so I must not have "properly" bootstrapped a Deno project to test that importing from deno.land would pull this in without issue.

Let me think on how best to address this. Maybe it will be as easy as tracking this file and occasionally updating it.

MasterKale commented 1 year ago

@ingoradatz This should be resolved with the release of v8.3.3:

$> deno vendor https://deno.land/x/simplewebauthn/deno/server.ts --no-config --force
Warning Implicitly using latest version (v8.3.3) for https://deno.land/x/simplewebauthn/deno/server.ts
Vendored 169 modules into vendor/ directory.

To use vendored modules, specify the `--import-map vendor/import_map.json` flag when invoking Deno subcommands or add an `"importMap": "<path_to_vendored_import_map>"` entry to a deno.json file.
ingoradatz commented 1 year ago

Nice. I will give it a try.

Meanwhile i got it working on deno by building it and copying it over but this has no future :-) and i've hoped you will find a solution.

My experiment is to run it as function on deno deploy. It looks good so far and i've learned a lot from your code comments. Actually i also want to use the deno KV storage for the session related data of SWA.

Are you interested in discussing security implications when this works?

MasterKale commented 1 year ago

Are you interested in discussing security implications when this works?

I'd be interested in following along, sure. Opening a Discussion here is probably the best way to start the conversation when you're ready.

spendres commented 1 year ago

@ingoradatz

There is a simple deno.deploy using kv example at passkeys.deno.dev. It uses oak sessions and an early 8.x version of simplewebauthn. It may give you a head start.

@MasterKale

The issue with webcrypto on cloudflare needing a check on the global namespace to know which webcrypto to import was where we left off in August. It's good to see that being resolved with other PRs. But, I have not verified that the proposed PR would not break Deno and am too busy on other fronts at the moment to do so – so just a note.

Steve

spendres commented 1 year ago

sorry... repo: https://github.com/maximousblk/passkeys-demo

ingoradatz commented 1 year ago

@spendres Thank you for the hint