@orangecheck/auth-client 2.51.0 → 2.53.0
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/bond.mjs +3 -3
- package/dist/{chunk-F3QPJLWF.mjs → chunk-2FBI2M6N.mjs} +215 -37
- package/dist/chunk-2FBI2M6N.mjs.map +1 -0
- package/dist/{chunk-XVLOTOCX.mjs → chunk-6UIOGWHT.mjs} +96 -4
- package/dist/chunk-6UIOGWHT.mjs.map +1 -0
- package/dist/{chunk-IKNAIRW5.mjs → chunk-FDN374RW.mjs} +2 -2
- package/dist/{chunk-OKIFTNEO.mjs → chunk-HQ6APBHF.mjs} +8 -2
- package/dist/{chunk-OKIFTNEO.mjs.map → chunk-HQ6APBHF.mjs.map} +1 -1
- package/dist/{chunk-VU4DDRCO.mjs → chunk-LKYBT4Q7.mjs} +2 -2
- package/dist/chunk-QHZ6E64O.mjs +61 -0
- package/dist/chunk-QHZ6E64O.mjs.map +1 -0
- package/dist/{chunk-OI64DUVC.mjs → chunk-W6YYHOYL.mjs} +2 -2
- package/dist/{chunk-MIBVEZLP.mjs → chunk-XVYFEBMR.mjs} +4 -3
- package/dist/{chunk-MIBVEZLP.mjs.map → chunk-XVYFEBMR.mjs.map} +1 -1
- package/dist/components.mjs +5 -3
- package/dist/index.d.ts +35 -2
- package/dist/index.js +354 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/linked-identities.mjs +2 -2
- package/dist/passkey.mjs +9 -0
- package/dist/passkey.mjs.map +1 -0
- package/dist/provider.mjs +2 -2
- package/dist/refusal.mjs +1 -1
- package/dist/signin.mjs +5 -4
- package/dist/webauthn.mjs +6 -3
- package/package.json +3 -3
- package/dist/chunk-F3QPJLWF.mjs.map +0 -1
- package/dist/chunk-XVLOTOCX.mjs.map +0 -1
- /package/dist/{chunk-IKNAIRW5.mjs.map → chunk-FDN374RW.mjs.map} +0 -0
- /package/dist/{chunk-VU4DDRCO.mjs.map → chunk-LKYBT4Q7.mjs.map} +0 -0
- /package/dist/{chunk-OI64DUVC.mjs.map → chunk-W6YYHOYL.mjs.map} +0 -0
package/dist/bond.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
bondFloorsText,
|
|
5
5
|
bondRefusal,
|
|
6
6
|
fetchOcBond
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-LKYBT4Q7.mjs";
|
|
8
|
+
import "./chunk-W6YYHOYL.mjs";
|
|
9
9
|
import "./chunk-FNGBJD4S.mjs";
|
|
10
10
|
import "./chunk-U7IUGDLW.mjs";
|
|
11
11
|
import "./chunk-H2TXOCXH.mjs";
|
|
12
12
|
import "./chunk-5KQ36QNH.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-HQ6APBHF.mjs";
|
|
14
14
|
import "./chunk-E3QI365E.mjs";
|
|
15
15
|
import "./chunk-X4PPXI3K.mjs";
|
|
16
16
|
import "./chunk-JTT77LMU.mjs";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cancelPasskeyAutofill,
|
|
3
|
+
passkeyCeremony
|
|
4
|
+
} from "./chunk-QHZ6E64O.mjs";
|
|
1
5
|
import {
|
|
2
6
|
LinkPromptStep
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-W6YYHOYL.mjs";
|
|
4
8
|
import {
|
|
5
9
|
addressInputValue
|
|
6
10
|
} from "./chunk-U7IUGDLW.mjs";
|
|
@@ -21,7 +25,7 @@ import {
|
|
|
21
25
|
} from "./chunk-5KQ36QNH.mjs";
|
|
22
26
|
import {
|
|
23
27
|
useOptionalOcSession
|
|
24
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FDN374RW.mjs";
|
|
25
29
|
import {
|
|
26
30
|
SEVERAL_SESSIONS_TEXT,
|
|
27
31
|
endedSigninText,
|
|
@@ -29,7 +33,7 @@ import {
|
|
|
29
33
|
humanSigninError,
|
|
30
34
|
isSeveralSessions,
|
|
31
35
|
networkError
|
|
32
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-HQ6APBHF.mjs";
|
|
33
37
|
import {
|
|
34
38
|
stripFragment
|
|
35
39
|
} from "./chunk-JTT77LMU.mjs";
|
|
@@ -52,6 +56,7 @@ import {
|
|
|
52
56
|
// src/signin.tsx
|
|
53
57
|
import { isFamilyOrigin } from "@orangecheck/auth-core/family-origins";
|
|
54
58
|
import { normalizeEmail } from "@orangecheck/auth-core/identifiers";
|
|
59
|
+
import { browserSupportsWebAuthnAutofill } from "@simplewebauthn/browser";
|
|
55
60
|
import * as React from "react";
|
|
56
61
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
57
62
|
function isSameOriginPath(candidate, origin) {
|
|
@@ -130,13 +135,17 @@ function OcSignIn({
|
|
|
130
135
|
paths,
|
|
131
136
|
className,
|
|
132
137
|
mode,
|
|
133
|
-
providerHref
|
|
138
|
+
providerHref,
|
|
139
|
+
passkey = "off"
|
|
134
140
|
}) {
|
|
135
|
-
const
|
|
136
|
-
const
|
|
141
|
+
const passkeyOnly = passkey === "only";
|
|
142
|
+
const layered = passkey === "layered";
|
|
143
|
+
const walletEnabled = !passkeyOnly && (paths?.wallet ?? true);
|
|
144
|
+
const emailEnabled = !passkeyOnly && !layered && (paths?.email ?? true);
|
|
137
145
|
const firstParty = mode === "first-party";
|
|
138
146
|
const credentials = firstParty ? "omit" : "include";
|
|
139
|
-
const linkPrompt = linkPromptProp && !firstParty;
|
|
147
|
+
const linkPrompt = linkPromptProp && !firstParty && !passkeyOnly && !layered;
|
|
148
|
+
const [layering, setLayering] = React.useState(false);
|
|
140
149
|
const providerSession = useOptionalOcSession();
|
|
141
150
|
const recheck = onSeveralSessions ?? providerSession?.refresh;
|
|
142
151
|
const [resolvedReturn, setResolvedReturn] = React.useState(
|
|
@@ -227,7 +236,7 @@ function OcSignIn({
|
|
|
227
236
|
if (onSuccess) onSuccess(account, token);
|
|
228
237
|
else void navigate(account);
|
|
229
238
|
};
|
|
230
|
-
if (!linkPrompt || !linkAlso) {
|
|
239
|
+
if (!linkPrompt || !linkAlso || via === "passkey") {
|
|
231
240
|
proceed();
|
|
232
241
|
return;
|
|
233
242
|
}
|
|
@@ -252,30 +261,47 @@ function OcSignIn({
|
|
|
252
261
|
},
|
|
253
262
|
[onSuccess, linkPrompt, linkAlso, navigate, authOrigin]
|
|
254
263
|
);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
const onPasskey = (a, t) => void handleSuccess(a, t, "passkey");
|
|
265
|
+
if (passkeyOnly) {
|
|
266
|
+
return /* @__PURE__ */ jsx("div", { className, "data-oc-signin": "", children: /* @__PURE__ */ jsx(
|
|
267
|
+
PasskeyButton,
|
|
258
268
|
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
border: "1px solid var(--border, #27272a)",
|
|
264
|
-
color: "var(--foreground, #fafafa)",
|
|
265
|
-
fontFamily: SIGNIN_FONT,
|
|
266
|
-
fontSize: signinSize(12)
|
|
267
|
-
},
|
|
268
|
-
children: [
|
|
269
|
-
"no signin paths enabled \u2014 set ",
|
|
270
|
-
/* @__PURE__ */ jsx("code", { children: "paths.wallet" }),
|
|
271
|
-
" or",
|
|
272
|
-
" ",
|
|
273
|
-
/* @__PURE__ */ jsx("code", { children: "paths.email" }),
|
|
274
|
-
" to ",
|
|
275
|
-
/* @__PURE__ */ jsx("code", { children: "true" })
|
|
276
|
-
]
|
|
269
|
+
authOrigin,
|
|
270
|
+
add: addMode,
|
|
271
|
+
credentials,
|
|
272
|
+
onSuccess: onPasskey
|
|
277
273
|
}
|
|
278
|
-
);
|
|
274
|
+
) });
|
|
275
|
+
}
|
|
276
|
+
if (layered && firstParty) {
|
|
277
|
+
return /* @__PURE__ */ jsxs(ConfigNote, { className, children: [
|
|
278
|
+
/* @__PURE__ */ jsx("code", { children: 'passkey="layered"' }),
|
|
279
|
+
" adds to a family session; a first-party site uses ",
|
|
280
|
+
/* @__PURE__ */ jsx("code", { children: '"with"' }),
|
|
281
|
+
" or ",
|
|
282
|
+
/* @__PURE__ */ jsx("code", { children: '"only"' })
|
|
283
|
+
] });
|
|
284
|
+
}
|
|
285
|
+
if (layering) {
|
|
286
|
+
return /* @__PURE__ */ jsx("div", { className, "data-oc-signin": "", children: /* @__PURE__ */ jsx(
|
|
287
|
+
PasskeyLayerStep,
|
|
288
|
+
{
|
|
289
|
+
authOrigin,
|
|
290
|
+
credentials,
|
|
291
|
+
onSuccess: onPasskey
|
|
292
|
+
}
|
|
293
|
+
) });
|
|
294
|
+
}
|
|
295
|
+
if (!walletEnabled && !emailEnabled) {
|
|
296
|
+
return /* @__PURE__ */ jsxs(ConfigNote, { className, children: [
|
|
297
|
+
"no signin paths enabled \u2014 set ",
|
|
298
|
+
/* @__PURE__ */ jsx("code", { children: "paths.wallet" }),
|
|
299
|
+
" or",
|
|
300
|
+
" ",
|
|
301
|
+
/* @__PURE__ */ jsx("code", { children: "paths.email" }),
|
|
302
|
+
" to ",
|
|
303
|
+
/* @__PURE__ */ jsx("code", { children: "true" })
|
|
304
|
+
] });
|
|
279
305
|
}
|
|
280
306
|
if (heldLink) {
|
|
281
307
|
return /* @__PURE__ */ jsx("div", { className, "data-oc-signin": "", children: /* @__PURE__ */ jsx(
|
|
@@ -356,7 +382,17 @@ function OcSignIn({
|
|
|
356
382
|
]
|
|
357
383
|
}
|
|
358
384
|
),
|
|
359
|
-
|
|
385
|
+
passkey === "with" && /* @__PURE__ */ jsx("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ jsx(
|
|
386
|
+
PasskeyButton,
|
|
387
|
+
{
|
|
388
|
+
authOrigin,
|
|
389
|
+
add: addMode,
|
|
390
|
+
credentials,
|
|
391
|
+
onSuccess: onPasskey,
|
|
392
|
+
quiet: true
|
|
393
|
+
}
|
|
394
|
+
) }),
|
|
395
|
+
providersFirst && !layered && /* @__PURE__ */ jsx(
|
|
360
396
|
ProviderSignIn,
|
|
361
397
|
{
|
|
362
398
|
authOrigin,
|
|
@@ -415,7 +451,7 @@ function OcSignIn({
|
|
|
415
451
|
add: addMode,
|
|
416
452
|
credentials,
|
|
417
453
|
onSeveralSessions: recheck,
|
|
418
|
-
onSuccess: (a, t) => void handleSuccess(a, t, "wallet")
|
|
454
|
+
onSuccess: layered ? () => setLayering(true) : (a, t) => void handleSuccess(a, t, "wallet")
|
|
419
455
|
}
|
|
420
456
|
),
|
|
421
457
|
showEmail && /* @__PURE__ */ jsx(
|
|
@@ -426,13 +462,14 @@ function OcSignIn({
|
|
|
426
462
|
credentials,
|
|
427
463
|
firstParty,
|
|
428
464
|
onSeveralSessions: recheck,
|
|
429
|
-
onSuccess: (a, t) => void handleSuccess(a, t, "email")
|
|
465
|
+
onSuccess: (a, t) => void handleSuccess(a, t, "email"),
|
|
466
|
+
onPasskey: passkey === "with" ? onPasskey : void 0
|
|
430
467
|
}
|
|
431
468
|
)
|
|
432
469
|
]
|
|
433
470
|
}
|
|
434
471
|
),
|
|
435
|
-
!providersFirst && /* @__PURE__ */ jsx(
|
|
472
|
+
!providersFirst && !layered && /* @__PURE__ */ jsx(
|
|
436
473
|
ProviderSignIn,
|
|
437
474
|
{
|
|
438
475
|
authOrigin,
|
|
@@ -455,6 +492,26 @@ function OcSignIn({
|
|
|
455
492
|
] })
|
|
456
493
|
] });
|
|
457
494
|
}
|
|
495
|
+
function ConfigNote({
|
|
496
|
+
className,
|
|
497
|
+
children
|
|
498
|
+
}) {
|
|
499
|
+
return /* @__PURE__ */ jsx(
|
|
500
|
+
"div",
|
|
501
|
+
{
|
|
502
|
+
className,
|
|
503
|
+
"data-oc-signin": "",
|
|
504
|
+
style: {
|
|
505
|
+
padding: "1rem",
|
|
506
|
+
border: "1px solid var(--border, #27272a)",
|
|
507
|
+
color: "var(--foreground, #fafafa)",
|
|
508
|
+
fontFamily: SIGNIN_FONT,
|
|
509
|
+
fontSize: signinSize(12)
|
|
510
|
+
},
|
|
511
|
+
children
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
}
|
|
458
515
|
var SigninTab = React.forwardRef(function SigninTab2({ id, controls, active, onClick, onKeyDown, children }, ref) {
|
|
459
516
|
return /* @__PURE__ */ jsx(
|
|
460
517
|
"button",
|
|
@@ -616,6 +673,104 @@ function ProviderSignIn({
|
|
|
616
673
|
}
|
|
617
674
|
);
|
|
618
675
|
}
|
|
676
|
+
var quietPasskeyStyle = {
|
|
677
|
+
boxSizing: "border-box",
|
|
678
|
+
width: "100%",
|
|
679
|
+
minHeight: 44,
|
|
680
|
+
padding: "0.6rem 0.875rem",
|
|
681
|
+
border: "1px solid var(--border, #27272a)",
|
|
682
|
+
borderRadius: SIGNIN_BUTTON_RADIUS,
|
|
683
|
+
background: "transparent",
|
|
684
|
+
color: "var(--foreground, #fafafa)",
|
|
685
|
+
fontFamily: SIGNIN_FONT,
|
|
686
|
+
fontSize: signinSize(12),
|
|
687
|
+
cursor: "pointer"
|
|
688
|
+
};
|
|
689
|
+
function PasskeyButton({
|
|
690
|
+
authOrigin,
|
|
691
|
+
add,
|
|
692
|
+
credentials,
|
|
693
|
+
onSuccess,
|
|
694
|
+
quiet = false
|
|
695
|
+
}) {
|
|
696
|
+
const uid = React.useId();
|
|
697
|
+
const [busy, setBusy] = React.useState(false);
|
|
698
|
+
const [error, setError] = React.useState(null);
|
|
699
|
+
async function run() {
|
|
700
|
+
if (busy) return;
|
|
701
|
+
setError(null);
|
|
702
|
+
setBusy(true);
|
|
703
|
+
try {
|
|
704
|
+
const r = await passkeyCeremony({ authOrigin, kind: "signin", credentials, add });
|
|
705
|
+
if (r.ok) {
|
|
706
|
+
onSuccess(r.account, r.token);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
setError(humanSigninError(r.reason, "passkey"));
|
|
710
|
+
} catch (err) {
|
|
711
|
+
setError(failureMessage(err, "passkey", "submit", authOrigin));
|
|
712
|
+
} finally {
|
|
713
|
+
setBusy(false);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return /* @__PURE__ */ jsxs("div", { "data-oc-signin-passkey": "", children: [
|
|
717
|
+
/* @__PURE__ */ jsx(
|
|
718
|
+
"button",
|
|
719
|
+
{
|
|
720
|
+
type: "button",
|
|
721
|
+
onClick: () => void run(),
|
|
722
|
+
"aria-disabled": busy || void 0,
|
|
723
|
+
"aria-describedby": describedBy(error && `${uid}-error`),
|
|
724
|
+
style: quiet ? { ...quietPasskeyStyle, opacity: busy ? 0.5 : 1 } : { ...submitStyle(busy), marginTop: 0 },
|
|
725
|
+
children: busy ? "Waiting for your passkey\u2026" : quiet ? "Sign in with a passkey" : /* @__PURE__ */ jsx(Submit, { children: "Sign in with a passkey" })
|
|
726
|
+
}
|
|
727
|
+
),
|
|
728
|
+
error && /* @__PURE__ */ jsx(ErrorLine, { id: `${uid}-error`, children: error }),
|
|
729
|
+
/* @__PURE__ */ jsx(Busy, { children: busy ? "Waiting for your passkey\u2026" : null })
|
|
730
|
+
] });
|
|
731
|
+
}
|
|
732
|
+
function PasskeyLayerStep({
|
|
733
|
+
authOrigin,
|
|
734
|
+
credentials,
|
|
735
|
+
onSuccess
|
|
736
|
+
}) {
|
|
737
|
+
const uid = React.useId();
|
|
738
|
+
const [busy, setBusy] = React.useState(false);
|
|
739
|
+
const [error, setError] = React.useState(null);
|
|
740
|
+
async function run() {
|
|
741
|
+
if (busy) return;
|
|
742
|
+
setError(null);
|
|
743
|
+
setBusy(true);
|
|
744
|
+
try {
|
|
745
|
+
const r = await passkeyCeremony({ authOrigin, kind: "layer", credentials });
|
|
746
|
+
if (r.ok) {
|
|
747
|
+
onSuccess(r.account, r.token);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
setError(humanSigninError(r.reason, "passkey"));
|
|
751
|
+
} catch (err) {
|
|
752
|
+
setError(failureMessage(err, "passkey", "submit", authOrigin));
|
|
753
|
+
} finally {
|
|
754
|
+
setBusy(false);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return /* @__PURE__ */ jsxs("div", { "data-oc-signin-passkey-layer": "", children: [
|
|
758
|
+
/* @__PURE__ */ jsx(FlowHeader, { children: "Your wallet signed you in. This site also asks for your passkey." }),
|
|
759
|
+
/* @__PURE__ */ jsx(
|
|
760
|
+
"button",
|
|
761
|
+
{
|
|
762
|
+
type: "button",
|
|
763
|
+
onClick: () => void run(),
|
|
764
|
+
"aria-disabled": busy || void 0,
|
|
765
|
+
"aria-describedby": describedBy(error && `${uid}-error`),
|
|
766
|
+
style: submitStyle(busy),
|
|
767
|
+
children: busy ? "Waiting for your passkey\u2026" : /* @__PURE__ */ jsx(Submit, { children: "Confirm with your passkey" })
|
|
768
|
+
}
|
|
769
|
+
),
|
|
770
|
+
error && /* @__PURE__ */ jsx(ErrorLine, { id: `${uid}-error`, children: error }),
|
|
771
|
+
/* @__PURE__ */ jsx(Busy, { children: busy ? "Waiting for your passkey\u2026" : null })
|
|
772
|
+
] });
|
|
773
|
+
}
|
|
619
774
|
function recheckAfter(err, recheck) {
|
|
620
775
|
if (!recheck || !isSeveralSessions(err)) return;
|
|
621
776
|
void Promise.resolve().then(recheck).catch(() => {
|
|
@@ -906,7 +1061,8 @@ function EmailFlow({
|
|
|
906
1061
|
credentials,
|
|
907
1062
|
firstParty,
|
|
908
1063
|
onSuccess,
|
|
909
|
-
onSeveralSessions
|
|
1064
|
+
onSeveralSessions,
|
|
1065
|
+
onPasskey
|
|
910
1066
|
}) {
|
|
911
1067
|
const uid = React.useId();
|
|
912
1068
|
const [stage, setStage] = React.useState("enter");
|
|
@@ -926,6 +1082,28 @@ function EmailFlow({
|
|
|
926
1082
|
codeError: `${uid}-code-error`,
|
|
927
1083
|
listed: `${uid}-listed`
|
|
928
1084
|
};
|
|
1085
|
+
const onPasskeyRef = React.useRef(onPasskey);
|
|
1086
|
+
React.useEffect(() => {
|
|
1087
|
+
onPasskeyRef.current = onPasskey;
|
|
1088
|
+
});
|
|
1089
|
+
const autofill = onPasskey !== void 0 && stage === "enter";
|
|
1090
|
+
React.useEffect(() => {
|
|
1091
|
+
if (!autofill) return;
|
|
1092
|
+
let live = true;
|
|
1093
|
+
void (async () => {
|
|
1094
|
+
try {
|
|
1095
|
+
if (!await browserSupportsWebAuthnAutofill() || !live) return;
|
|
1096
|
+
const r = await passkeyCeremony({ authOrigin, kind: "signin", credentials, add, autofill: true });
|
|
1097
|
+
if (r.ok) onPasskeyRef.current?.(r.account, r.token);
|
|
1098
|
+
else if (live && r.step === "verify") setEmailError(humanSigninError(r.reason, "passkey"));
|
|
1099
|
+
} catch {
|
|
1100
|
+
}
|
|
1101
|
+
})();
|
|
1102
|
+
return () => {
|
|
1103
|
+
live = false;
|
|
1104
|
+
cancelPasskeyAutofill();
|
|
1105
|
+
};
|
|
1106
|
+
}, [autofill, authOrigin, credentials, add]);
|
|
929
1107
|
async function sendCode(address) {
|
|
930
1108
|
try {
|
|
931
1109
|
const bind = firstParty ? await linkBind() : void 0;
|
|
@@ -1039,7 +1217,7 @@ function EmailFlow({
|
|
|
1039
1217
|
"data-oca-field": "",
|
|
1040
1218
|
id: `${uid}-email`,
|
|
1041
1219
|
type: "email",
|
|
1042
|
-
autoComplete: "email",
|
|
1220
|
+
autoComplete: onPasskey ? "username webauthn" : "email",
|
|
1043
1221
|
value: email,
|
|
1044
1222
|
onChange: (e) => {
|
|
1045
1223
|
setEmail(e.target.value);
|
|
@@ -1405,4 +1583,4 @@ export {
|
|
|
1405
1583
|
looksLikeBitcoinAddress,
|
|
1406
1584
|
OcSignIn
|
|
1407
1585
|
};
|
|
1408
|
-
//# sourceMappingURL=chunk-
|
|
1586
|
+
//# sourceMappingURL=chunk-2FBI2M6N.mjs.map
|