@sylphx/auth-solid 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/browser.js +329 -283
- package/dist/messages.d.ts +7 -0
- package/dist/server.js +105 -50
- package/dist/sign-in-controller.d.ts +11 -1
- package/package.json +2 -2
package/dist/messages.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export type SignInMessages = {
|
|
|
57
57
|
use_existing: string;
|
|
58
58
|
invalid_credentials: string;
|
|
59
59
|
verify_email: string;
|
|
60
|
+
acceptance_required: string;
|
|
60
61
|
verification_failed: string;
|
|
61
62
|
invalid_code: string;
|
|
62
63
|
method_unavailable: string;
|
|
@@ -124,6 +125,7 @@ export declare const catalogs: {
|
|
|
124
125
|
cancelled: string;
|
|
125
126
|
use_existing: string;
|
|
126
127
|
invalid_credentials: string;
|
|
128
|
+
acceptance_required: string;
|
|
127
129
|
verify_email: string;
|
|
128
130
|
verification_failed: string;
|
|
129
131
|
invalid_code: string;
|
|
@@ -191,6 +193,7 @@ export declare const catalogs: {
|
|
|
191
193
|
cancelled: string;
|
|
192
194
|
use_existing: string;
|
|
193
195
|
invalid_credentials: string;
|
|
196
|
+
acceptance_required: string;
|
|
194
197
|
verify_email: string;
|
|
195
198
|
verification_failed: string;
|
|
196
199
|
invalid_code: string;
|
|
@@ -258,6 +261,7 @@ export declare const catalogs: {
|
|
|
258
261
|
cancelled: string;
|
|
259
262
|
use_existing: string;
|
|
260
263
|
invalid_credentials: string;
|
|
264
|
+
acceptance_required: string;
|
|
261
265
|
verify_email: string;
|
|
262
266
|
verification_failed: string;
|
|
263
267
|
invalid_code: string;
|
|
@@ -325,6 +329,7 @@ export declare const catalogs: {
|
|
|
325
329
|
cancelled: string;
|
|
326
330
|
use_existing: string;
|
|
327
331
|
invalid_credentials: string;
|
|
332
|
+
acceptance_required: string;
|
|
328
333
|
verify_email: string;
|
|
329
334
|
verification_failed: string;
|
|
330
335
|
invalid_code: string;
|
|
@@ -392,6 +397,7 @@ export declare const catalogs: {
|
|
|
392
397
|
cancelled: string;
|
|
393
398
|
use_existing: string;
|
|
394
399
|
invalid_credentials: string;
|
|
400
|
+
acceptance_required: string;
|
|
395
401
|
verify_email: string;
|
|
396
402
|
verification_failed: string;
|
|
397
403
|
invalid_code: string;
|
|
@@ -459,6 +465,7 @@ export declare const catalogs: {
|
|
|
459
465
|
cancelled: string;
|
|
460
466
|
use_existing: string;
|
|
461
467
|
invalid_credentials: string;
|
|
468
|
+
acceptance_required: string;
|
|
462
469
|
verify_email: string;
|
|
463
470
|
verification_failed: string;
|
|
464
471
|
invalid_code: string;
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createComponent, escape, memo, ssr, ssrAttribute, ssrHydrationKey, ssrStyle } from "solid-js/web";
|
|
2
|
-
import { providerDestination, providers, safeReturnTo } from "@sylphx/auth/client";
|
|
3
|
-
import { For, Match, Show, Switch, createMemo, createSignal, createUniqueId, onCleanup, onMount } from "solid-js";
|
|
2
|
+
import { authRoutePrefix, providerDestination, providers, safeReturnTo } from "@sylphx/auth/client";
|
|
3
|
+
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, createUniqueId, onCleanup, onMount } from "solid-js";
|
|
4
4
|
// src/messages.ts
|
|
5
5
|
var catalogs = {
|
|
6
6
|
en: {
|
|
@@ -60,6 +60,7 @@ var catalogs = {
|
|
|
60
60
|
cancelled: "Sign-in was canceled. You can try again whenever you’re ready.",
|
|
61
61
|
use_existing: "Try the method you originally used to sign in. This provider couldn’t confirm your email.",
|
|
62
62
|
invalid_credentials: "That email and password didn’t match. Check both and try again.",
|
|
63
|
+
acceptance_required: "Accept the current terms to continue.",
|
|
63
64
|
verify_email: "Confirm your email from the link in your inbox before signing in.",
|
|
64
65
|
verification_failed: "This confirmation link couldn’t be used. Check that you opened the latest link.",
|
|
65
66
|
invalid_code: "That code didn’t work. Check it and try again.",
|
|
@@ -127,6 +128,7 @@ var catalogs = {
|
|
|
127
128
|
cancelled: "登入已取消。你可以隨時再試。",
|
|
128
129
|
use_existing: "這項登入服務未能確認你的電郵地址。請改用原來的登入方式。",
|
|
129
130
|
invalid_credentials: "電郵地址與密碼不符。請核對後再試。",
|
|
131
|
+
acceptance_required: "請同意現行條款後繼續。",
|
|
130
132
|
verify_email: "請先開啟確認電郵內的連結,確認電郵地址後再登入。",
|
|
131
133
|
verification_failed: "此連結無法使用。請開啟最新一封確認電郵內的連結。",
|
|
132
134
|
invalid_code: "驗證碼無法使用。請核對後再試。",
|
|
@@ -194,6 +196,7 @@ var catalogs = {
|
|
|
194
196
|
cancelled: "登入已取消。你可以隨時再試。",
|
|
195
197
|
use_existing: "這項登入服務無法確認你的電子郵件地址。請改用原本的登入方式。",
|
|
196
198
|
invalid_credentials: "電子郵件地址和密碼不符。請檢查後再試一次。",
|
|
199
|
+
acceptance_required: "請同意目前的條款後繼續。",
|
|
197
200
|
verify_email: "請先開啟確認信中的連結,確認電子郵件地址後再登入。",
|
|
198
201
|
verification_failed: "這個確認連結無法使用。請確認你開啟的是最新一封確認信中的連結。",
|
|
199
202
|
invalid_code: "這組驗證碼無法使用。請檢查後再試一次。",
|
|
@@ -261,6 +264,7 @@ var catalogs = {
|
|
|
261
264
|
cancelled: "登录已取消。你可以随时重试。",
|
|
262
265
|
use_existing: "此登录服务无法确认你的邮箱地址。请改用原来的登录方式。",
|
|
263
266
|
invalid_credentials: "邮箱地址和密码不匹配。请检查后重试。",
|
|
267
|
+
acceptance_required: "请同意当前条款后继续。",
|
|
264
268
|
verify_email: "请先打开确认邮件中的链接,确认邮箱地址后再登录。",
|
|
265
269
|
verification_failed: "此链接无法使用。请打开最新一封确认邮件中的链接。",
|
|
266
270
|
invalid_code: "此验证码无法使用。请检查后重试。",
|
|
@@ -328,6 +332,7 @@ var catalogs = {
|
|
|
328
332
|
cancelled: "ログインがキャンセルされました。いつでもやり直せます。",
|
|
329
333
|
use_existing: "このサービスではメールアドレスを確認できませんでした。最初に使った方法でログインしてください。",
|
|
330
334
|
invalid_credentials: "メールアドレスとパスワードが一致しません。両方を確認して、もう一度お試しください。",
|
|
335
|
+
acceptance_required: "続行するには、現在の利用規約に同意してください。",
|
|
331
336
|
verify_email: "確認メール内のリンクを開き、メールアドレスを確認してからログインしてください。",
|
|
332
337
|
verification_failed: "この確認リンクは使えません。最新の確認メールのリンクをお試しください。",
|
|
333
338
|
invalid_code: "このコードは使えません。入力内容を確認して、もう一度お試しください。",
|
|
@@ -395,6 +400,7 @@ var catalogs = {
|
|
|
395
400
|
cancelled: "로그인이 취소되었습니다. 언제든지 다시 시도할 수 있습니다.",
|
|
396
401
|
use_existing: "이 로그인 서비스에서 이메일 주소를 확인할 수 없습니다. 처음 사용한 방법으로 로그인하세요.",
|
|
397
402
|
invalid_credentials: "이메일 주소 또는 비밀번호가 올바르지 않습니다. 확인한 뒤 다시 시도하세요.",
|
|
403
|
+
acceptance_required: "계속하려면 현재 약관에 동의하세요.",
|
|
398
404
|
verify_email: "로그인하기 전에 받은 이메일의 링크를 열어 이메일 주소를 확인하세요.",
|
|
399
405
|
verification_failed: "이 확인 링크를 사용할 수 없습니다. 가장 최근에 받은 링크를 열어 보세요.",
|
|
400
406
|
invalid_code: "인증 코드가 올바르지 않습니다. 코드를 확인한 뒤 다시 시도하세요.",
|
|
@@ -485,11 +491,12 @@ function encode(value) {
|
|
|
485
491
|
function createSignInController(options) {
|
|
486
492
|
const search = new URLSearchParams(options.search);
|
|
487
493
|
const next = safeReturnTo(options.next);
|
|
494
|
+
const route = authRoutePrefix(options.routePrefix);
|
|
488
495
|
const loginPath = safeReturnTo(options.loginPath, "/login").split(/[?#]/, 1)[0];
|
|
489
496
|
const challengeId = search.get("challenge_id");
|
|
490
497
|
const verification = search.get("token");
|
|
491
498
|
const hasVerification = !!challengeId && !!verification && search.get("type") === "email_verification";
|
|
492
|
-
const [config, setConfig] = createSignal();
|
|
499
|
+
const [config, setConfig] = createSignal(options.initialConfig);
|
|
493
500
|
const [configFailed, setConfigFailed] = createSignal(false);
|
|
494
501
|
const [step, setStep] = createSignal("choose");
|
|
495
502
|
const [email, setEmail] = createSignal("");
|
|
@@ -502,6 +509,9 @@ function createSignInController(options) {
|
|
|
502
509
|
const [busy, setBusy] = createSignal("");
|
|
503
510
|
const [showPassword, setShowPassword] = createSignal(false);
|
|
504
511
|
const [canPasskey, setCanPasskey] = createSignal(false);
|
|
512
|
+
const [conditionalReady, setConditionalReady] = createSignal(false);
|
|
513
|
+
let conditional;
|
|
514
|
+
let attemptedConditional = false;
|
|
505
515
|
const [code, setCode] = createSignal("");
|
|
506
516
|
const [flow, setFlow] = createSignal("");
|
|
507
517
|
const [challenge, setChallenge] = createSignal("");
|
|
@@ -520,7 +530,7 @@ function createSignInController(options) {
|
|
|
520
530
|
const attempt = new AbortController();
|
|
521
531
|
confController = attempt;
|
|
522
532
|
try {
|
|
523
|
-
const res = await fetch(
|
|
533
|
+
const res = await fetch(`${route}/config`, {
|
|
524
534
|
referrerPolicy: "origin",
|
|
525
535
|
redirect: "error",
|
|
526
536
|
signal: AbortSignal.any([attempt.signal, AbortSignal.timeout(12e3)])
|
|
@@ -544,34 +554,50 @@ function createSignInController(options) {
|
|
|
544
554
|
setStep("confirm");
|
|
545
555
|
window.history.replaceState(window.history.state, "", `${loginPath}?${new URLSearchParams({ next })}`);
|
|
546
556
|
}
|
|
547
|
-
loadConfig();
|
|
557
|
+
if (!config()) loadConfig();
|
|
558
|
+
if (options.conditionalPasskey && canPasskey()) PublicKeyCredential.isConditionalMediationAvailable?.().then((supported) => {
|
|
559
|
+
if (!controller.signal.aborted) setConditionalReady(supported);
|
|
560
|
+
}).catch(() => void 0);
|
|
548
561
|
const timer = window.setInterval(() => setNow(Date.now()), 1e3);
|
|
549
562
|
onCleanup(() => {
|
|
550
563
|
window.clearInterval(timer);
|
|
551
564
|
confController?.abort();
|
|
565
|
+
stopConditional();
|
|
552
566
|
controller.abort();
|
|
553
567
|
});
|
|
554
568
|
});
|
|
569
|
+
function stopConditional() {
|
|
570
|
+
conditional?.abort();
|
|
571
|
+
conditional = void 0;
|
|
572
|
+
}
|
|
555
573
|
function go(to) {
|
|
574
|
+
if (to !== "choose") stopConditional();
|
|
556
575
|
setErrorCode("");
|
|
557
576
|
setShowPassword(false);
|
|
558
577
|
setStep(to);
|
|
559
578
|
}
|
|
560
|
-
async function post(path, body) {
|
|
579
|
+
async function post(path, body, signal = controller.signal) {
|
|
561
580
|
const res = await fetch(path, {
|
|
562
581
|
method: "POST",
|
|
563
582
|
headers: { "Content-Type": "application/json" },
|
|
564
583
|
referrerPolicy: "origin",
|
|
565
584
|
redirect: "error",
|
|
566
|
-
signal: AbortSignal.any([
|
|
567
|
-
|
|
585
|
+
signal: AbortSignal.any([
|
|
586
|
+
controller.signal,
|
|
587
|
+
signal,
|
|
588
|
+
AbortSignal.timeout(45e3)
|
|
589
|
+
]),
|
|
590
|
+
body: JSON.stringify({
|
|
591
|
+
...body,
|
|
592
|
+
acceptance: options.getAcceptance?.()
|
|
593
|
+
})
|
|
568
594
|
});
|
|
569
595
|
const data = await res.json();
|
|
570
596
|
if (!res.ok) throw new SignInError(isErrorCode(data.error) ? data.error : "unavailable");
|
|
571
597
|
return data;
|
|
572
598
|
}
|
|
573
599
|
async function request(action, fields = {}) {
|
|
574
|
-
const data = await post(
|
|
600
|
+
const data = await post(`${route}/email`, {
|
|
575
601
|
action,
|
|
576
602
|
next,
|
|
577
603
|
...fields
|
|
@@ -581,6 +607,8 @@ function createSignInController(options) {
|
|
|
581
607
|
}
|
|
582
608
|
async function run(label, op) {
|
|
583
609
|
if (busy() || controller.signal.aborted) return;
|
|
610
|
+
attemptedConditional = true;
|
|
611
|
+
stopConditional();
|
|
584
612
|
setBusy(label);
|
|
585
613
|
setErrorCode("");
|
|
586
614
|
try {
|
|
@@ -594,7 +622,7 @@ function createSignInController(options) {
|
|
|
594
622
|
function social(provider) {
|
|
595
623
|
if (!config()?.providers.includes(provider)) return;
|
|
596
624
|
return run(providers[provider][0], async () => {
|
|
597
|
-
const { authorize } = await post(
|
|
625
|
+
const { authorize } = await post(`${route}/start/${provider}`, { next });
|
|
598
626
|
const target = providerDestination(provider, authorize);
|
|
599
627
|
if (!target) throw new Error();
|
|
600
628
|
if (!controller.signal.aborted) window.location.assign(target);
|
|
@@ -627,39 +655,63 @@ function createSignInController(options) {
|
|
|
627
655
|
}
|
|
628
656
|
});
|
|
629
657
|
}
|
|
658
|
+
async function getPasskey(signal, autofill) {
|
|
659
|
+
const { challenge, challengeId, rpId, credentials } = await post(`${route}/email`, {
|
|
660
|
+
action: "passkey_start",
|
|
661
|
+
next
|
|
662
|
+
}, signal);
|
|
663
|
+
if (signal.aborted || !challenge || !challengeId || !rpId || !credentials) return;
|
|
664
|
+
if (autofill && credentials.length) return;
|
|
665
|
+
const assertion = await navigator.credentials.get({
|
|
666
|
+
signal,
|
|
667
|
+
...autofill && { mediation: "conditional" },
|
|
668
|
+
publicKey: {
|
|
669
|
+
challenge: decode(challenge),
|
|
670
|
+
rpId,
|
|
671
|
+
...autofill ? {} : { timeout: 6e4 },
|
|
672
|
+
userVerification: "required",
|
|
673
|
+
allowCredentials: credentials.map((id) => ({
|
|
674
|
+
id: decode(id),
|
|
675
|
+
type: "public-key"
|
|
676
|
+
}))
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
if (signal.aborted || !(assertion instanceof PublicKeyCredential) || !(assertion.response instanceof AuthenticatorAssertionResponse)) return;
|
|
680
|
+
const response = assertion.response;
|
|
681
|
+
return {
|
|
682
|
+
challenge_id: challengeId,
|
|
683
|
+
credential_id: encode(assertion.rawId),
|
|
684
|
+
client_data_json: encode(response.clientDataJSON),
|
|
685
|
+
authenticator_data: encode(response.authenticatorData),
|
|
686
|
+
signature: encode(response.signature),
|
|
687
|
+
user_handle: response.userHandle ? encode(response.userHandle) : ""
|
|
688
|
+
};
|
|
689
|
+
}
|
|
630
690
|
function passkey() {
|
|
631
691
|
if (!canPasskey() || !config()?.passkey) return;
|
|
632
692
|
return run("passkey", async () => {
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
const assertion = await navigator.credentials.get({
|
|
636
|
-
signal: controller.signal,
|
|
637
|
-
publicKey: {
|
|
638
|
-
challenge: decode(challenge),
|
|
639
|
-
rpId,
|
|
640
|
-
timeout: 6e4,
|
|
641
|
-
userVerification: "required",
|
|
642
|
-
allowCredentials: credentials.map((id) => ({
|
|
643
|
-
id: decode(id),
|
|
644
|
-
type: "public-key"
|
|
645
|
-
}))
|
|
646
|
-
}
|
|
647
|
-
}).catch((error) => {
|
|
648
|
-
if (error instanceof DOMException && error.name === "NotAllowedError") return null;
|
|
693
|
+
const fields = await getPasskey(controller.signal, false).catch((error) => {
|
|
694
|
+
if (error instanceof DOMException && error.name === "NotAllowedError") return;
|
|
649
695
|
throw error;
|
|
650
696
|
});
|
|
651
|
-
if (!
|
|
652
|
-
|
|
653
|
-
await request("passkey_verify", {
|
|
654
|
-
challenge_id: challengeId,
|
|
655
|
-
credential_id: encode(assertion.rawId),
|
|
656
|
-
client_data_json: encode(response.clientDataJSON),
|
|
657
|
-
authenticator_data: encode(response.authenticatorData),
|
|
658
|
-
signature: encode(response.signature),
|
|
659
|
-
user_handle: response.userHandle ? encode(response.userHandle) : ""
|
|
660
|
-
});
|
|
697
|
+
if (!fields) throw new SignInError("method_unavailable");
|
|
698
|
+
await request("passkey_verify", fields);
|
|
661
699
|
});
|
|
662
700
|
}
|
|
701
|
+
createEffect(() => {
|
|
702
|
+
if (attemptedConditional || !conditionalReady() || step() !== "choose" || !config()?.passkey) return;
|
|
703
|
+
if (options.getAcceptance && !options.getAcceptance()) return;
|
|
704
|
+
attemptedConditional = true;
|
|
705
|
+
const attempt = new AbortController();
|
|
706
|
+
conditional = attempt;
|
|
707
|
+
getPasskey(attempt.signal, true).then((fields) => {
|
|
708
|
+
if (fields && !attempt.signal.aborted && !controller.signal.aborted) return run("passkey", async () => {
|
|
709
|
+
await request("passkey_verify", fields);
|
|
710
|
+
});
|
|
711
|
+
}).catch(() => void 0).finally(() => {
|
|
712
|
+
if (conditional === attempt) conditional = void 0;
|
|
713
|
+
});
|
|
714
|
+
});
|
|
663
715
|
function continueWithEmail() {
|
|
664
716
|
if (config()?.otp) return sendCode();
|
|
665
717
|
if (config()?.password && !busy()) go("password");
|
|
@@ -709,6 +761,7 @@ function createSignInController(options) {
|
|
|
709
761
|
});
|
|
710
762
|
}
|
|
711
763
|
return {
|
|
764
|
+
emailRoute: `${route}/email`,
|
|
712
765
|
config,
|
|
713
766
|
configFailed,
|
|
714
767
|
loadConfig,
|
|
@@ -755,12 +808,13 @@ var _tmpl$3 = [
|
|
|
755
808
|
];
|
|
756
809
|
var _tmpl$4 = [
|
|
757
810
|
"<input",
|
|
758
|
-
" type=\"email\" name=\"username\"
|
|
811
|
+
" type=\"email\" name=\"username\"",
|
|
812
|
+
" required maxlength=\"254\"",
|
|
759
813
|
">"
|
|
760
814
|
];
|
|
761
815
|
var _tmpl$5 = [
|
|
762
816
|
"<form",
|
|
763
|
-
" method=\"post\"
|
|
817
|
+
" method=\"post\"",
|
|
764
818
|
"><!--$-->",
|
|
765
819
|
"<!--/--><label",
|
|
766
820
|
">",
|
|
@@ -791,7 +845,7 @@ var _tmpl$7 = [
|
|
|
791
845
|
];
|
|
792
846
|
var _tmpl$8 = [
|
|
793
847
|
"<form",
|
|
794
|
-
" method=\"post\"
|
|
848
|
+
" method=\"post\"",
|
|
795
849
|
"><label",
|
|
796
850
|
">",
|
|
797
851
|
"</label><div",
|
|
@@ -818,7 +872,7 @@ var _tmpl$9 = [
|
|
|
818
872
|
];
|
|
819
873
|
var _tmpl$0 = [
|
|
820
874
|
"<form",
|
|
821
|
-
" method=\"post\"
|
|
875
|
+
" method=\"post\"",
|
|
822
876
|
"><label",
|
|
823
877
|
">",
|
|
824
878
|
"</label><input",
|
|
@@ -873,11 +927,12 @@ var _tmpl$13 = [
|
|
|
873
927
|
];
|
|
874
928
|
var _tmpl$14 = [
|
|
875
929
|
"<form",
|
|
876
|
-
" method=\"post\"
|
|
930
|
+
" method=\"post\"",
|
|
877
931
|
"><label",
|
|
878
932
|
">",
|
|
879
933
|
"</label><input",
|
|
880
|
-
" type=\"email\" name=\"email\"
|
|
934
|
+
" type=\"email\" name=\"email\"",
|
|
935
|
+
" required maxlength=\"254\"",
|
|
881
936
|
"><button type=\"submit\"",
|
|
882
937
|
"",
|
|
883
938
|
">",
|
|
@@ -902,7 +957,7 @@ var _tmpl$16 = [
|
|
|
902
957
|
var _tmpl$17 = [
|
|
903
958
|
"<input",
|
|
904
959
|
" tabindex=\"-1\" hidden name=\"username\"",
|
|
905
|
-
"
|
|
960
|
+
" readonly>"
|
|
906
961
|
];
|
|
907
962
|
var _tmpl$18 = [
|
|
908
963
|
"<span",
|
|
@@ -924,7 +979,7 @@ var icons = {
|
|
|
924
979
|
microsoft: MicrosoftIcon
|
|
925
980
|
};
|
|
926
981
|
function SylphxSignIn(props) {
|
|
927
|
-
const { config, configFailed, loadConfig, step, email, setEmail, errorCode, busy, showPassword, setShowPassword, canPasskey, code, setCode, recovery, setRecovery, wait, continueWithEmail, social, sendCode, verifyCode, passkey, submitPassword, submitMfa } = createSignInController(props);
|
|
982
|
+
const { emailRoute, config, configFailed, loadConfig, step, email, setEmail, errorCode, busy, showPassword, setShowPassword, canPasskey, code, setCode, recovery, setRecovery, wait, continueWithEmail, social, sendCode, verifyCode, passkey, submitPassword, submitMfa } = createSignInController(props);
|
|
928
983
|
const [detected, setDetected] = createSignal();
|
|
929
984
|
const [selected, setSelected] = createSignal();
|
|
930
985
|
const locale = createMemo(() => props.locale === void 0 ? selected() ?? detected() ?? resolveAuthLocale(props.localePreferences ?? []) : resolveAuthLocale([props.locale, ...props.localePreferences ?? []]));
|
|
@@ -1020,7 +1075,7 @@ function SylphxSignIn(props) {
|
|
|
1020
1075
|
get children() {
|
|
1021
1076
|
return ssr(_tmpl$13, ssrHydrationKey() + ssrAttribute("class", escape(className("divider"), true), false), escape(text().orEmail));
|
|
1022
1077
|
}
|
|
1023
|
-
}), ssr(_tmpl$14, ssrHydrationKey(), ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("email"), true), false), escape(text().email), ssrAttribute("id", escape(id("email"), true), false), ssrAttribute("value", escape(email(), true), false), ssrAttribute("class", escape(className("primary"), true), false), ssrAttribute("disabled", !!busy(), true), busy() === "email" ? escape(text().sendingCode) : methods().otp ? escape(text().emailCodeAction) : escape(text().continueEmail))];
|
|
1078
|
+
}), ssr(_tmpl$14, ssrHydrationKey(), ssrAttribute("action", escape(emailRoute, true), false) + ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("email"), true), false), escape(text().email), ssrAttribute("id", escape(id("email"), true), false), ssrAttribute("autocomplete", config()?.passkey ? "username webauthn" : "username", false), ssrAttribute("value", escape(email(), true), false), ssrAttribute("class", escape(className("primary"), true), false), ssrAttribute("disabled", !!busy(), true), busy() === "email" ? escape(text().sendingCode) : methods().otp ? escape(text().emailCodeAction) : escape(text().continueEmail))];
|
|
1024
1079
|
}
|
|
1025
1080
|
}),
|
|
1026
1081
|
createComponent(Show, {
|
|
@@ -1056,15 +1111,15 @@ function SylphxSignIn(props) {
|
|
|
1056
1111
|
return step() === "password" || step() === "signup" || step() === "confirm";
|
|
1057
1112
|
},
|
|
1058
1113
|
get children() {
|
|
1059
|
-
return [ssr(_tmpl$5, ssrHydrationKey(), ssrAttribute("class", escape(className("form"), true), false), escape(createComponent(Show, {
|
|
1114
|
+
return [ssr(_tmpl$5, ssrHydrationKey(), ssrAttribute("action", escape(emailRoute, true), false) + ssrAttribute("class", escape(className("form"), true), false), escape(createComponent(Show, {
|
|
1060
1115
|
get when() {
|
|
1061
1116
|
return step() !== "password";
|
|
1062
1117
|
},
|
|
1063
1118
|
get fallback() {
|
|
1064
|
-
return ssr(_tmpl$17, ssrHydrationKey(), ssrAttribute("value", escape(email(), true), false));
|
|
1119
|
+
return ssr(_tmpl$17, ssrHydrationKey(), ssrAttribute("value", escape(email(), true), false) + ssrAttribute("autocomplete", config()?.passkey ? "username webauthn" : "username", false));
|
|
1065
1120
|
},
|
|
1066
1121
|
get children() {
|
|
1067
|
-
return [ssr(_tmpl$3, ssrHydrationKey() + ssrAttribute("for", escape(id("account-email"), true), false), escape(text().email)), ssr(_tmpl$4, ssrHydrationKey() + ssrAttribute("id", escape(id("account-email"), true), false), ssrAttribute("value", escape(email(), true), false))];
|
|
1122
|
+
return [ssr(_tmpl$3, ssrHydrationKey() + ssrAttribute("for", escape(id("account-email"), true), false), escape(text().email)), ssr(_tmpl$4, ssrHydrationKey() + ssrAttribute("id", escape(id("account-email"), true), false), ssrAttribute("autocomplete", config()?.passkey ? "username webauthn" : "username", false), ssrAttribute("value", escape(email(), true), false))];
|
|
1068
1123
|
}
|
|
1069
1124
|
})), ssrAttribute("for", escape(id("password"), true), false), escape(text().password), ssrAttribute("class", escape(className("password"), true), false), ssrAttribute("id", escape(id("password"), true), false) + ssrAttribute("type", showPassword() ? "text" : "password", false) + ssrAttribute("autocomplete", step() === "signup" ? "new-password" : "current-password", false), ssrAttribute("minlength", step() === "signup" ? 12 : escape(void 0, true), false), ssrAttribute("aria-describedby", step() === "signup" ? escape(id("password-hint"), true) : escape(void 0, true), false), ssrAttribute("class", escape(className("link"), true), false) + ssrAttribute("aria-label", showPassword() ? escape(text().hidePassword, true) : escape(text().showPassword, true), false), showPassword() ? escape(text().hide) : escape(text().show), escape(createComponent(Show, {
|
|
1070
1125
|
get when() {
|
|
@@ -1089,7 +1144,7 @@ function SylphxSignIn(props) {
|
|
|
1089
1144
|
return step() === "otp";
|
|
1090
1145
|
},
|
|
1091
1146
|
get children() {
|
|
1092
|
-
return [ssr(_tmpl$8, ssrHydrationKey(), ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("code"), true), false), escape(text().emailCode), ssrAttribute("class", escape(className("otp"), true), false), ssrAttribute("id", escape(id("code"), true), false), ssrAttribute("value", escape(code(), true), false), ssrAttribute("readonly", !!busy(), true), ssrAttribute("class", escape(className("cells"), true), false), escape(createComponent(For, {
|
|
1147
|
+
return [ssr(_tmpl$8, ssrHydrationKey(), ssrAttribute("action", escape(emailRoute, true), false) + ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("code"), true), false), escape(text().emailCode), ssrAttribute("class", escape(className("otp"), true), false), ssrAttribute("id", escape(id("code"), true), false), ssrAttribute("value", escape(code(), true), false), ssrAttribute("readonly", !!busy(), true), ssrAttribute("class", escape(className("cells"), true), false), escape(createComponent(For, {
|
|
1093
1148
|
each: [
|
|
1094
1149
|
0,
|
|
1095
1150
|
1,
|
|
@@ -1114,7 +1169,7 @@ function SylphxSignIn(props) {
|
|
|
1114
1169
|
return step() === "mfa";
|
|
1115
1170
|
},
|
|
1116
1171
|
get children() {
|
|
1117
|
-
return [ssr(_tmpl$0, ssrHydrationKey(), ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("mfa"), true), false), recovery() ? escape(text().recoveryCode) : escape(text().authenticatorCode), ssrAttribute("id", escape(id("mfa"), true), false), ssrAttribute("inputmode", recovery() ? "text" : "numeric", false), ssrAttribute("maxlength", recovery() ? 128 : 6, false), ssrAttribute("class", escape(className("primary"), true), false), ssrAttribute("disabled", !!busy(), true), busy() ? escape(text().checkingCode) : escape(text().verifyAndSignIn)), ssr(_tmpl$1, ssrHydrationKey() + ssrAttribute("class", escape(className("actions"), true), false), ssrAttribute("disabled", !!busy(), true) + ssrAttribute("class", escape(className("link"), true), false), recovery() ? escape(text().useAuthenticator) : escape(text().useRecovery), ssrAttribute("disabled", !!busy(), true) + ssrAttribute("class", escape(className("link"), true), false), escape(text().backToSignIn))];
|
|
1172
|
+
return [ssr(_tmpl$0, ssrHydrationKey(), ssrAttribute("action", escape(emailRoute, true), false) + ssrAttribute("class", escape(className("form"), true), false), ssrAttribute("for", escape(id("mfa"), true), false), recovery() ? escape(text().recoveryCode) : escape(text().authenticatorCode), ssrAttribute("id", escape(id("mfa"), true), false), ssrAttribute("inputmode", recovery() ? "text" : "numeric", false), ssrAttribute("maxlength", recovery() ? 128 : 6, false), ssrAttribute("class", escape(className("primary"), true), false), ssrAttribute("disabled", !!busy(), true), busy() ? escape(text().checkingCode) : escape(text().verifyAndSignIn)), ssr(_tmpl$1, ssrHydrationKey() + ssrAttribute("class", escape(className("actions"), true), false), ssrAttribute("disabled", !!busy(), true) + ssrAttribute("class", escape(className("link"), true), false), recovery() ? escape(text().useAuthenticator) : escape(text().useRecovery), ssrAttribute("disabled", !!busy(), true) + ssrAttribute("class", escape(className("link"), true), false), escape(text().backToSignIn))];
|
|
1118
1173
|
}
|
|
1119
1174
|
})
|
|
1120
1175
|
];
|
|
@@ -4,6 +4,7 @@ declare const errors: {
|
|
|
4
4
|
cancelled: string;
|
|
5
5
|
use_existing: string;
|
|
6
6
|
invalid_credentials: string;
|
|
7
|
+
acceptance_required: string;
|
|
7
8
|
verify_email: string;
|
|
8
9
|
verification_failed: string;
|
|
9
10
|
invalid_code: string;
|
|
@@ -23,9 +24,18 @@ export type SignInControllerOptions = {
|
|
|
23
24
|
search: string;
|
|
24
25
|
/** The same-origin login pathname, used to scrub a confirmation link. */
|
|
25
26
|
loginPath?: string;
|
|
27
|
+
/** Public methods loaded by the host on the server, reused on hydration. */
|
|
28
|
+
initialConfig?: EntryConfig;
|
|
29
|
+
/** Same-origin pathname, defaults to /auth. */
|
|
30
|
+
routePrefix?: string;
|
|
31
|
+
/** Start a discoverable WebAuthn request once on the sign-in screen. */
|
|
32
|
+
conditionalPasskey?: boolean;
|
|
33
|
+
/** Return only versions the user has accepted; undefined means no acceptance. */
|
|
34
|
+
getAcceptance?: () => Readonly<Record<string, string>> | undefined;
|
|
26
35
|
};
|
|
27
36
|
/** Create under a Solid owner. Requests start on mount and abort on cleanup. */
|
|
28
37
|
export declare function createSignInController(options: SignInControllerOptions): {
|
|
38
|
+
emailRoute: string;
|
|
29
39
|
config: import("solid-js").Accessor<EntryConfig | undefined>;
|
|
30
40
|
configFailed: import("solid-js").Accessor<boolean>;
|
|
31
41
|
loadConfig: () => Promise<void>;
|
|
@@ -34,7 +44,7 @@ export declare function createSignInController(options: SignInControllerOptions)
|
|
|
34
44
|
email: import("solid-js").Accessor<string>;
|
|
35
45
|
setEmail: import("solid-js").Setter<string>;
|
|
36
46
|
error: () => string;
|
|
37
|
-
errorCode: import("solid-js").Accessor<"" | "signin" | "cancelled" | "use_existing" | "invalid_credentials" | "verify_email" | "verification_failed" | "invalid_code" | "method_unavailable" | "signup_failed" | "invalid_input" | "try_later" | "unavailable">;
|
|
47
|
+
errorCode: import("solid-js").Accessor<"" | "signin" | "cancelled" | "use_existing" | "invalid_credentials" | "acceptance_required" | "verify_email" | "verification_failed" | "invalid_code" | "method_unavailable" | "signup_failed" | "invalid_input" | "try_later" | "unavailable">;
|
|
38
48
|
busy: import("solid-js").Accessor<string>;
|
|
39
49
|
showPassword: import("solid-js").Accessor<boolean>;
|
|
40
50
|
setShowPassword: import("solid-js").Setter<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sylphx/auth-solid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"build": "tsc -p tsconfig.build.json && node build.mjs"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@sylphx/auth": "0.1.
|
|
23
|
+
"@sylphx/auth": "0.1.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"solid-js": "^1.9.20"
|