activescott / activescott/auth

email-provider: can magiclink and otp be consolidated to simplify the internal implementation and usage of the email-providre?

Offen
#39 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
0
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In https://github.com/activescott/auth/blob/ade8601c4673589fbf6d3f4387976a4a5dea3a91/packages/auth-provider-email/src/email-provider.ts#L92-L114 we have different code to generate a "link key" separate from generating an OTP code. Since OTP codes and link keys are very similar in purpose, I wonder the "link key" can't simply be an OTP code. The separation of OTP and link key is scattered a bit throughout the code so it isn't just this one block of code. Some other notable places the duplication impacts that I noticed (there may be more):
- EmailTransport.sendMagicLink: Has to deal with both magiclink and options arg (SendMagicLinkOptions) includes the OTP code. Why isn't this more like "sendMessage" and includes an OTP. I wonder if unifying on OTP for the magic link can even be further DRYd up with SMS transport.
- the EmailProvider.verify implementation has to deal with boduy.challenge and body.key and body.code.
- examples/react-router/app/lib/capture-email-transport.server.ts ends up with "sendMagicLink" which seems overfitted to the purpose here sinc eit sends a code.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.