@orangecheck/auth-client 2.43.0 → 2.43.1

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