Two-factor setup doesn't compile against the new better-auth types

Đang mở Phù hợp với người mới
#18 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bun, typescript
Lĩnh vực
authentication, testing

Hướng nghiên cứu

Bắt đầu trong apps/web/src/routes/profile.tsx tại start() và thu hẹp kết quả của twoFactor.enable dựa trên method trước khi đọc các trường TOTP; kiểm tra dòng lỗi hiện có cho trường hợp không phải TOTP. Sau đó, cập nhật các assertion trong packages/auth/src/two-factor.test.ts và packages/auth/src/sign-in-events.test.ts để kiểm tra method dự kiến. Trên branch #12, chạy bun run typecheck và bun test packages/auth; cả hai đều sẽ chạy thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

dependencies good first issue javascript

Dependabot's minor-and-patch group (#12) moves better-auth forward, and with it the return type of twoFactor.enable. It used to promise a TOTP URI and backup codes every time. Now it says what it actually does: you get { method: "otp" } or { method: "totp"; totpURI; backupCodes }, depending on how two-factor was turned on.

Our code reads totpURI and backupCodes straight off the result, so the typecheck fails on #12 at d3f9dcc0 and the whole group is stuck behind it.

Where

  • apps/web/src/routes/profile.tsx:527 and :530, in start()
  • packages/auth/src/two-factor.test.ts:44, :46, :47
  • packages/auth/src/sign-in-events.test.ts:176, :187, :346

What to change

Narrow on method before reading the TOTP fields. In profile.tsx, an answer that isn't "totp" should show the existing error line rather than handing new URL("") an empty string, which throws. The tests can assert method === "totp" first; that's a better test anyway, since it says which kind of setup they expect.

Please don't add a cast. The new type is telling the truth.

Test

Check out the #12 branch (dependabot/bun/minor-and-patch-…), make the change on top, then:

bun run typecheck
bun test packages/auth

Both should pass, and #12 can merge once this lands.

Ngôn ngữ chính
TypeScript
Star
13
Fork
3
Merge trung bình
38 phút
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Sentrello/Sentrello

Tất cả issue của Sentrello/Sentrello

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.