Skip to content

Commit 82e6fc9

Browse files
docs: kernel.auth.connections.login (sdk client is named kernel)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a9d0996 commit 82e6fc9

8 files changed

Lines changed: 48 additions & 91 deletions

File tree

packages/managed-auth-react/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function LoginPage() {
2929
}
3030
```
3131

32-
`sessionId` and `handoffCode` come from your backend's call to `POST /auth/connections/{id}/login` (or `client.auth.connections.login(id)` via `@onkernel/sdk`). The response includes a `hosted_url`; pass the connection ID and the single-use `code` query parameter from that URL into the component.
32+
`sessionId` and `handoffCode` come from your backend's call to `POST /auth/connections/{id}/login` (or `kernel.auth.connections.login(id)` via `@onkernel/sdk`). The response includes a `hosted_url`; pass the connection ID and the single-use `code` query parameter from that URL into the component.
3333

3434
## Styling
3535

packages/managed-auth-react/package.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@
1313
"bugs": {
1414
"url": "https://github.com/kernel/managed-auth-react/issues"
1515
},
16-
"keywords": [
17-
"kernel",
18-
"auth",
19-
"react",
20-
"managed-auth",
21-
"authentication"
22-
],
16+
"keywords": ["kernel", "auth", "react", "managed-auth", "authentication"],
2317
"type": "module",
24-
"sideEffects": [
25-
"**/*.css"
26-
],
18+
"sideEffects": ["**/*.css"],
2719
"main": "./dist/index.cjs",
2820
"module": "./dist/index.js",
2921
"types": "./dist/index.d.ts",
@@ -36,11 +28,7 @@
3628
"./styles.css": "./dist/styles.css",
3729
"./package.json": "./package.json"
3830
},
39-
"files": [
40-
"dist",
41-
"README.md",
42-
"LICENSE"
43-
],
31+
"files": ["dist", "README.md", "LICENSE"],
4432
"scripts": {
4533
"build": "tsup",
4634
"dev": "tsup --watch",

packages/managed-auth-react/src/appearance/context.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,19 @@ interface AppearanceContextValue {
1313
elements: AppearanceElements;
1414
}
1515

16-
const AppearanceContext = createContext<AppearanceContextValue>({
17-
elements: {},
18-
});
16+
const AppearanceContext = createContext<AppearanceContextValue>({ elements: {} });
1917

2018
interface AppearanceProviderProps {
2119
appearance?: Appearance;
2220
children: ReactNode;
2321
}
2422

25-
export function AppearanceProvider({
26-
appearance,
27-
children,
28-
}: AppearanceProviderProps) {
23+
export function AppearanceProvider({ appearance, children }: AppearanceProviderProps) {
2924
const value = useMemo<AppearanceContextValue>(
3025
() => ({ elements: appearance?.elements ?? {} }),
3126
[appearance?.elements],
3227
);
33-
return (
34-
<AppearanceContext.Provider value={value}>
35-
{children}
36-
</AppearanceContext.Provider>
37-
);
28+
return <AppearanceContext.Provider value={value}>{children}</AppearanceContext.Provider>;
3829
}
3930

4031
function normalizeElement(value: ElementValue | undefined): {

packages/managed-auth-react/src/appearance/pseudoStyles.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ export function compilePseudoStyle(style: ElementStyle | undefined): {
143143
// For belt-and-suspenders, every declaration is emitted with the same
144144
// class selector and inherits its specificity directly.
145145
const rules = pseudoBlocks
146-
.map(([sel, decls]) => `.${className}${sel}{${styleObjectToCss(decls)}}`)
146+
.map(
147+
([sel, decls]) =>
148+
`.${className}${sel}{${styleObjectToCss(decls)}}`,
149+
)
147150
.join("");
148151

149152
injectRules(className, rules);

packages/managed-auth-react/src/components/KernelLogo.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ const BRAND_COLORS: Record<Exclude<KernelLogoColor, "auto">, string> = {
1717
white: "#ffffff",
1818
};
1919

20-
export function KernelLogo({
21-
brandColor,
22-
style: callerStyle,
23-
...props
24-
}: KernelLogoProps) {
20+
export function KernelLogo({ brandColor, style: callerStyle, ...props }: KernelLogoProps) {
2521
const slot = useSlot();
2622
const { style: slotStyle, ...slotPropsRest } = slot(
2723
"poweredByLogo",

packages/managed-auth-react/src/components/UnifiedAuthForm.tsx

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { useState, type FormEvent, type ReactNode } from "react";
22
import { useSlot } from "../appearance/context";
33
import { useLocalization } from "../localization/context";
44
import { extractDomainName } from "../lib/profile-name";
5-
import type { AppearanceLayout } from "../appearance/types";
5+
import type {
6+
AppearanceLayout,
7+
} from "../appearance/types";
68
import type {
79
DiscoveredField,
810
MFAOption,
@@ -89,8 +91,7 @@ function getAutocomplete(field: DiscoveredField): string | undefined {
8991
case "totp":
9092
return "one-time-code";
9193
default:
92-
if (name.includes("user") || name.includes("identifier"))
93-
return "username";
94+
if (name.includes("user") || name.includes("identifier")) return "username";
9495
return undefined;
9596
}
9697
}
@@ -168,9 +169,7 @@ export function UnifiedAuthForm({
168169
{option.label}
169170
</div>
170171
{option.description && (
171-
<div
172-
{...slot("signInOptionDescription", "kma-option__description")}
173-
>
172+
<div {...slot("signInOptionDescription", "kma-option__description")}>
174173
{option.description}
175174
</div>
176175
)}
@@ -189,7 +188,8 @@ export function UnifiedAuthForm({
189188
// "switch" MFA options ("Use another method") are fallbacks — always
190189
// render them last so the primary verification methods come first.
191190
const sortedMFAOptions = [...mfaOptions].sort(
192-
(a, b) => (a.type === "switch" ? 1 : 0) - (b.type === "switch" ? 1 : 0),
191+
(a, b) =>
192+
(a.type === "switch" ? 1 : 0) - (b.type === "switch" ? 1 : 0),
193193
);
194194

195195
const renderMFAOptions = () => (
@@ -203,10 +203,7 @@ export function UnifiedAuthForm({
203203
onClick={() => onMFASelect(option.type)}
204204
disabled={isLoading}
205205
>
206-
<span
207-
{...slot("mfaOptionIcon", "kma-option__icon")}
208-
aria-hidden="true"
209-
>
206+
<span {...slot("mfaOptionIcon", "kma-option__icon")} aria-hidden="true">
210207
{getMFAIcon(option.type)}
211208
</span>
212209
<div className="kma-option__text">
@@ -254,10 +251,7 @@ export function UnifiedAuthForm({
254251
autoComplete={getAutocomplete(field)}
255252
value={formData[field.name] || ""}
256253
onChange={(e) =>
257-
setFormData((prev) => ({
258-
...prev,
259-
[field.name]: e.target.value,
260-
}))
254+
setFormData((prev) => ({ ...prev, [field.name]: e.target.value }))
261255
}
262256
className="kma-input--with-toggle"
263257
/>
@@ -270,9 +264,7 @@ export function UnifiedAuthForm({
270264
}))
271265
}
272266
tabIndex={-1}
273-
aria-label={
274-
showPassword[field.name] ? l.passwordHide : l.passwordShow
275-
}
267+
aria-label={showPassword[field.name] ? l.passwordHide : l.passwordShow}
276268
{...slot("passwordToggle", "kma-password-toggle")}
277269
>
278270
{showPassword[field.name] ? <EyeOffIcon /> : <EyeIcon />}
@@ -288,10 +280,7 @@ export function UnifiedAuthForm({
288280
autoComplete={getAutocomplete(field)}
289281
value={formData[field.name] || ""}
290282
onChange={(e) =>
291-
setFormData((prev) => ({
292-
...prev,
293-
[field.name]: e.target.value,
294-
}))
283+
setFormData((prev) => ({ ...prev, [field.name]: e.target.value }))
295284
}
296285
/>
297286
)}
@@ -342,8 +331,7 @@ export function UnifiedAuthForm({
342331
);
343332

344333
const sections: ReactNode[] = [];
345-
if (hasSignIn)
346-
sections.push(<div key="sign-in">{renderSignInOptions()}</div>);
334+
if (hasSignIn) sections.push(<div key="sign-in">{renderSignInOptions()}</div>);
347335
if (hasMFA) sections.push(<div key="mfa">{renderMFAOptions()}</div>);
348336
if (socialsTop && hasSSO) sections.push(<div key="sso">{renderSSO()}</div>);
349337
if (hasFields) sections.push(<div key="fields">{renderFields()}</div>);

packages/managed-auth-react/src/components/icons.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import type { SVGProps } from "react";
22

33
type IconProps = SVGProps<SVGSVGElement>;
44

5-
function Icon({
6-
children,
7-
...rest
8-
}: IconProps & { children: React.ReactNode }) {
5+
function Icon({ children, ...rest }: IconProps & { children: React.ReactNode }) {
96
return (
107
<svg
118
viewBox="0 0 24 24"
@@ -181,7 +178,12 @@ export const RepeatIcon = (p: IconProps) => (
181178
);
182179

183180
export const SpinnerIcon = (p: IconProps) => (
184-
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true" {...p}>
181+
<svg
182+
viewBox="0 0 24 24"
183+
fill="none"
184+
aria-hidden="true"
185+
{...p}
186+
>
185187
<circle
186188
cx="12"
187189
cy="12"

packages/managed-auth-react/src/styles/styles.css

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
--kma-radius-sm: 0.375rem;
4343
--kma-radius-lg: 0.625rem;
4444

45-
--kma-font-family:
46-
ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
47-
Roboto, "Helvetica Neue", Arial, sans-serif;
45+
--kma-font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
46+
"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
4847
--kma-font-size: 14px;
4948
--kma-font-size-sm: 12px;
5049
--kma-font-size-lg: 16px;
@@ -53,8 +52,8 @@
5352
--kma-font-weight-semibold: 600;
5453

5554
--kma-spacing-unit: 4px;
56-
--kma-shadow:
57-
0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
55+
--kma-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1),
56+
0 4px 6px -4px rgb(0 0 0 / 0.1);
5857
--kma-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
5958
--kma-transition-duration: 150ms;
6059

@@ -362,8 +361,7 @@
362361
font: inherit;
363362
font-weight: var(--kma-font-weight-medium);
364363
border-radius: var(--kma-radius-sm);
365-
transition:
366-
background-color var(--kma-transition-duration),
364+
transition: background-color var(--kma-transition-duration),
367365
color var(--kma-transition-duration),
368366
border-color var(--kma-transition-duration),
369367
opacity var(--kma-transition-duration),
@@ -381,8 +379,7 @@
381379

382380
.kma-button:focus-visible {
383381
outline: none;
384-
box-shadow: 0 0 0 3px
385-
color-mix(in srgb, var(--kma-color-ring) 50%, transparent);
382+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--kma-color-ring) 50%, transparent);
386383
}
387384

388385
.kma-button:disabled {
@@ -561,8 +558,7 @@
561558
font-size: var(--kma-font-size);
562559
line-height: 1.4;
563560
box-shadow: var(--kma-shadow-xs);
564-
transition:
565-
border-color var(--kma-transition-duration),
561+
transition: border-color var(--kma-transition-duration),
566562
box-shadow var(--kma-transition-duration);
567563
}
568564

@@ -659,7 +655,8 @@
659655

660656
.kma-error-banner {
661657
background: color-mix(in srgb, var(--kma-color-danger) 8%, transparent);
662-
border: 1px solid color-mix(in srgb, var(--kma-color-danger) 25%, transparent);
658+
border: 1px solid
659+
color-mix(in srgb, var(--kma-color-danger) 25%, transparent);
663660
border-radius: var(--kma-radius-sm);
664661
padding: 12px 14px;
665662
}
@@ -899,20 +896,12 @@
899896
}
900897

901898
.kma-root.kma-theme-dark .kma-external-action__badge--key {
902-
background: color-mix(
903-
in oklab,
904-
oklch(0.414 0.112 45.904) 30%,
905-
transparent
906-
); /* amber-900/30 */
899+
background: color-mix(in oklab, oklch(0.414 0.112 45.904) 30%, transparent); /* amber-900/30 */
907900
color: oklch(0.828 0.189 84.429); /* amber-400 */
908901
}
909902

910903
.kma-root.kma-theme-dark .kma-external-action__badge--fp {
911-
background: color-mix(
912-
in oklab,
913-
oklch(0.379 0.146 265.522) 30%,
914-
transparent
915-
); /* blue-900/30 */
904+
background: color-mix(in oklab, oklch(0.379 0.146 265.522) 30%, transparent); /* blue-900/30 */
916905
color: oklch(0.707 0.165 254.624); /* blue-400 */
917906
}
918907

@@ -922,11 +911,7 @@
922911
color: oklch(0.828 0.189 84.429);
923912
}
924913
.kma-root.kma-theme-auto .kma-external-action__badge--fp {
925-
background: color-mix(
926-
in oklab,
927-
oklch(0.379 0.146 265.522) 30%,
928-
transparent
929-
);
914+
background: color-mix(in oklab, oklch(0.379 0.146 265.522) 30%, transparent);
930915
color: oklch(0.707 0.165 254.624);
931916
}
932917
}
@@ -1035,7 +1020,11 @@
10351020

10361021
@media (prefers-color-scheme: dark) {
10371022
.kma-root.kma-theme-auto .kma-circle-icon--warning {
1038-
background: color-mix(in oklab, oklch(0.414 0.112 45.904) 30%, transparent);
1023+
background: color-mix(
1024+
in oklab,
1025+
oklch(0.414 0.112 45.904) 30%,
1026+
transparent
1027+
);
10391028
color: oklch(0.828 0.189 84.429);
10401029
}
10411030
}

0 commit comments

Comments
 (0)