@orangecheck/auth-client 2.43.0 → 2.43.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/dist/{chunk-66IUQ2ZP.mjs → chunk-Z6WLEPHB.mjs} +77 -18
- package/dist/chunk-Z6WLEPHB.mjs.map +1 -0
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/signin.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-66IUQ2ZP.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2411,6 +2411,8 @@ var SIGNIN_ERRORS = {
|
|
|
2411
2411
|
audience_mismatch: "That request didn't match this site. Reload the page and try again.",
|
|
2412
2412
|
purpose_mismatch: "That request didn't match. Try again for a fresh one.",
|
|
2413
2413
|
malformed: "That signature couldn't be read. Copy it again, whole.",
|
|
2414
|
+
challenge_mismatch: "That sign-in message changed after it was issued. Get a new one and sign it again.",
|
|
2415
|
+
mainnet_only: "Sign in with a mainnet Bitcoin address.",
|
|
2414
2416
|
cross_site_blocked: "Your browser blocked this request. Reload the page and try again.",
|
|
2415
2417
|
rate_limited: "Too many tries. Wait a minute, then try again.",
|
|
2416
2418
|
invalid_email: "That email address doesn't look right.",
|
|
@@ -2964,11 +2966,14 @@ function WalletFlow({
|
|
|
2964
2966
|
address: `${uid}-address`,
|
|
2965
2967
|
wallet: `${uid}-wallet`,
|
|
2966
2968
|
message: `${uid}-message`,
|
|
2967
|
-
signature: `${uid}-signature
|
|
2969
|
+
signature: `${uid}-signature`,
|
|
2970
|
+
prompt: `${uid}-prompt`,
|
|
2971
|
+
error: `${uid}-error`
|
|
2968
2972
|
};
|
|
2969
2973
|
const [address, setAddress] = React4__namespace.useState("");
|
|
2970
2974
|
const [error, setError] = React4__namespace.useState(null);
|
|
2971
2975
|
const [submitting, setSubmitting] = React4__namespace.useState(false);
|
|
2976
|
+
const [back, setBack] = React4__namespace.useState(false);
|
|
2972
2977
|
const [wallets, setWallets] = React4__namespace.useState(null);
|
|
2973
2978
|
const [walletId, setWalletId] = React4__namespace.useState(null);
|
|
2974
2979
|
const [manual, setManual] = React4__namespace.useState(null);
|
|
@@ -3022,6 +3027,7 @@ function WalletFlow({
|
|
|
3022
3027
|
}
|
|
3023
3028
|
async function signIn(e) {
|
|
3024
3029
|
e.preventDefault();
|
|
3030
|
+
if (submitting) return;
|
|
3025
3031
|
const addr = address.trim();
|
|
3026
3032
|
if (!addr) {
|
|
3027
3033
|
setError("Paste your Bitcoin address.");
|
|
@@ -3066,7 +3072,7 @@ function WalletFlow({
|
|
|
3066
3072
|
}
|
|
3067
3073
|
async function signInManual(e) {
|
|
3068
3074
|
e.preventDefault();
|
|
3069
|
-
if (!manual) return;
|
|
3075
|
+
if (!manual || submitting) return;
|
|
3070
3076
|
const sig = pasted.trim();
|
|
3071
3077
|
if (!sig) {
|
|
3072
3078
|
setError("Paste the signature your wallet gave you.");
|
|
@@ -3092,7 +3098,7 @@ function WalletFlow({
|
|
|
3092
3098
|
}
|
|
3093
3099
|
if (manual) {
|
|
3094
3100
|
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: signInManual, "data-oc-signin-wallet-manual": "", children: [
|
|
3095
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FlowHeader, { children: [
|
|
3101
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FlowHeader, { id: ids.prompt, children: [
|
|
3096
3102
|
"In your wallet, use \u201Csign message\u201D (BIP-322) with ",
|
|
3097
3103
|
address.trim(),
|
|
3098
3104
|
", sign the text below, and paste the signature back here. Nothing is spent."
|
|
@@ -3129,25 +3135,29 @@ function WalletFlow({
|
|
|
3129
3135
|
spellCheck: false,
|
|
3130
3136
|
autoFocus: true,
|
|
3131
3137
|
"aria-invalid": error ? true : void 0,
|
|
3138
|
+
"aria-describedby": describedBy(ids.prompt, ids.message, error && ids.error),
|
|
3132
3139
|
style: { ...inputStyle2, resize: "vertical" }
|
|
3133
3140
|
}
|
|
3134
3141
|
)
|
|
3135
3142
|
] }),
|
|
3136
|
-
error && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { children: error }),
|
|
3143
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { id: ids.error, children: error }),
|
|
3137
3144
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3138
3145
|
"button",
|
|
3139
3146
|
{
|
|
3140
3147
|
type: "submit",
|
|
3141
|
-
disabled:
|
|
3148
|
+
disabled: !pasted.trim(),
|
|
3149
|
+
"aria-disabled": submitting || void 0,
|
|
3142
3150
|
style: submitStyle(submitting || !pasted.trim()),
|
|
3143
3151
|
children: submitting ? "Checking\u2026" : /* @__PURE__ */ jsxRuntime.jsx(Submit, { children: "Sign me in" })
|
|
3144
3152
|
}
|
|
3145
3153
|
),
|
|
3154
|
+
/* @__PURE__ */ jsxRuntime.jsx(Busy, { children: submitting ? "Checking\u2026" : null }),
|
|
3146
3155
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3147
3156
|
"button",
|
|
3148
3157
|
{
|
|
3149
3158
|
type: "button",
|
|
3150
3159
|
onClick: () => {
|
|
3160
|
+
setBack(true);
|
|
3151
3161
|
setManual(null);
|
|
3152
3162
|
setPasted("");
|
|
3153
3163
|
setError(null);
|
|
@@ -3179,7 +3189,9 @@ function WalletFlow({
|
|
|
3179
3189
|
autoCapitalize: "none",
|
|
3180
3190
|
spellCheck: false,
|
|
3181
3191
|
required: true,
|
|
3192
|
+
autoFocus: back,
|
|
3182
3193
|
"aria-invalid": error ? true : void 0,
|
|
3194
|
+
"aria-describedby": describedBy(error && ids.error),
|
|
3183
3195
|
style: inputStyle2
|
|
3184
3196
|
}
|
|
3185
3197
|
),
|
|
@@ -3196,16 +3208,18 @@ function WalletFlow({
|
|
|
3196
3208
|
}
|
|
3197
3209
|
)
|
|
3198
3210
|
] }),
|
|
3199
|
-
error && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { children: error }),
|
|
3211
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { id: ids.error, children: error }),
|
|
3200
3212
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3201
3213
|
"button",
|
|
3202
3214
|
{
|
|
3203
3215
|
type: "submit",
|
|
3204
|
-
disabled:
|
|
3216
|
+
disabled: !address.trim(),
|
|
3217
|
+
"aria-disabled": submitting || void 0,
|
|
3205
3218
|
style: submitStyle(submitting || !address.trim()),
|
|
3206
3219
|
children: submitting ? "Waiting for wallet\u2026" : noBrowserWallet ? /* @__PURE__ */ jsxRuntime.jsx(Submit, { children: "Get the message to sign" }) : /* @__PURE__ */ jsxRuntime.jsx(Submit, { children: "Sign in with wallet" })
|
|
3207
3220
|
}
|
|
3208
3221
|
),
|
|
3222
|
+
/* @__PURE__ */ jsxRuntime.jsx(Busy, { children: submitting ? "Waiting for wallet\u2026" : null }),
|
|
3209
3223
|
noBrowserWallet && /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: "No browser wallet found here. You can sign with any wallet and paste." })
|
|
3210
3224
|
] });
|
|
3211
3225
|
}
|
|
@@ -3219,6 +3233,8 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3219
3233
|
const [token, setToken] = React4__namespace.useState(null);
|
|
3220
3234
|
const [submitting, setSubmitting] = React4__namespace.useState(false);
|
|
3221
3235
|
const [resent, setResent] = React4__namespace.useState(false);
|
|
3236
|
+
const [back, setBack] = React4__namespace.useState(false);
|
|
3237
|
+
const ids = { emailError: `${uid}-email-error`, codeError: `${uid}-code-error` };
|
|
3222
3238
|
async function sendCode(address) {
|
|
3223
3239
|
try {
|
|
3224
3240
|
const res = await fetch(`${authOrigin}/api/auth/email-otp/start`, {
|
|
@@ -3238,6 +3254,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3238
3254
|
}
|
|
3239
3255
|
async function start(e) {
|
|
3240
3256
|
e.preventDefault();
|
|
3257
|
+
if (submitting) return;
|
|
3241
3258
|
const trimmed = identifiers.normalizeEmail(email);
|
|
3242
3259
|
if (!trimmed || !/.+@.+\..+/.test(trimmed)) {
|
|
3243
3260
|
setEmailError(humanSigninError("invalid_email", "email"));
|
|
@@ -3255,6 +3272,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3255
3272
|
setStage("code");
|
|
3256
3273
|
}
|
|
3257
3274
|
async function resend() {
|
|
3275
|
+
if (submitting) return;
|
|
3258
3276
|
setCodeError(null);
|
|
3259
3277
|
setResent(false);
|
|
3260
3278
|
setSubmitting(true);
|
|
@@ -3266,7 +3284,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3266
3284
|
}
|
|
3267
3285
|
async function verify(e) {
|
|
3268
3286
|
e.preventDefault();
|
|
3269
|
-
if (!token) return;
|
|
3287
|
+
if (!token || submitting) return;
|
|
3270
3288
|
if (code.length !== 6) {
|
|
3271
3289
|
setCodeError("The code is 6 digits.");
|
|
3272
3290
|
return;
|
|
@@ -3298,7 +3316,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3298
3316
|
}
|
|
3299
3317
|
}
|
|
3300
3318
|
if (stage === "enter") {
|
|
3301
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: start, "data-oc-signin-email": "", children: [
|
|
3319
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: start, noValidate: true, "data-oc-signin-email": "", children: [
|
|
3302
3320
|
/* @__PURE__ */ jsxRuntime.jsx(FlowHeader, { children: "We email you a 6-digit code. No password, and no wallet needed to start. Add a Bitcoin address any time: a way in that only you hold." }),
|
|
3303
3321
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${uid}-email`, children: "Email" }),
|
|
3304
3322
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3315,13 +3333,24 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3315
3333
|
},
|
|
3316
3334
|
placeholder: "you@example.com",
|
|
3317
3335
|
required: true,
|
|
3336
|
+
autoFocus: back,
|
|
3318
3337
|
"aria-invalid": emailError ? true : void 0,
|
|
3338
|
+
"aria-describedby": describedBy(emailError && ids.emailError),
|
|
3319
3339
|
style: inputStyle2
|
|
3320
3340
|
}
|
|
3321
3341
|
),
|
|
3322
|
-
emailError && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { children: emailError }),
|
|
3323
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3324
|
-
|
|
3342
|
+
emailError && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { id: ids.emailError, children: emailError }),
|
|
3343
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3344
|
+
"button",
|
|
3345
|
+
{
|
|
3346
|
+
type: "submit",
|
|
3347
|
+
"aria-disabled": submitting || void 0,
|
|
3348
|
+
style: submitStyle(submitting),
|
|
3349
|
+
children: submitting ? "Sending\u2026" : /* @__PURE__ */ jsxRuntime.jsx(Submit, { children: "Send one-time code" })
|
|
3350
|
+
}
|
|
3351
|
+
),
|
|
3352
|
+
/* @__PURE__ */ jsxRuntime.jsx(Busy, { children: submitting ? "Sending\u2026" : null })
|
|
3353
|
+
] }, "enter");
|
|
3325
3354
|
}
|
|
3326
3355
|
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: verify, "data-oc-signin-email-verify": "", children: [
|
|
3327
3356
|
/* @__PURE__ */ jsxRuntime.jsxs(FlowHeader, { children: [
|
|
@@ -3349,26 +3378,29 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3349
3378
|
required: true,
|
|
3350
3379
|
autoFocus: true,
|
|
3351
3380
|
"aria-invalid": codeError ? true : void 0,
|
|
3381
|
+
"aria-describedby": describedBy(codeError && ids.codeError),
|
|
3352
3382
|
style: { ...inputStyle2, letterSpacing: "0.4em", fontSize: 16 }
|
|
3353
3383
|
}
|
|
3354
3384
|
),
|
|
3355
|
-
codeError && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { children: codeError }),
|
|
3385
|
+
codeError && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine2, { id: ids.codeError, children: codeError }),
|
|
3356
3386
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3357
3387
|
"button",
|
|
3358
3388
|
{
|
|
3359
3389
|
type: "submit",
|
|
3360
|
-
disabled:
|
|
3390
|
+
disabled: code.length !== 6,
|
|
3391
|
+
"aria-disabled": submitting || void 0,
|
|
3361
3392
|
style: submitStyle(submitting || code.length !== 6),
|
|
3362
3393
|
children: submitting ? "Verifying\u2026" : /* @__PURE__ */ jsxRuntime.jsx(Submit, { children: "Verify \xB7 sign me in" })
|
|
3363
3394
|
}
|
|
3364
3395
|
),
|
|
3396
|
+
/* @__PURE__ */ jsxRuntime.jsx(Busy, { children: submitting ? "Verifying\u2026" : null }),
|
|
3365
3397
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3366
3398
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3367
3399
|
"button",
|
|
3368
3400
|
{
|
|
3369
3401
|
type: "button",
|
|
3370
3402
|
onClick: () => void resend(),
|
|
3371
|
-
disabled: submitting,
|
|
3403
|
+
"aria-disabled": submitting || void 0,
|
|
3372
3404
|
style: linkButtonStyle,
|
|
3373
3405
|
children: "Send a new code"
|
|
3374
3406
|
}
|
|
@@ -3378,6 +3410,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3378
3410
|
{
|
|
3379
3411
|
type: "button",
|
|
3380
3412
|
onClick: () => {
|
|
3413
|
+
setBack(true);
|
|
3381
3414
|
setStage("enter");
|
|
3382
3415
|
setCode("");
|
|
3383
3416
|
setToken(null);
|
|
@@ -3388,7 +3421,7 @@ function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
|
3388
3421
|
}
|
|
3389
3422
|
)
|
|
3390
3423
|
] })
|
|
3391
|
-
] });
|
|
3424
|
+
] }, "code");
|
|
3392
3425
|
}
|
|
3393
3426
|
function Submit({ children }) {
|
|
3394
3427
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -3397,6 +3430,7 @@ function Submit({ children }) {
|
|
|
3397
3430
|
] });
|
|
3398
3431
|
}
|
|
3399
3432
|
function FlowHeader({
|
|
3433
|
+
id,
|
|
3400
3434
|
label,
|
|
3401
3435
|
children
|
|
3402
3436
|
}) {
|
|
@@ -3418,6 +3452,7 @@ function FlowHeader({
|
|
|
3418
3452
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3419
3453
|
"p",
|
|
3420
3454
|
{
|
|
3455
|
+
id,
|
|
3421
3456
|
style: {
|
|
3422
3457
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
3423
3458
|
fontSize: signinRoleSize("text", "13px"),
|
|
@@ -3518,10 +3553,11 @@ function submitStyle(disabled) {
|
|
|
3518
3553
|
width: "100%"
|
|
3519
3554
|
};
|
|
3520
3555
|
}
|
|
3521
|
-
function ErrorLine2({ children }) {
|
|
3556
|
+
function ErrorLine2({ id, children }) {
|
|
3522
3557
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3523
3558
|
"p",
|
|
3524
3559
|
{
|
|
3560
|
+
id,
|
|
3525
3561
|
role: "alert",
|
|
3526
3562
|
style: {
|
|
3527
3563
|
marginTop: 6,
|
|
@@ -3535,6 +3571,29 @@ function ErrorLine2({ children }) {
|
|
|
3535
3571
|
}
|
|
3536
3572
|
);
|
|
3537
3573
|
}
|
|
3574
|
+
function describedBy(...ids) {
|
|
3575
|
+
return ids.filter(Boolean).join(" ") || void 0;
|
|
3576
|
+
}
|
|
3577
|
+
function Busy({ children }) {
|
|
3578
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3579
|
+
"span",
|
|
3580
|
+
{
|
|
3581
|
+
role: "status",
|
|
3582
|
+
style: {
|
|
3583
|
+
position: "absolute",
|
|
3584
|
+
width: 1,
|
|
3585
|
+
height: 1,
|
|
3586
|
+
margin: -1,
|
|
3587
|
+
padding: 0,
|
|
3588
|
+
overflow: "hidden",
|
|
3589
|
+
clip: "rect(0 0 0 0)",
|
|
3590
|
+
whiteSpace: "nowrap",
|
|
3591
|
+
border: 0
|
|
3592
|
+
},
|
|
3593
|
+
children: children ?? ""
|
|
3594
|
+
}
|
|
3595
|
+
);
|
|
3596
|
+
}
|
|
3538
3597
|
function Hint({ children }) {
|
|
3539
3598
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3540
3599
|
"p",
|