@hanzo/ui 8.27.23 → 8.27.25
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/auth/SignIn.cjs +157 -0
- package/dist/auth/SignIn.d.ts +54 -0
- package/dist/auth/SignIn.d.ts.map +1 -0
- package/dist/auth/SignIn.js +155 -0
- package/dist/auth/SignIn.js.map +1 -0
- package/dist/auth/index.cjs +16 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/session.cjs +34 -0
- package/dist/auth/session.d.ts +12 -0
- package/dist/auth/session.d.ts.map +1 -0
- package/dist/auth/session.js +29 -0
- package/dist/auth/session.js.map +1 -0
- package/dist/auth/signout.cjs +49 -0
- package/dist/auth/signout.d.ts +21 -0
- package/dist/auth/signout.d.ts.map +1 -0
- package/dist/auth/signout.js +46 -0
- package/dist/auth/signout.js.map +1 -0
- package/dist/auth.css +40 -0
- package/dist/gallery.html +1 -1
- package/dist/models/ModelSelector.cjs +6 -4
- package/dist/models/ModelSelector.d.ts.map +1 -1
- package/dist/models/ModelSelector.js +6 -4
- package/dist/models/ModelSelector.js.map +1 -1
- package/package.json +14 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SignIn = SignIn;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const iam_1 = require("@hanzo/iam");
|
|
8
|
+
const react_2 = require("@hanzo/iam/react");
|
|
9
|
+
const shell_1 = require("@hanzogui/shell");
|
|
10
|
+
const FIRST = {
|
|
11
|
+
password: true,
|
|
12
|
+
code: true,
|
|
13
|
+
signup: true,
|
|
14
|
+
providers: [
|
|
15
|
+
{ name: 'provider-google', type: 'Google' },
|
|
16
|
+
{ name: 'provider-github', type: 'GitHub' },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
const said = (err) => (err instanceof Error && err.message ? err.message : 'Something went wrong. Try again.');
|
|
20
|
+
const GOOGLE = 'M12.48 10.92v3.28h7.84c-.24 1.84-.85 3.18-1.73 4.1-1.02 1.02-2.62 2.14-5.63 2.14-4.64 0-8.26-3.74-8.26-8.38s3.62-8.38 8.26-8.38c2.5 0 4.34.99 5.69 2.26l2.31-2.31C18.96 1.28 16.46 0 12.48 0 5.72 0 .04 5.5.04 12.28s5.68 12.28 12.44 12.28c3.65 0 6.4-1.2 8.55-3.44 2.21-2.21 2.9-5.32 2.9-7.83 0-.78-.06-1.5-.18-2.1z';
|
|
21
|
+
const GITHUB = 'M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.2.5-2.3 1.3-3.1-.2-.4-.6-1.6 0-3.2 0 0 1-.3 3.4 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.6.2 2.8.1 3.2.8.8 1.3 1.9 1.3 3.1 0 4.6-2.8 5.7-5.5 6 .4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3z';
|
|
22
|
+
function Brand({ kind }) {
|
|
23
|
+
const d = kind === 'google' ? GOOGLE : kind === 'github' ? GITHUB : null;
|
|
24
|
+
return d ? ((0, jsx_runtime_1.jsx)("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("path", { d: d }) })) : null;
|
|
25
|
+
}
|
|
26
|
+
function SignIn({ mode = 'login', site = 'Hanzo', callbackPath = '/auth/callback', providers, via, loginPath = '/login', signupPath = '/signup', termsPath = '/terms', privacyPath = '/privacy', track, authorize = (u) => u, onMethod, onShown, }) {
|
|
27
|
+
const { config, sdk } = (0, react_2.useIam)();
|
|
28
|
+
const [methods, setMethods] = (0, react_1.useState)(providers ? { ...FIRST, providers } : FIRST);
|
|
29
|
+
const [step, setStep] = (0, react_1.useState)('email');
|
|
30
|
+
const [email, setEmail] = (0, react_1.useState)('');
|
|
31
|
+
const [password, setPassword] = (0, react_1.useState)('');
|
|
32
|
+
const [code, setCode] = (0, react_1.useState)('');
|
|
33
|
+
const [name, setName] = (0, react_1.useState)('');
|
|
34
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
35
|
+
const [wrong, setWrong] = (0, react_1.useState)(null);
|
|
36
|
+
const origin = via ?? (typeof window === 'undefined' ? '' : window.location.origin);
|
|
37
|
+
const iam = (0, react_1.useMemo)(() => new iam_1.IAM({ ...config, proxyBaseUrl: origin || undefined, redirectUri: origin ? `${origin}${callbackPath}` : config.redirectUri }), [config, origin, callbackPath]);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
let live = true;
|
|
40
|
+
iam
|
|
41
|
+
.methods()
|
|
42
|
+
.then((m) => {
|
|
43
|
+
// A list with no provider in it is IAM saying none; one that failed to
|
|
44
|
+
// arrive keeps the ones Hanzo runs.
|
|
45
|
+
if (live)
|
|
46
|
+
setMethods(m);
|
|
47
|
+
})
|
|
48
|
+
.catch(() => { });
|
|
49
|
+
return () => {
|
|
50
|
+
live = false;
|
|
51
|
+
};
|
|
52
|
+
}, [iam]);
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
track?.('signup_viewed', { mode });
|
|
55
|
+
onShown?.();
|
|
56
|
+
// Once, when the card first appears.
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, []);
|
|
59
|
+
const signup = mode === 'signup';
|
|
60
|
+
function commit(method) {
|
|
61
|
+
onMethod?.(method, mode);
|
|
62
|
+
if (signup)
|
|
63
|
+
track?.('signup_submitted', { method });
|
|
64
|
+
}
|
|
65
|
+
/** The issuer's page, for what cannot be typed here, with the address filled in. */
|
|
66
|
+
const issuer = async () => {
|
|
67
|
+
window.location.replace(authorize(await sdk.getSigninUrl({ additionalParams: { login_hint: email.trim(), ...(signup ? { signup: 'true' } : {}) } })));
|
|
68
|
+
};
|
|
69
|
+
async function run(call) {
|
|
70
|
+
setBusy(true);
|
|
71
|
+
setWrong(null);
|
|
72
|
+
try {
|
|
73
|
+
const to = await call();
|
|
74
|
+
if (to)
|
|
75
|
+
window.location.assign(authorize(to));
|
|
76
|
+
else
|
|
77
|
+
setBusy(false);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
if (err instanceof iam_1.SecondFactor) {
|
|
81
|
+
await issuer();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setWrong(said(err));
|
|
85
|
+
setBusy(false);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function social(provider, kind) {
|
|
89
|
+
commit(kind.toLowerCase());
|
|
90
|
+
setBusy(true);
|
|
91
|
+
void sdk
|
|
92
|
+
.getSigninUrl({ additionalParams: { provider } })
|
|
93
|
+
.then((u) => window.location.replace(authorize(u)))
|
|
94
|
+
.catch((err) => {
|
|
95
|
+
setWrong(said(err));
|
|
96
|
+
setBusy(false);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async function sendCode() {
|
|
100
|
+
await run(async () => {
|
|
101
|
+
await iam.sendLoginCode(email.trim());
|
|
102
|
+
setCode('');
|
|
103
|
+
setStep('code');
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function next(e) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
const address = email.trim();
|
|
109
|
+
if (!address.includes('@')) {
|
|
110
|
+
setWrong('Enter your email address.');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (signup) {
|
|
114
|
+
void run(async () => {
|
|
115
|
+
await iam.sendLoginCode(address);
|
|
116
|
+
setStep('create');
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setWrong(null);
|
|
121
|
+
if (methods.password)
|
|
122
|
+
setStep('password');
|
|
123
|
+
else
|
|
124
|
+
void sendCode();
|
|
125
|
+
}
|
|
126
|
+
function finish(e) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
const address = email.trim();
|
|
129
|
+
if (step === 'password') {
|
|
130
|
+
commit('password');
|
|
131
|
+
void run(() => iam.loginWithPassword(address, password));
|
|
132
|
+
}
|
|
133
|
+
else if (step === 'code') {
|
|
134
|
+
commit('code');
|
|
135
|
+
void run(() => iam.loginWithCode(address, code.trim()));
|
|
136
|
+
}
|
|
137
|
+
else if (step === 'create') {
|
|
138
|
+
commit('email');
|
|
139
|
+
void run(() => iam.signup({ email: address, password, code: code.trim(), name: name.trim() || undefined }));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const back = () => {
|
|
143
|
+
setStep('email');
|
|
144
|
+
setWrong(null);
|
|
145
|
+
setPassword('');
|
|
146
|
+
setCode('');
|
|
147
|
+
};
|
|
148
|
+
const query = typeof window === 'undefined' ? '' : window.location.search;
|
|
149
|
+
const title = signup ? `Create your ${site} account` : `Log in to ${site}`;
|
|
150
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "hz-signin", "aria-label": signup ? 'Sign up' : 'Log in', children: [(0, jsx_runtime_1.jsxs)("div", { className: "hz-signin-card", children: [(0, jsx_runtime_1.jsxs)("p", { className: "hz-signin-brand", children: [(0, jsx_runtime_1.jsx)(shell_1.HanzoMark, { size: 20 }), site] }), (0, jsx_runtime_1.jsx)("h1", { className: "hz-signin-title", children: title }), step === 'email' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [methods.providers.length ? ((0, jsx_runtime_1.jsx)("div", { className: "hz-signin-social", children: methods.providers.map((p) => ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "hz-action", onClick: () => social(p.name, p.type), disabled: busy, children: [(0, jsx_runtime_1.jsx)(Brand, { kind: p.type.toLowerCase() }), "Continue with ", p.type] }, p.name))) })) : null, methods.providers.length ? (0, jsx_runtime_1.jsx)("p", { className: "hz-signin-or", children: "or" }) : null, (0, jsx_runtime_1.jsxs)("form", { onSubmit: next, noValidate: true, children: [(0, jsx_runtime_1.jsx)(Field, { label: "Email", children: (0, jsx_runtime_1.jsx)("input", { type: "email", name: "email", autoComplete: signup ? 'email' : 'username', value: email, onChange: (e) => setEmail(e.target.value), placeholder: "you@company.com", required: true, autoFocus: true }) }), (0, jsx_runtime_1.jsx)(Wrong, { text: wrong }), (0, jsx_runtime_1.jsx)("button", { type: "submit", className: "hz-action", "data-fill": "", disabled: busy, children: busy ? 'One moment…' : 'Continue' })] })] })) : ((0, jsx_runtime_1.jsxs)("form", { onSubmit: finish, noValidate: true, children: [(0, jsx_runtime_1.jsxs)("p", { className: "hz-signin-who", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "hz-more", onClick: back, "aria-label": "Use another email", children: (0, jsx_runtime_1.jsx)("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("path", { d: "m12 19-7-7 7-7M19 12H5" }) }) }), (0, jsx_runtime_1.jsx)("span", { children: email.trim() })] }), step === 'password' ? ((0, jsx_runtime_1.jsx)(Field, { label: "Password", children: (0, jsx_runtime_1.jsx)("input", { type: "password", name: "password", autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value), required: true, autoFocus: true }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("p", { className: "hz-signin-note", children: ["We sent a code to ", email.trim(), ". It is good for a few minutes."] }), (0, jsx_runtime_1.jsx)(Field, { label: "Code", children: (0, jsx_runtime_1.jsx)("input", { name: "code", inputMode: "numeric", autoComplete: "one-time-code", value: code, onChange: (e) => setCode(e.target.value), required: true, autoFocus: true }) })] })), step === 'create' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Field, { label: "Your name", children: (0, jsx_runtime_1.jsx)("input", { name: "name", autoComplete: "name", value: name, onChange: (e) => setName(e.target.value) }) }), (0, jsx_runtime_1.jsx)(Field, { label: "Password", children: (0, jsx_runtime_1.jsx)("input", { type: "password", name: "password", autoComplete: "new-password", value: password, onChange: (e) => setPassword(e.target.value), required: true }) })] })) : null, (0, jsx_runtime_1.jsx)(Wrong, { text: wrong }), (0, jsx_runtime_1.jsx)("button", { type: "submit", className: "hz-action", "data-fill": "", disabled: busy, children: busy ? 'One moment…' : step === 'create' ? 'Create account' : 'Continue' }), step === 'password' && methods.code ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "hz-more hz-signin-alt", onClick: () => void sendCode(), disabled: busy, children: "Email me a code instead" })) : null, step !== 'password' ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "hz-more hz-signin-alt", onClick: () => void sendCode(), disabled: busy, children: "Send a new code" })) : null] })), signup ? ((0, jsx_runtime_1.jsxs)("p", { className: "hz-signin-fine", children: ["By creating an account you agree to the ", (0, jsx_runtime_1.jsx)("a", { href: termsPath, children: "Terms" }), " and the ", (0, jsx_runtime_1.jsx)("a", { href: privacyPath, children: "Privacy Policy" }), "."] })) : null] }), (0, jsx_runtime_1.jsxs)("p", { className: "hz-signin-else", children: [signup ? 'Have an account? ' : `New to ${site}? `, (0, jsx_runtime_1.jsx)("a", { href: `${signup ? loginPath : signupPath}${query}`, children: signup ? 'Log in' : 'Create an account' })] })] }));
|
|
151
|
+
}
|
|
152
|
+
function Field({ label, children }) {
|
|
153
|
+
return ((0, jsx_runtime_1.jsxs)("label", { className: "hz-signin-field", children: [(0, jsx_runtime_1.jsx)("span", { children: label }), children] }));
|
|
154
|
+
}
|
|
155
|
+
function Wrong({ text }) {
|
|
156
|
+
return text ? ((0, jsx_runtime_1.jsx)("p", { role: "alert", className: "hz-signin-wrong", children: text })) : null;
|
|
157
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in and signing up, drawn on the host site's own page.
|
|
3
|
+
*
|
|
4
|
+
* IAM is the authority and the only one: it checks the password or the code,
|
|
5
|
+
* creates the account, mints the PKCE-bound code and, at the callback, the
|
|
6
|
+
* tokens. This component is where the person types, and nothing more: no
|
|
7
|
+
* password is kept and no session is made here.
|
|
8
|
+
*
|
|
9
|
+
* a social provider a top-level hop through IAM to the provider and back to
|
|
10
|
+
* the callback. IAM's own page is never drawn; the
|
|
11
|
+
* provider's is, because only the provider can ask.
|
|
12
|
+
* email, password `loginWithPassword`: the credential goes to IAM, a code
|
|
13
|
+
* comes back, the browser goes to the callback.
|
|
14
|
+
* email, a code `sendLoginCode`, then `loginWithCode`.
|
|
15
|
+
* a new account `sendLoginCode` proves the address, then `signup`.
|
|
16
|
+
*
|
|
17
|
+
* The credential calls go to `via` (this origin by default), which answers
|
|
18
|
+
* IAM's /v1/iam routes, so no IAM route is opened cross-origin. An account with
|
|
19
|
+
* a second factor finishes on the issuer's page: IAM holds that ceremony in a
|
|
20
|
+
* cookie on the issuer.
|
|
21
|
+
*
|
|
22
|
+
* Styled by `@hanzo/ui/auth.css`, which the host imports once.
|
|
23
|
+
*/
|
|
24
|
+
export type Mode = 'login' | 'signup';
|
|
25
|
+
export interface Provider {
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SignInProps {
|
|
30
|
+
mode?: Mode;
|
|
31
|
+
/** The product's name on the card: `Hanzo`. */
|
|
32
|
+
site?: string;
|
|
33
|
+
/** Where IAM sends the browser with the code. Default `/auth/callback`. */
|
|
34
|
+
callbackPath?: string;
|
|
35
|
+
/** What is offered until IAM says. Default: Google and GitHub, the two Hanzo runs. */
|
|
36
|
+
providers?: Provider[];
|
|
37
|
+
/** The origin that answers IAM's credential calls. Default: this page's origin. */
|
|
38
|
+
via?: string;
|
|
39
|
+
/** Where the login page is, for the other-mode link. */
|
|
40
|
+
loginPath?: string;
|
|
41
|
+
signupPath?: string;
|
|
42
|
+
termsPath?: string;
|
|
43
|
+
privacyPath?: string;
|
|
44
|
+
/** A step the stream should hear: `signup_submitted{method}`, `signup_viewed{mode}`. */
|
|
45
|
+
track?: (name: string, props?: Record<string, unknown>) => void;
|
|
46
|
+
/** Decorates an address the browser is about to leave for (the visitor rides along). */
|
|
47
|
+
authorize?: (url: string) => string;
|
|
48
|
+
/** The way in the person chose, kept for the callback. */
|
|
49
|
+
onMethod?: (method: string, mode: Mode) => void;
|
|
50
|
+
/** The card is drawn (once). */
|
|
51
|
+
onShown?: () => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function SignIn({ mode, site, callbackPath, providers, via, loginPath, signupPath, termsPath, privacyPath, track, authorize, onMethod, onShown, }: SignInProps): import("react").JSX.Element;
|
|
54
|
+
//# sourceMappingURL=SignIn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../src/auth/SignIn.tsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAA;AAIrC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,sFAAsF;IACtF,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wFAAwF;IACxF,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IAC/D,wFAAwF;IACxF,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC/C,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AA4BD,wBAAgB,MAAM,CAAC,EACrB,IAAc,EACd,IAAc,EACd,YAA+B,EAC/B,SAAS,EACT,GAAG,EACH,SAAoB,EACpB,UAAsB,EACtB,SAAoB,EACpB,WAAwB,EACxB,KAAK,EACL,SAAoB,EACpB,QAAQ,EACR,OAAO,GACR,EAAE,WAAW,+BA0Ob"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { IAM, SecondFactor } from '@hanzo/iam';
|
|
5
|
+
import { useIam } from '@hanzo/iam/react';
|
|
6
|
+
import { HanzoMark } from '@hanzogui/shell';
|
|
7
|
+
const FIRST = {
|
|
8
|
+
password: true,
|
|
9
|
+
code: true,
|
|
10
|
+
signup: true,
|
|
11
|
+
providers: [
|
|
12
|
+
{ name: 'provider-google', type: 'Google' },
|
|
13
|
+
{ name: 'provider-github', type: 'GitHub' },
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
const said = (err) => (err instanceof Error && err.message ? err.message : 'Something went wrong. Try again.');
|
|
17
|
+
const GOOGLE = 'M12.48 10.92v3.28h7.84c-.24 1.84-.85 3.18-1.73 4.1-1.02 1.02-2.62 2.14-5.63 2.14-4.64 0-8.26-3.74-8.26-8.38s3.62-8.38 8.26-8.38c2.5 0 4.34.99 5.69 2.26l2.31-2.31C18.96 1.28 16.46 0 12.48 0 5.72 0 .04 5.5.04 12.28s5.68 12.28 12.44 12.28c3.65 0 6.4-1.2 8.55-3.44 2.21-2.21 2.9-5.32 2.9-7.83 0-.78-.06-1.5-.18-2.1z';
|
|
18
|
+
const GITHUB = 'M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.2.5-2.3 1.3-3.1-.2-.4-.6-1.6 0-3.2 0 0 1-.3 3.4 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.6.2 2.8.1 3.2.8.8 1.3 1.9 1.3 3.1 0 4.6-2.8 5.7-5.5 6 .4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3z';
|
|
19
|
+
function Brand({ kind }) {
|
|
20
|
+
const d = kind === 'google' ? GOOGLE : kind === 'github' ? GITHUB : null;
|
|
21
|
+
return d ? (_jsx("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: d }) })) : null;
|
|
22
|
+
}
|
|
23
|
+
export function SignIn({ mode = 'login', site = 'Hanzo', callbackPath = '/auth/callback', providers, via, loginPath = '/login', signupPath = '/signup', termsPath = '/terms', privacyPath = '/privacy', track, authorize = (u) => u, onMethod, onShown, }) {
|
|
24
|
+
const { config, sdk } = useIam();
|
|
25
|
+
const [methods, setMethods] = useState(providers ? { ...FIRST, providers } : FIRST);
|
|
26
|
+
const [step, setStep] = useState('email');
|
|
27
|
+
const [email, setEmail] = useState('');
|
|
28
|
+
const [password, setPassword] = useState('');
|
|
29
|
+
const [code, setCode] = useState('');
|
|
30
|
+
const [name, setName] = useState('');
|
|
31
|
+
const [busy, setBusy] = useState(false);
|
|
32
|
+
const [wrong, setWrong] = useState(null);
|
|
33
|
+
const origin = via ?? (typeof window === 'undefined' ? '' : window.location.origin);
|
|
34
|
+
const iam = useMemo(() => new IAM({ ...config, proxyBaseUrl: origin || undefined, redirectUri: origin ? `${origin}${callbackPath}` : config.redirectUri }), [config, origin, callbackPath]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
let live = true;
|
|
37
|
+
iam
|
|
38
|
+
.methods()
|
|
39
|
+
.then((m) => {
|
|
40
|
+
// A list with no provider in it is IAM saying none; one that failed to
|
|
41
|
+
// arrive keeps the ones Hanzo runs.
|
|
42
|
+
if (live)
|
|
43
|
+
setMethods(m);
|
|
44
|
+
})
|
|
45
|
+
.catch(() => { });
|
|
46
|
+
return () => {
|
|
47
|
+
live = false;
|
|
48
|
+
};
|
|
49
|
+
}, [iam]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
track?.('signup_viewed', { mode });
|
|
52
|
+
onShown?.();
|
|
53
|
+
// Once, when the card first appears.
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, []);
|
|
56
|
+
const signup = mode === 'signup';
|
|
57
|
+
function commit(method) {
|
|
58
|
+
onMethod?.(method, mode);
|
|
59
|
+
if (signup)
|
|
60
|
+
track?.('signup_submitted', { method });
|
|
61
|
+
}
|
|
62
|
+
/** The issuer's page, for what cannot be typed here, with the address filled in. */
|
|
63
|
+
const issuer = async () => {
|
|
64
|
+
window.location.replace(authorize(await sdk.getSigninUrl({ additionalParams: { login_hint: email.trim(), ...(signup ? { signup: 'true' } : {}) } })));
|
|
65
|
+
};
|
|
66
|
+
async function run(call) {
|
|
67
|
+
setBusy(true);
|
|
68
|
+
setWrong(null);
|
|
69
|
+
try {
|
|
70
|
+
const to = await call();
|
|
71
|
+
if (to)
|
|
72
|
+
window.location.assign(authorize(to));
|
|
73
|
+
else
|
|
74
|
+
setBusy(false);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
if (err instanceof SecondFactor) {
|
|
78
|
+
await issuer();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setWrong(said(err));
|
|
82
|
+
setBusy(false);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function social(provider, kind) {
|
|
86
|
+
commit(kind.toLowerCase());
|
|
87
|
+
setBusy(true);
|
|
88
|
+
void sdk
|
|
89
|
+
.getSigninUrl({ additionalParams: { provider } })
|
|
90
|
+
.then((u) => window.location.replace(authorize(u)))
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
setWrong(said(err));
|
|
93
|
+
setBusy(false);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function sendCode() {
|
|
97
|
+
await run(async () => {
|
|
98
|
+
await iam.sendLoginCode(email.trim());
|
|
99
|
+
setCode('');
|
|
100
|
+
setStep('code');
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function next(e) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
const address = email.trim();
|
|
106
|
+
if (!address.includes('@')) {
|
|
107
|
+
setWrong('Enter your email address.');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (signup) {
|
|
111
|
+
void run(async () => {
|
|
112
|
+
await iam.sendLoginCode(address);
|
|
113
|
+
setStep('create');
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
setWrong(null);
|
|
118
|
+
if (methods.password)
|
|
119
|
+
setStep('password');
|
|
120
|
+
else
|
|
121
|
+
void sendCode();
|
|
122
|
+
}
|
|
123
|
+
function finish(e) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
const address = email.trim();
|
|
126
|
+
if (step === 'password') {
|
|
127
|
+
commit('password');
|
|
128
|
+
void run(() => iam.loginWithPassword(address, password));
|
|
129
|
+
}
|
|
130
|
+
else if (step === 'code') {
|
|
131
|
+
commit('code');
|
|
132
|
+
void run(() => iam.loginWithCode(address, code.trim()));
|
|
133
|
+
}
|
|
134
|
+
else if (step === 'create') {
|
|
135
|
+
commit('email');
|
|
136
|
+
void run(() => iam.signup({ email: address, password, code: code.trim(), name: name.trim() || undefined }));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const back = () => {
|
|
140
|
+
setStep('email');
|
|
141
|
+
setWrong(null);
|
|
142
|
+
setPassword('');
|
|
143
|
+
setCode('');
|
|
144
|
+
};
|
|
145
|
+
const query = typeof window === 'undefined' ? '' : window.location.search;
|
|
146
|
+
const title = signup ? `Create your ${site} account` : `Log in to ${site}`;
|
|
147
|
+
return (_jsxs("section", { className: "hz-signin", "aria-label": signup ? 'Sign up' : 'Log in', children: [_jsxs("div", { className: "hz-signin-card", children: [_jsxs("p", { className: "hz-signin-brand", children: [_jsx(HanzoMark, { size: 20 }), site] }), _jsx("h1", { className: "hz-signin-title", children: title }), step === 'email' ? (_jsxs(_Fragment, { children: [methods.providers.length ? (_jsx("div", { className: "hz-signin-social", children: methods.providers.map((p) => (_jsxs("button", { type: "button", className: "hz-action", onClick: () => social(p.name, p.type), disabled: busy, children: [_jsx(Brand, { kind: p.type.toLowerCase() }), "Continue with ", p.type] }, p.name))) })) : null, methods.providers.length ? _jsx("p", { className: "hz-signin-or", children: "or" }) : null, _jsxs("form", { onSubmit: next, noValidate: true, children: [_jsx(Field, { label: "Email", children: _jsx("input", { type: "email", name: "email", autoComplete: signup ? 'email' : 'username', value: email, onChange: (e) => setEmail(e.target.value), placeholder: "you@company.com", required: true, autoFocus: true }) }), _jsx(Wrong, { text: wrong }), _jsx("button", { type: "submit", className: "hz-action", "data-fill": "", disabled: busy, children: busy ? 'One moment…' : 'Continue' })] })] })) : (_jsxs("form", { onSubmit: finish, noValidate: true, children: [_jsxs("p", { className: "hz-signin-who", children: [_jsx("button", { type: "button", className: "hz-more", onClick: back, "aria-label": "Use another email", children: _jsx("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 19-7-7 7-7M19 12H5" }) }) }), _jsx("span", { children: email.trim() })] }), step === 'password' ? (_jsx(Field, { label: "Password", children: _jsx("input", { type: "password", name: "password", autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value), required: true, autoFocus: true }) })) : (_jsxs(_Fragment, { children: [_jsxs("p", { className: "hz-signin-note", children: ["We sent a code to ", email.trim(), ". It is good for a few minutes."] }), _jsx(Field, { label: "Code", children: _jsx("input", { name: "code", inputMode: "numeric", autoComplete: "one-time-code", value: code, onChange: (e) => setCode(e.target.value), required: true, autoFocus: true }) })] })), step === 'create' ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Your name", children: _jsx("input", { name: "name", autoComplete: "name", value: name, onChange: (e) => setName(e.target.value) }) }), _jsx(Field, { label: "Password", children: _jsx("input", { type: "password", name: "password", autoComplete: "new-password", value: password, onChange: (e) => setPassword(e.target.value), required: true }) })] })) : null, _jsx(Wrong, { text: wrong }), _jsx("button", { type: "submit", className: "hz-action", "data-fill": "", disabled: busy, children: busy ? 'One moment…' : step === 'create' ? 'Create account' : 'Continue' }), step === 'password' && methods.code ? (_jsx("button", { type: "button", className: "hz-more hz-signin-alt", onClick: () => void sendCode(), disabled: busy, children: "Email me a code instead" })) : null, step !== 'password' ? (_jsx("button", { type: "button", className: "hz-more hz-signin-alt", onClick: () => void sendCode(), disabled: busy, children: "Send a new code" })) : null] })), signup ? (_jsxs("p", { className: "hz-signin-fine", children: ["By creating an account you agree to the ", _jsx("a", { href: termsPath, children: "Terms" }), " and the ", _jsx("a", { href: privacyPath, children: "Privacy Policy" }), "."] })) : null] }), _jsxs("p", { className: "hz-signin-else", children: [signup ? 'Have an account? ' : `New to ${site}? `, _jsx("a", { href: `${signup ? loginPath : signupPath}${query}`, children: signup ? 'Log in' : 'Create an account' })] })] }));
|
|
148
|
+
}
|
|
149
|
+
function Field({ label, children }) {
|
|
150
|
+
return (_jsxs("label", { className: "hz-signin-field", children: [_jsx("span", { children: label }), children] }));
|
|
151
|
+
}
|
|
152
|
+
function Wrong({ text }) {
|
|
153
|
+
return text ? (_jsx("p", { role: "alert", className: "hz-signin-wrong", children: text })) : null;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=SignIn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignIn.js","sourceRoot":"","sources":["../../src/auth/SignIn.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAkC,MAAM,OAAO,CAAA;AACpF,OAAO,EAAE,GAAG,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AA4D3C,MAAM,KAAK,GAAY;IACrB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3C,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC5C;CACF,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAA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ClG,IACI,CACX,CAAA;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAA0C;IACxE,OAAO,CACL,iBAAO,SAAS,EAAC,iBAAiB,aAChC,yBAAO,KAAK,GAAQ,EACnB,QAAQ,IACH,CACT,CAAA;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAE,IAAI,EAA2B;IAC9C,OAAO,IAAI,CAAC,CAAC,CAAC,CACZ,YAAG,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,iBAAiB,YACxC,IAAI,GACH,CACL,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refresher = exports.live = exports.bearer = exports.useSignOut = exports.signOut = exports.SignIn = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Signing in, signing out, and the session, for every Hanzo site: IAM answers
|
|
6
|
+
* (/v1/iam), the site draws. `@hanzo/ui/auth.css` styles it.
|
|
7
|
+
*/
|
|
8
|
+
var SignIn_1 = require("./SignIn.cjs");
|
|
9
|
+
Object.defineProperty(exports, "SignIn", { enumerable: true, get: function () { return SignIn_1.SignIn; } });
|
|
10
|
+
var signout_1 = require("./signout.cjs");
|
|
11
|
+
Object.defineProperty(exports, "signOut", { enumerable: true, get: function () { return signout_1.signOut; } });
|
|
12
|
+
Object.defineProperty(exports, "useSignOut", { enumerable: true, get: function () { return signout_1.useSignOut; } });
|
|
13
|
+
var session_1 = require("./session.cjs");
|
|
14
|
+
Object.defineProperty(exports, "bearer", { enumerable: true, get: function () { return session_1.bearer; } });
|
|
15
|
+
Object.defineProperty(exports, "live", { enumerable: true, get: function () { return session_1.live; } });
|
|
16
|
+
Object.defineProperty(exports, "refresher", { enumerable: true, get: function () { return session_1.refresher; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in, signing out, and the session, for every Hanzo site: IAM answers
|
|
3
|
+
* (/v1/iam), the site draws. `@hanzo/ui/auth.css` styles it.
|
|
4
|
+
*/
|
|
5
|
+
export { SignIn, type Mode, type Provider, type SignInProps } from './SignIn.js';
|
|
6
|
+
export { signOut, useSignOut, type SignOutOptions } from './signout.js';
|
|
7
|
+
export { bearer, live, refresher } from './session.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in, signing out, and the session, for every Hanzo site: IAM answers
|
|
3
|
+
* (/v1/iam), the site draws. `@hanzo/ui/auth.css` styles it.
|
|
4
|
+
*/
|
|
5
|
+
export { SignIn } from './SignIn.js';
|
|
6
|
+
export { signOut, useSignOut } from './signout.js';
|
|
7
|
+
export { bearer, live, refresher } from './session.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAA8C,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAuB,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Where the IAM session is kept, named once. The `@hanzo/iam` SDK owns these
|
|
4
|
+
* keys (`hanzo_iam_`-prefixed) and publishes no plain-module reader, so this is
|
|
5
|
+
* the one derivation every surface reads the bearer through.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.refresher = exports.bearer = void 0;
|
|
9
|
+
exports.live = live;
|
|
10
|
+
const PREFIX = 'hanzo_iam_';
|
|
11
|
+
const ACCESS = `${PREFIX}access_token`;
|
|
12
|
+
const REFRESH = `${PREFIX}refresh_token`;
|
|
13
|
+
const EXPIRES = `${PREFIX}expires_at`;
|
|
14
|
+
const read = (key) => {
|
|
15
|
+
if (typeof window === 'undefined')
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
return window.localStorage.getItem(key);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** The access token, or null. Storage that throws answers null. */
|
|
25
|
+
const bearer = () => read(ACCESS);
|
|
26
|
+
exports.bearer = bearer;
|
|
27
|
+
/** The refresh token, or null. */
|
|
28
|
+
const refresher = () => read(REFRESH);
|
|
29
|
+
exports.refresher = refresher;
|
|
30
|
+
/** Whether the stored access token is present and not past the expiry the SDK wrote beside it. */
|
|
31
|
+
function live() {
|
|
32
|
+
const expires = read(EXPIRES);
|
|
33
|
+
return Boolean((0, exports.bearer)()) && (!expires || Date.now() < Number(expires));
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the IAM session is kept, named once. The `@hanzo/iam` SDK owns these
|
|
3
|
+
* keys (`hanzo_iam_`-prefixed) and publishes no plain-module reader, so this is
|
|
4
|
+
* the one derivation every surface reads the bearer through.
|
|
5
|
+
*/
|
|
6
|
+
/** The access token, or null. Storage that throws answers null. */
|
|
7
|
+
export declare const bearer: () => string | null;
|
|
8
|
+
/** The refresh token, or null. */
|
|
9
|
+
export declare const refresher: () => string | null;
|
|
10
|
+
/** Whether the stored access token is present and not past the expiry the SDK wrote beside it. */
|
|
11
|
+
export declare function live(): boolean;
|
|
12
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/auth/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,mEAAmE;AACnE,eAAO,MAAM,MAAM,QAAO,MAAM,GAAG,IAAoB,CAAA;AAEvD,kCAAkC;AAClC,eAAO,MAAM,SAAS,QAAO,MAAM,GAAG,IAAqB,CAAA;AAE3D,kGAAkG;AAClG,wBAAgB,IAAI,IAAI,OAAO,CAG9B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the IAM session is kept, named once. The `@hanzo/iam` SDK owns these
|
|
3
|
+
* keys (`hanzo_iam_`-prefixed) and publishes no plain-module reader, so this is
|
|
4
|
+
* the one derivation every surface reads the bearer through.
|
|
5
|
+
*/
|
|
6
|
+
const PREFIX = 'hanzo_iam_';
|
|
7
|
+
const ACCESS = `${PREFIX}access_token`;
|
|
8
|
+
const REFRESH = `${PREFIX}refresh_token`;
|
|
9
|
+
const EXPIRES = `${PREFIX}expires_at`;
|
|
10
|
+
const read = (key) => {
|
|
11
|
+
if (typeof window === 'undefined')
|
|
12
|
+
return null;
|
|
13
|
+
try {
|
|
14
|
+
return window.localStorage.getItem(key);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** The access token, or null. Storage that throws answers null. */
|
|
21
|
+
export const bearer = () => read(ACCESS);
|
|
22
|
+
/** The refresh token, or null. */
|
|
23
|
+
export const refresher = () => read(REFRESH);
|
|
24
|
+
/** Whether the stored access token is present and not past the expiry the SDK wrote beside it. */
|
|
25
|
+
export function live() {
|
|
26
|
+
const expires = read(EXPIRES);
|
|
27
|
+
return Boolean(bearer()) && (!expires || Date.now() < Number(expires));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/auth/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,GAAG,YAAY,CAAA;AAC3B,MAAM,MAAM,GAAG,GAAG,MAAM,cAAc,CAAA;AACtC,MAAM,OAAO,GAAG,GAAG,MAAM,eAAe,CAAA;AACxC,MAAM,OAAO,GAAG,GAAG,MAAM,YAAY,CAAA;AAErC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAiB,EAAE;IAC1C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,GAAkB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEvD,kCAAkC;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAkB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAE3D,kGAAkG;AAClG,MAAM,UAAU,IAAI;IAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IAC7B,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.signOut = signOut;
|
|
5
|
+
exports.useSignOut = useSignOut;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_2 = require("@hanzo/iam/react");
|
|
8
|
+
const session_1 = require("./session.cjs");
|
|
9
|
+
/** RFC 7009: hand one token back to IAM's /v1/iam route; a refusal is not the person's problem. */
|
|
10
|
+
async function revoke(origin, token, hint, access, clientId) {
|
|
11
|
+
if (!token)
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
await fetch(`${origin}/v1/iam/oauth/revoke`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...(access ? { Authorization: `Bearer ${access}` } : {}) },
|
|
17
|
+
body: new URLSearchParams({ token, token_type_hint: hint, ...(clientId ? { client_id: clientId } : {}) }).toString(),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// The local clear below has already signed the machine out.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sign out: hand both tokens back to IAM through its /v1/iam revocation route
|
|
26
|
+
* (a same-site call, refresh token first, since it is the one that mints more),
|
|
27
|
+
* clear the local session, and land on the site's own `/login?from=logout`.
|
|
28
|
+
* IAM's own logout page is never visited.
|
|
29
|
+
*/
|
|
30
|
+
async function signOut(iam, { via, to = '/login?from=logout', clientId, track } = {}) {
|
|
31
|
+
const origin = via ?? window.location.origin;
|
|
32
|
+
const access = (0, session_1.bearer)();
|
|
33
|
+
const refresh = (0, session_1.refresher)();
|
|
34
|
+
iam.clearTokens();
|
|
35
|
+
try {
|
|
36
|
+
await revoke(origin, refresh, 'refresh_token', access, clientId);
|
|
37
|
+
await revoke(origin, access, 'access_token', access, clientId);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
track?.('logout_completed', {});
|
|
41
|
+
window.location.assign(to);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** `signOut` bound to the page's IAM client. */
|
|
45
|
+
function useSignOut(options = {}) {
|
|
46
|
+
const { sdk, config } = (0, react_2.useIam)();
|
|
47
|
+
const { via, to, track, clientId = config.clientId } = options;
|
|
48
|
+
return (0, react_1.useCallback)(() => signOut(sdk, { via, to, track, clientId }), [sdk, via, to, track, clientId]);
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IAM } from '@hanzo/iam';
|
|
2
|
+
export interface SignOutOptions {
|
|
3
|
+
/** The origin that answers IAM's /v1/iam routes. Default: this page's origin. */
|
|
4
|
+
via?: string;
|
|
5
|
+
/** Where the person lands. Default `/login?from=logout`: the site's own sign-in hero. */
|
|
6
|
+
to?: string;
|
|
7
|
+
/** The IAM client id the tokens were minted for. */
|
|
8
|
+
clientId?: string;
|
|
9
|
+
/** `logout_completed` reaches the stream here. */
|
|
10
|
+
track?: (name: string, props?: Record<string, unknown>) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sign out: hand both tokens back to IAM through its /v1/iam revocation route
|
|
14
|
+
* (a same-site call, refresh token first, since it is the one that mints more),
|
|
15
|
+
* clear the local session, and land on the site's own `/login?from=logout`.
|
|
16
|
+
* IAM's own logout page is never visited.
|
|
17
|
+
*/
|
|
18
|
+
export declare function signOut(iam: IAM, { via, to, clientId, track }?: SignOutOptions): Promise<void>;
|
|
19
|
+
/** `signOut` bound to the page's IAM client. */
|
|
20
|
+
export declare function useSignOut(options?: SignOutOptions): () => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=signout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signout.d.ts","sourceRoot":"","sources":["../../src/auth/signout.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAIrC,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yFAAyF;IACzF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CAChE;AAgBD;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,EAAyB,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAY/H;AAED,gDAAgD;AAChD,wBAAgB,UAAU,CAAC,OAAO,GAAE,cAAmB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAI5E"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useIam } from '@hanzo/iam/react';
|
|
4
|
+
import { bearer, refresher } from './session.js';
|
|
5
|
+
/** RFC 7009: hand one token back to IAM's /v1/iam route; a refusal is not the person's problem. */
|
|
6
|
+
async function revoke(origin, token, hint, access, clientId) {
|
|
7
|
+
if (!token)
|
|
8
|
+
return;
|
|
9
|
+
try {
|
|
10
|
+
await fetch(`${origin}/v1/iam/oauth/revoke`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...(access ? { Authorization: `Bearer ${access}` } : {}) },
|
|
13
|
+
body: new URLSearchParams({ token, token_type_hint: hint, ...(clientId ? { client_id: clientId } : {}) }).toString(),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// The local clear below has already signed the machine out.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sign out: hand both tokens back to IAM through its /v1/iam revocation route
|
|
22
|
+
* (a same-site call, refresh token first, since it is the one that mints more),
|
|
23
|
+
* clear the local session, and land on the site's own `/login?from=logout`.
|
|
24
|
+
* IAM's own logout page is never visited.
|
|
25
|
+
*/
|
|
26
|
+
export async function signOut(iam, { via, to = '/login?from=logout', clientId, track } = {}) {
|
|
27
|
+
const origin = via ?? window.location.origin;
|
|
28
|
+
const access = bearer();
|
|
29
|
+
const refresh = refresher();
|
|
30
|
+
iam.clearTokens();
|
|
31
|
+
try {
|
|
32
|
+
await revoke(origin, refresh, 'refresh_token', access, clientId);
|
|
33
|
+
await revoke(origin, access, 'access_token', access, clientId);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
track?.('logout_completed', {});
|
|
37
|
+
window.location.assign(to);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** `signOut` bound to the page's IAM client. */
|
|
41
|
+
export function useSignOut(options = {}) {
|
|
42
|
+
const { sdk, config } = useIam();
|
|
43
|
+
const { via, to, track, clientId = config.clientId } = options;
|
|
44
|
+
return useCallback(() => signOut(sdk, { via, to, track, clientId }), [sdk, via, to, track, clientId]);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=signout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signout.js","sourceRoot":"","sources":["../../src/auth/signout.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAa7C,mGAAmG;AACnG,KAAK,UAAU,MAAM,CAAC,MAAc,EAAE,KAAoB,EAAE,IAAY,EAAE,MAAqB,EAAE,QAAiB;IAChH,IAAI,CAAC,KAAK;QAAE,OAAM;IAClB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,GAAG,MAAM,sBAAsB,EA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U,UAAU,CAAC,OAAO,GAAmB,EAAE;IACrD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IAChC,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC9D,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;AACvG,CAAC"}
|
package/dist/auth.css
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* The sign-in card (SignIn, @hanzo/ui/auth): one narrow card in the page's
|
|
2
|
+
chrome. Reads the theme's tokens, so light and dark need no second copy.
|
|
3
|
+
Imported once by every site that draws it. */
|
|
4
|
+
.hz-signin { display: grid; justify-items: center; gap: 20px; min-height: 560px; padding: 112px 16px 96px; }
|
|
5
|
+
.hz-signin-card { width: 100%; max-width: 400px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-xl, 16px); background: var(--background); }
|
|
6
|
+
@media (min-width: 640px) {
|
|
7
|
+
.hz-signin { padding-top: 136px; }
|
|
8
|
+
.hz-signin-card { padding: 32px; }
|
|
9
|
+
}
|
|
10
|
+
.hz-signin-brand { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 24px; font-size: var(--text-lg, 18px); font-weight: 500; color: var(--foreground); }
|
|
11
|
+
.hz-signin-title { margin: 0 0 24px; font-size: var(--text-2xl, 24px); font-weight: 500; line-height: 1.2; color: var(--foreground); }
|
|
12
|
+
.hz-signin-social { display: grid; gap: 10px; }
|
|
13
|
+
.hz-action {
|
|
14
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding-inline: 24px;
|
|
15
|
+
border: 1px solid var(--border); border-radius: var(--radius-full, 9999px); font: inherit; font-size: var(--text-sm, 14px); font-weight: 500;
|
|
16
|
+
color: var(--foreground); background: var(--secondary); cursor: pointer; text-decoration: none;
|
|
17
|
+
transition: background 150ms ease-in-out, opacity 150ms ease-in-out;
|
|
18
|
+
}
|
|
19
|
+
.hz-action:hover { background: var(--accent, var(--secondary)); }
|
|
20
|
+
.hz-action[data-fill] { border: 0; background: var(--foreground); color: var(--background); }
|
|
21
|
+
.hz-action[data-fill]:hover { opacity: 0.92; background: var(--foreground); }
|
|
22
|
+
.hz-action:disabled { opacity: 0.6; cursor: default; }
|
|
23
|
+
.hz-action:focus-visible, .hz-more:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }
|
|
24
|
+
.hz-signin-social .hz-action, .hz-signin-card form > .hz-action { width: 100%; }
|
|
25
|
+
.hz-signin-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: var(--text-sm, 14px); color: var(--muted-foreground); }
|
|
26
|
+
.hz-signin-or::before, .hz-signin-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
|
|
27
|
+
.hz-signin-card form { display: grid; gap: 16px; }
|
|
28
|
+
.hz-signin-field { display: grid; gap: 8px; font-size: var(--text-sm, 14px); font-weight: 500; color: var(--foreground); }
|
|
29
|
+
.hz-signin-field input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg, 12px); background: var(--secondary); color: var(--foreground); font: inherit; font-size: var(--text-base, 16px); font-weight: 400; }
|
|
30
|
+
.hz-signin-field input:focus-visible { outline: 2px solid var(--foreground); outline-offset: 1px; }
|
|
31
|
+
.hz-signin-who { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; font-size: var(--text-sm, 14px); color: var(--foreground); }
|
|
32
|
+
.hz-signin-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
33
|
+
.hz-more { display: inline-flex; align-items: center; padding: 0; border: 0; background: none; color: var(--foreground); font: inherit; font-size: var(--text-sm, 14px); font-weight: 500; cursor: pointer; }
|
|
34
|
+
.hz-signin-who .hz-more { min-width: 44px; min-height: 44px; margin: -12px 0 -12px -12px; justify-content: center; }
|
|
35
|
+
.hz-signin-alt { justify-self: center; justify-content: center; min-height: 44px; color: var(--muted-foreground); }
|
|
36
|
+
.hz-signin-note { margin: 0; font-size: var(--text-sm, 14px); color: var(--muted-foreground); }
|
|
37
|
+
.hz-signin-wrong { margin: 0; font-size: var(--text-sm, 14px); color: var(--foreground); }
|
|
38
|
+
.hz-signin-fine { margin: 20px 0 0; font-size: var(--text-xs, 12px); color: var(--muted-foreground); }
|
|
39
|
+
.hz-signin-fine a, .hz-signin-else a { color: var(--foreground); text-decoration: underline; text-underline-offset: 3px; }
|
|
40
|
+
.hz-signin-else { margin: 0; font-size: var(--text-sm, 14px); color: var(--muted-foreground); }
|
package/dist/gallery.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en" class="t_dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>@hanzo/ui 8.27.
|
|
1
|
+
<!doctype html><html lang="en" class="t_dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>@hanzo/ui 8.27.25</title><style>/* @hanzo/ui — generated by scripts/gen-css.mjs. Do not edit. */
|
|
2
2
|
:root { --hanzo-ui-styles: 1; }
|
|
3
3
|
/* Hanzo Design System — the entry point. Import THIS one file.
|
|
4
4
|
*
|
|
@@ -63,12 +63,14 @@ function ModelSelector({ models, value, onChange, disabled = false, size = 'md',
|
|
|
63
63
|
const label = m.label ?? m.id;
|
|
64
64
|
const ctx = fmtContext(m.context_window);
|
|
65
65
|
const locked = m.access === 'research';
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)(gui_2.CommandItem, { value: `${group.family} ${label} ${m.id}`, disabled: locked, "aria-disabled": locked
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)(gui_2.CommandItem, { value: `${group.family} ${label} ${m.id}`, disabled: locked, "aria-disabled": locked ? false : undefined, "data-access": m.access,
|
|
67
|
+
// The name is muted, not the row: its link has to read as a link.
|
|
68
|
+
opacity: 1, onSelect: () => {
|
|
67
69
|
onChange(m.id);
|
|
68
70
|
setOpen(false);
|
|
69
|
-
}, children: [(0, jsx_runtime_1.jsx)(lucide_icons_2_1.Check, { size: 14, shrink: 0, opacity: m.id === value ? 1 : 0 }), (0, jsx_runtime_1.jsx)(gui_1.SizableText, { numberOfLines: 1, size: "$2", children: label }), m.premium && ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$2", color: "$color11", "aria-label": "Premium", children: "\u2726" })), locked ? ((0, jsx_runtime_1.
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
}, children: [(0, jsx_runtime_1.jsxs)(gui_1.XStack, { flex: 1, minW: 0, items: "center", gap: "$2", "aria-disabled": locked || undefined, opacity: locked ? 0.5 : 1, children: [(0, jsx_runtime_1.jsx)(lucide_icons_2_1.Check, { size: 14, shrink: 0, opacity: m.id === value ? 1 : 0 }), (0, jsx_runtime_1.jsx)(gui_1.SizableText, { numberOfLines: 1, size: "$2", children: label }), m.premium && ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$2", color: "$color11", "aria-label": "Premium", children: "\u2726" })), locked ? ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { ml: "auto", shrink: 0, pl: "$2", size: "$1", color: "$color11", children: "Research preview" })) : ctx && ((0, jsx_runtime_1.jsx)(gui_1.XStack, { ml: "auto", shrink: 0, pl: "$2", children: (0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$1", color: "$color11", fontVariant: ['tabular-nums'], children: ctx }) }))] }), locked && m.request && ((0, jsx_runtime_1.jsx)(gui_2.Anchor, { href: m.request, target: "_blank", rel: "noopener noreferrer", shrink: 0, size: "$1", color: "$color12", textDecorationLine: "underline",
|
|
72
|
+
// The row takes no pointer while disabled; its link does.
|
|
73
|
+
pointerEvents: "auto", onKeyDown: (e) => e.stopPropagation(), children: "Request access" }))] }, m.id));
|
|
72
74
|
}) }, group.family)))] })] }) })] }));
|
|
73
75
|
}
|
|
74
76
|
exports.default = ModelSelector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../src/models/ModelSelector.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAenG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,IAAW,EACX,WAA4B,EAC5B,QAAe,EACf,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,YAAY,GACb,EAAE,kBAAkB,+
|
|
1
|
+
{"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../src/models/ModelSelector.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAenG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,IAAW,EACX,WAA4B,EAC5B,QAAe,EACf,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,YAAY,GACb,EAAE,kBAAkB,+BAqIpB;eAEc,aAAa"}
|
|
@@ -60,12 +60,14 @@ export function ModelSelector({ models, value, onChange, disabled = false, size
|
|
|
60
60
|
const label = m.label ?? m.id;
|
|
61
61
|
const ctx = fmtContext(m.context_window);
|
|
62
62
|
const locked = m.access === 'research';
|
|
63
|
-
return (_jsxs(CommandItem, { value: `${group.family} ${label} ${m.id}`, disabled: locked, "aria-disabled": locked
|
|
63
|
+
return (_jsxs(CommandItem, { value: `${group.family} ${label} ${m.id}`, disabled: locked, "aria-disabled": locked ? false : undefined, "data-access": m.access,
|
|
64
|
+
// The name is muted, not the row: its link has to read as a link.
|
|
65
|
+
opacity: 1, onSelect: () => {
|
|
64
66
|
onChange(m.id);
|
|
65
67
|
setOpen(false);
|
|
66
|
-
}, children: [_jsx(Check, { size: 14, shrink: 0, opacity: m.id === value ? 1 : 0 }), _jsx(SizableText, { numberOfLines: 1, size: "$2", children: label }), m.premium && (_jsx(SizableText, { size: "$2", color: "$color11", "aria-label": "Premium", children: "\u2726" })), locked ? (
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
}, children: [_jsxs(XStack, { flex: 1, minW: 0, items: "center", gap: "$2", "aria-disabled": locked || undefined, opacity: locked ? 0.5 : 1, children: [_jsx(Check, { size: 14, shrink: 0, opacity: m.id === value ? 1 : 0 }), _jsx(SizableText, { numberOfLines: 1, size: "$2", children: label }), m.premium && (_jsx(SizableText, { size: "$2", color: "$color11", "aria-label": "Premium", children: "\u2726" })), locked ? (_jsx(SizableText, { ml: "auto", shrink: 0, pl: "$2", size: "$1", color: "$color11", children: "Research preview" })) : ctx && (_jsx(XStack, { ml: "auto", shrink: 0, pl: "$2", children: _jsx(SizableText, { size: "$1", color: "$color11", fontVariant: ['tabular-nums'], children: ctx }) }))] }), locked && m.request && (_jsx(Anchor, { href: m.request, target: "_blank", rel: "noopener noreferrer", shrink: 0, size: "$1", color: "$color12", textDecorationLine: "underline",
|
|
69
|
+
// The row takes no pointer while disabled; its link does.
|
|
70
|
+
pointerEvents: "auto", onKeyDown: (e) => e.stopPropagation(), children: "Request access" }))] }, m.id));
|
|
69
71
|
}) }, group.family)))] })] }) })] }));
|
|
70
72
|
}
|
|
71
73
|
export default ModelSelector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelSelector.js","sourceRoot":"","sources":["../../src/models/ModelSelector.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,cAAc,GACf,MA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EAAC,IAAI,EACT,KAAK,EAAC,UAAU,EAChB,kBAAkB,EAAC,WAAW;oDAC9B,0DAA0D;oDAC1D,aAAa,EAAC,MAAM,EACpB,SAAS,EAAE,CAAC,CAAkC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,+BAG/D,CACV,KA3DI,CAAC,CAAC,EAAE,CA4DG,CACf,CAAA;oCACH,CAAC,CAAC,IArEe,KAAK,CAAC,MAAM,CAsEhB,CAChB,CAAC,IACU,IACN,GACK,IACT,CACX,CAAA;AACH,CAAC;AAED,eAAe,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/ui",
|
|
3
|
-
"version": "8.27.
|
|
3
|
+
"version": "8.27.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Hanzo UI — the one canonical Hanzo component library, on @hanzo/gui + @hanzo/design. ONE substrate: every component renders through @hanzo/gui primitives, so the same import works on web, native (expo) and desktop (Tauri). Self-contained (theme.css), presentational, host-agnostic, clean-room.",
|
|
6
6
|
"exports": {
|
|
@@ -104,6 +104,13 @@
|
|
|
104
104
|
"default": "./dist/masthead/nav.js"
|
|
105
105
|
},
|
|
106
106
|
"./masthead.css": "./dist/masthead.css",
|
|
107
|
+
"./auth": {
|
|
108
|
+
"types": "./dist/auth/index.d.ts",
|
|
109
|
+
"import": "./dist/auth/index.js",
|
|
110
|
+
"require": "./dist/auth/index.cjs",
|
|
111
|
+
"default": "./dist/auth/index.js"
|
|
112
|
+
},
|
|
113
|
+
"./auth.css": "./dist/auth.css",
|
|
107
114
|
"./product": {
|
|
108
115
|
"types": "./dist/product/index.d.ts",
|
|
109
116
|
"import": "./dist/product/index.js",
|
|
@@ -295,6 +302,7 @@
|
|
|
295
302
|
"@hanzo/dashboard": ">=0.2.0",
|
|
296
303
|
"@hanzo/data": ">=1.2.4",
|
|
297
304
|
"@hanzo/gui": "^8.3.5",
|
|
305
|
+
"@hanzo/iam": ">=0.21.21",
|
|
298
306
|
"@hanzo/usage": ">=0.1.13",
|
|
299
307
|
"@hanzogui/animations-css": "^8.3.5",
|
|
300
308
|
"@hanzogui/config": "^8.3.5",
|
|
@@ -310,6 +318,9 @@
|
|
|
310
318
|
"react-hook-form": ">=7"
|
|
311
319
|
},
|
|
312
320
|
"peerDependenciesMeta": {
|
|
321
|
+
"@hanzo/iam": {
|
|
322
|
+
"optional": true
|
|
323
|
+
},
|
|
313
324
|
"@hanzo/canvas": {
|
|
314
325
|
"optional": true
|
|
315
326
|
},
|
|
@@ -340,6 +351,7 @@
|
|
|
340
351
|
"@hanzo/dashboard": "0.2.0",
|
|
341
352
|
"@hanzo/data": "1.2.4",
|
|
342
353
|
"@hanzo/gui": "8.3.5",
|
|
354
|
+
"@hanzo/iam": "0.21.21",
|
|
343
355
|
"@hanzo/usage": "0.1.7",
|
|
344
356
|
"@hanzogui/animations-css": "8.3.5",
|
|
345
357
|
"@hanzogui/config": "8.3.5",
|
|
@@ -369,7 +381,7 @@
|
|
|
369
381
|
"license": "Apache-2.0 OR MIT",
|
|
370
382
|
"author": "Hanzo AI <dev@hanzo.ai>",
|
|
371
383
|
"scripts": {
|
|
372
|
-
"build": "rm -rf dist dist-cjs && tsc -p tsconfig.build.json && tsc -p tsconfig.cjs.json --noCheck && mkdir -p dist/styles && node scripts/compose-theme.mjs && cp src/styles/motion.css dist/styles/motion.css && cp src/masthead/masthead.css dist/masthead.css && cp src/next.cjs dist/next.cjs && node scripts/postbuild.mjs && node scripts/gen-css.mjs",
|
|
384
|
+
"build": "rm -rf dist dist-cjs && tsc -p tsconfig.build.json && tsc -p tsconfig.cjs.json --noCheck && mkdir -p dist/styles && node scripts/compose-theme.mjs && cp src/styles/motion.css dist/styles/motion.css && cp src/masthead/masthead.css dist/masthead.css && cp src/auth/auth.css dist/auth.css && cp src/next.cjs dist/next.cjs && node scripts/postbuild.mjs && node scripts/gen-css.mjs",
|
|
373
385
|
"clean": "rm -rf dist dist-cjs types",
|
|
374
386
|
"gen:primitives": "node scripts/gen-primitives.mjs",
|
|
375
387
|
"tc": "tsc --noEmit",
|