@orangecheck/auth-client 2.22.0 → 2.23.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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +38 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -134,6 +134,8 @@ interface OcSignInProps {
|
|
|
134
134
|
add?: boolean;
|
|
135
135
|
className?: string;
|
|
136
136
|
}
|
|
137
|
+
declare function safeReturnTo(input: string | undefined): string;
|
|
138
|
+
declare function familyReturnTarget(input: string | undefined | null): string | undefined;
|
|
137
139
|
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
|
|
138
140
|
|
|
139
141
|
interface OcLinkedIdentity {
|
|
@@ -253,4 +255,4 @@ declare function handleSudoRequired(body: {
|
|
|
253
255
|
returnTo?: string;
|
|
254
256
|
}): boolean;
|
|
255
257
|
|
|
256
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
|
258
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -134,6 +134,8 @@ interface OcSignInProps {
|
|
|
134
134
|
add?: boolean;
|
|
135
135
|
className?: string;
|
|
136
136
|
}
|
|
137
|
+
declare function safeReturnTo(input: string | undefined): string;
|
|
138
|
+
declare function familyReturnTarget(input: string | undefined | null): string | undefined;
|
|
137
139
|
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
|
|
138
140
|
|
|
139
141
|
interface OcLinkedIdentity {
|
|
@@ -253,4 +255,4 @@ declare function handleSudoRequired(body: {
|
|
|
253
255
|
returnTo?: string;
|
|
254
256
|
}): boolean;
|
|
255
257
|
|
|
256
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
|
258
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
package/dist/index.js
CHANGED
|
@@ -2020,15 +2020,27 @@ var primaryChipStyle = {
|
|
|
2020
2020
|
color: V.primary,
|
|
2021
2021
|
border: `1px solid ${V.primary}`
|
|
2022
2022
|
};
|
|
2023
|
+
function isSameOriginPath(candidate, origin) {
|
|
2024
|
+
try {
|
|
2025
|
+
return new URL(candidate, origin).origin === origin;
|
|
2026
|
+
} catch {
|
|
2027
|
+
return false;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
function resolutionOrigin() {
|
|
2031
|
+
return typeof window === "undefined" ? "https://ochk.io" : window.location.origin;
|
|
2032
|
+
}
|
|
2023
2033
|
function safeReturnTo(input) {
|
|
2024
2034
|
const candidate = input ?? "/";
|
|
2025
2035
|
if (typeof candidate !== "string") return "/";
|
|
2026
|
-
if (!candidate.startsWith("/")
|
|
2027
|
-
return candidate;
|
|
2036
|
+
if (!candidate.startsWith("/")) return "/";
|
|
2037
|
+
return isSameOriginPath(candidate, resolutionOrigin()) ? candidate : "/";
|
|
2028
2038
|
}
|
|
2029
2039
|
function familyReturnTarget(input) {
|
|
2030
2040
|
if (typeof input !== "string" || input.length === 0) return void 0;
|
|
2031
|
-
if (input.startsWith("/") &&
|
|
2041
|
+
if (input.startsWith("/") && isSameOriginPath(input, resolutionOrigin())) {
|
|
2042
|
+
return input;
|
|
2043
|
+
}
|
|
2032
2044
|
try {
|
|
2033
2045
|
const u = new URL(input);
|
|
2034
2046
|
if (u.protocol !== "https:") return void 0;
|
|
@@ -2397,6 +2409,8 @@ function ProviderSignIn({
|
|
|
2397
2409
|
if (providers.length === 0) return null;
|
|
2398
2410
|
const providerReturnTo = returnTo.startsWith("/") ? origin ? `${origin}${returnTo}` : returnTo : returnTo;
|
|
2399
2411
|
const line = { flex: 1, height: 1, background: "var(--border, #27272a)" };
|
|
2412
|
+
const BLOCK_GAP = 16;
|
|
2413
|
+
const BUTTON_GAP = 8;
|
|
2400
2414
|
const divider = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2401
2415
|
"div",
|
|
2402
2416
|
{
|
|
@@ -2404,7 +2418,10 @@ function ProviderSignIn({
|
|
|
2404
2418
|
display: "flex",
|
|
2405
2419
|
alignItems: "center",
|
|
2406
2420
|
gap: 10,
|
|
2407
|
-
|
|
2421
|
+
// Symmetric in both orderings: in `first` mode the divider
|
|
2422
|
+
// owns the gap on both sides; at the bottom the container's
|
|
2423
|
+
// marginTop owns the gap above, so the divider only pads below.
|
|
2424
|
+
margin: first ? `${BLOCK_GAP}px 0` : `0 0 ${BLOCK_GAP}px`,
|
|
2408
2425
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
2409
2426
|
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
2410
2427
|
fontSize: 10,
|
|
@@ -2432,7 +2449,7 @@ function ProviderSignIn({
|
|
|
2432
2449
|
gap: 10,
|
|
2433
2450
|
boxSizing: "border-box",
|
|
2434
2451
|
width: "100%",
|
|
2435
|
-
marginTop: i === 0 ? 0 :
|
|
2452
|
+
marginTop: i === 0 ? 0 : BUTTON_GAP,
|
|
2436
2453
|
padding: "0.6rem 0.875rem",
|
|
2437
2454
|
border: "1px solid var(--border, #27272a)",
|
|
2438
2455
|
borderRadius: 6,
|
|
@@ -2449,13 +2466,20 @@ function ProviderSignIn({
|
|
|
2449
2466
|
},
|
|
2450
2467
|
p.id
|
|
2451
2468
|
));
|
|
2452
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2469
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2470
|
+
"div",
|
|
2471
|
+
{
|
|
2472
|
+
"data-oc-signin-providers": "",
|
|
2473
|
+
style: first ? { marginBottom: 0 } : { marginTop: BLOCK_GAP },
|
|
2474
|
+
children: first ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2475
|
+
buttons,
|
|
2476
|
+
divider
|
|
2477
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2478
|
+
divider,
|
|
2479
|
+
buttons
|
|
2480
|
+
] })
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2459
2483
|
}
|
|
2460
2484
|
function WalletFlow({ authOrigin, audience, add, onSuccess }) {
|
|
2461
2485
|
const [address, setAddress] = React3__namespace.useState("");
|
|
@@ -3128,12 +3152,14 @@ exports.buildSignInUrl = buildSignInUrl;
|
|
|
3128
3152
|
exports.clearTabSession = clearTabSession;
|
|
3129
3153
|
exports.consumeTabAccountHint = consumeTabAccountHint;
|
|
3130
3154
|
exports.consumeTabAdoptMarker = consumeTabAdoptMarker;
|
|
3155
|
+
exports.familyReturnTarget = familyReturnTarget;
|
|
3131
3156
|
exports.fetchOcLinkedIdentities = fetchOcLinkedIdentities;
|
|
3132
3157
|
exports.handleSudoRequired = handleSudoRequired;
|
|
3133
3158
|
exports.installTabFetchInterceptor = installTabFetchInterceptor;
|
|
3134
3159
|
exports.installTabLinkDecorator = installTabLinkDecorator;
|
|
3135
3160
|
exports.readTabSession = readTabSession;
|
|
3136
3161
|
exports.redirectToSudo = redirectToSudo;
|
|
3162
|
+
exports.safeReturnTo = safeReturnTo;
|
|
3137
3163
|
exports.tabSessionHeader = tabSessionHeader;
|
|
3138
3164
|
exports.useOcAddressSuggestion = useOcAddressSuggestion;
|
|
3139
3165
|
exports.useOcSession = useOcSession;
|