@aiveth/react 0.13.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ## 0.13.0 — unreleased
3
+ ## 0.14.0 — unreleased
4
+
5
+ - The steps after the password, on your page (Clerk's session tasks): where your organization requires two-step, `needs_two_step_setup` shows the QR code and its key (`twoStepSetup()` for it again, `verifyTwoStepSetup(code)`), then `needs_recovery_codes_saved` shows the recovery codes once with their file (`recoveryCodesSaved()`). Where your app requires a workspace and the person is in several, `needs_workspace` lists them (`chooseWorkspace(id)`). `<SignIn />` shows all three; before, they went to Aiveth's page.
6
+ - `<SignIn />` no longer stretches to the height of a flex parent.
7
+
8
+ ## 0.13.0 — 2026-11-30
4
9
 
5
10
  - `<SignIn />` and `<SignUp />`: a ready-made sign-in box for your own page. One line, and it runs every step of `signInHere` — address, password, email code, Google / Microsoft / GitHub / SSO, second factor, a new password, sign-up details, your organization's terms — in your organization's look and the person's language (the sign-in card's own translations; `locale` to choose). `invitation` opens an invitation link's token. A step only Aiveth's page can do goes there and comes back. "Secured by Aiveth" shows on Free and Pro only. `signInHere.settings()` returns what the box reads.
6
11
  - An email code sent during a sign-in now answers `needs_email_code`.
package/README.md CHANGED
@@ -63,6 +63,11 @@ Also `signInHere.signUp({ email })` (`verifySignUpCode`, `details`), `signInHere
63
63
  (`details`), and on a sign-in `sendResetCode` / `verifyResetCode` / `setNewPassword` and
64
64
  `acceptTerms`. A refused step throws `StepRefused` with its HTTP `status` (401, 422, 429, 404).
65
65
 
66
+ After the password, two more steps can come: `needs_two_step_setup` where your organization
67
+ requires two-step (`step.qr`, `step.secret`; `verifyTwoStepSetup(code)`, then
68
+ `needs_recovery_codes_saved` with `step.recoveryCodes` shown once and `recoveryCodesSaved()`), and
69
+ `needs_workspace` where your app requires a workspace (`step.workspaces`; `chooseWorkspace(id)`).
70
+
66
71
  ## A ready-made sign-in box
67
72
 
68
73
  `<SignIn />` runs every step above in your organization's look (Aiveth → Branding) and the person's
package/dist/box.js CHANGED
@@ -31,6 +31,13 @@ function sayAround(words, text, slot, node, values = {}) {
31
31
  const [before, after = ''] = say(words, text, { ...values, [slot]: '\u0000' }).split('\u0000');
32
32
  return _jsxs(_Fragment, { children: [before, node, after] });
33
33
  }
34
+ /** The recovery codes as the file Aiveth's own page offers (its name and text from Aiveth). */
35
+ function download(name, contents) {
36
+ const url = URL.createObjectURL(new Blob([contents], { type: 'text/plain;charset=utf-8' }));
37
+ const a = Object.assign(document.createElement('a'), { href: url, download: name });
38
+ a.click();
39
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
40
+ }
34
41
  function inviteFromAddress() {
35
42
  if (typeof window === 'undefined')
36
43
  return '';
@@ -97,7 +104,7 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
97
104
  const outlined = settings.look.button_style === 'outlined';
98
105
  const font = settings.look.font?.family;
99
106
  const s = {
100
- card: { boxSizing: 'border-box', width: '100%', maxWidth: 400, padding: 28, background: c.card, color: c.text, border: `1px solid ${c.border}`, borderRadius: radius + 4, fontFamily: font ? `'${font}', system-ui, sans-serif` : 'system-ui, sans-serif', ...style },
107
+ card: { boxSizing: 'border-box', width: '100%', maxWidth: 400, height: 'fit-content', padding: 28, background: c.card, color: c.text, border: `1px solid ${c.border}`, borderRadius: radius + 4, fontFamily: font ? `'${font}', system-ui, sans-serif` : 'system-ui, sans-serif', ...style },
101
108
  title: { margin: '0 0 16px', fontSize: 20, fontWeight: 600, textAlign: 'center' },
102
109
  label: { display: 'block', fontSize: 14, fontWeight: 500, margin: '12px 0 6px' },
103
110
  input: { boxSizing: 'border-box', width: '100%', minHeight: 44, padding: '0 12px', background: c.input, color: c.text, border: `1px solid ${c.border}`, borderRadius: radius, fontSize: 16, fontFamily: 'inherit' },
@@ -150,6 +157,17 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
150
157
  const links = [[step.termsUrl, 'Terms of Service'], [step.privacyUrl, 'Privacy Policy']].filter(([u]) => u);
151
158
  body = (_jsxs("form", { onSubmit: submit(() => flow.current.acceptTerms()), children: [_jsxs("label", { style: { display: 'flex', gap: 8, alignItems: 'flex-start', fontSize: 14 }, children: [_jsx("input", { type: "checkbox", required: true }), _jsx("span", { children: sayAround(w, "I agree to {company}'s {links}", 'links', links.map(([u, t], i) => _jsxs("span", { children: [i ? ', ' : '', _jsx("a", { href: u, target: "_blank", rel: "noopener noreferrer", style: { color: c.link }, children: say(w, t) })] }, u)), { company: settings.name }) })] }), _jsx("button", { type: "submit", style: s.button, disabled: busy, children: say(w, 'Continue') })] }));
152
159
  }
160
+ else if (status === 'needs_two_step_setup') {
161
+ const key = (step.secret ?? '').replace(/(.{4})/g, '$1 ').trim();
162
+ body = (_jsxs("form", { onSubmit: submit((f) => flow.current.verifyTwoStepSetup(text(f, 'code'))), children: [_jsx("p", { style: s.note, children: say(w, 'Your organization asks everyone to use two-step sign-in. It takes a minute.') }), _jsxs("ol", { style: { fontSize: 14, paddingInlineStart: 20, margin: '12px 0' }, children: [_jsx("li", { children: say(w, 'Open an authenticator app — Google Authenticator, Microsoft Authenticator, 1Password or any other.') }), _jsx("li", { children: say(w, 'Scan this code, then type the 6 digits it shows.') })] }), step.qr && _jsx("img", { src: step.qr, alt: say(w, 'QR code for your authenticator app'), width: 180, height: 180, style: { display: 'block', margin: '0 auto', background: '#fff', borderRadius: 8 } }), _jsx("p", { style: { ...s.note, overflowWrap: 'anywhere' }, children: sayAround(w, "Can't scan? Type this key: {key}", 'key', _jsx("code", { children: key })) }), field('code', say(w, '6-digit code'), { inputMode: 'numeric', autoComplete: 'one-time-code', autoFocus: true }), _jsx("button", { type: "submit", style: s.button, disabled: busy, children: say(w, 'Turn on two-step') })] }));
163
+ }
164
+ else if (status === 'needs_recovery_codes_saved') {
165
+ const codes = step.recoveryCodes ?? [];
166
+ body = (_jsxs(_Fragment, { children: [_jsx("p", { style: s.note, children: say(w, 'Two-step is on.') }), _jsx("ul", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, listStyle: 'none', padding: 0, margin: '14px 0', fontFamily: 'ui-monospace, monospace', fontSize: 14, textAlign: 'center' }, children: codes.map((code) => _jsx("li", { children: code }, code)) }), _jsx("p", { style: s.note, children: say(w, "Each one signs you in once if you lose your phone. This is the only time they're shown — keep them somewhere safe.") }), step.recoveryFile && _jsx("button", { type: "button", style: s.quiet, onClick: () => download(step.recoveryFileName ?? 'recovery-codes.txt', step.recoveryFile ?? ''), children: say(w, 'Download codes') }), _jsx("button", { type: "button", style: s.button, disabled: busy, onClick: () => void run(() => flow.current.recoveryCodesSaved()), children: say(w, "I've saved them — continue") })] }));
167
+ }
168
+ else if (status === 'needs_workspace') {
169
+ body = (_jsxs(_Fragment, { children: [_jsx("p", { style: s.note, children: say(w, 'The app opens in the one you choose.') }), (step.workspaces ?? []).map((ws) => (_jsx("button", { type: "button", style: s.quiet, disabled: busy, onClick: () => void run(() => flow.current.chooseWorkspace(ws.id)), children: ws.name }, ws.id)))] }));
170
+ }
153
171
  else if (status === 'waiting') {
154
172
  body = _jsx("p", { style: s.note, children: say(w, "Request sent. If an admin approves it, you'll get an invitation by email.") });
155
173
  }
@@ -159,8 +177,11 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
159
177
  const heading = status === 'needs_details' && step?.reason === 'invited' ? say(w, 'Join {name}', { name: settings.name })
160
178
  : status === 'needs_legal_acceptance' ? say(w, 'Before you continue')
161
179
  : status === 'needs_new_password' ? say(w, 'Choose a new password')
162
- : asSignUp ? say(w, 'Create your account for {name}', { name: settings.name })
163
- : say(w, 'Sign in to {name}', { name: settings.name });
180
+ : status === 'needs_two_step_setup' ? say(w, 'Set up two-step sign-in')
181
+ : status === 'needs_recovery_codes_saved' ? say(w, 'Save your recovery codes')
182
+ : status === 'needs_workspace' ? say(w, 'Choose a workspace')
183
+ : asSignUp ? say(w, 'Create your account for {name}', { name: settings.name })
184
+ : say(w, 'Sign in to {name}', { name: settings.name });
164
185
  const fontUrl = settings.look.font?.url;
165
186
  return (_jsxs("div", { className: className, style: s.card, lang: settings.lang, dir: settings.dir, children: [font && fontUrl && _jsx("style", { children: `@font-face{font-family:'${font.replace(/'/g, '')}';src:url('${fontUrl.replace(/'/g, '')}') format('woff2');font-display:swap}` }), logo && _jsx("img", { src: logo, alt: settings.name, style: { display: 'block', maxHeight: 40, margin: '0 auto 16px' } }), _jsx("h1", { style: s.title, children: heading }), body, problem && _jsx("p", { role: "alert", style: s.alert, children: problem }), settings.secured_by && _jsx("p", { style: s.foot, children: say(w, 'Secured by {name}', { name: 'Aiveth' }) })] }));
166
187
  }
package/dist/here.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** What the next screen is. `signed_in`: done. `needs_aiveth`: send the browser to
2
2
  * `continueUrl` (a step only Aiveth's page can do), or call `continueOnAiveth()`. */
3
- export type StepStatus = 'needs_first_factor' | 'needs_second_factor' | 'needs_legal_acceptance' | 'needs_email_code' | 'needs_details' | 'needs_reset_code' | 'needs_new_password' | 'waiting' | 'needs_aiveth' | 'refused' | 'signed_in';
3
+ export type StepStatus = 'needs_first_factor' | 'needs_second_factor' | 'needs_legal_acceptance' | 'needs_email_code' | 'needs_details' | 'needs_reset_code' | 'needs_new_password' | 'needs_two_step_setup' | 'needs_recovery_codes_saved' | 'needs_workspace' | 'waiting' | 'needs_aiveth' | 'refused' | 'signed_in';
4
4
  export interface Step {
5
5
  status: StepStatus;
6
6
  /** needs_first_factor: `password`, `email_code`, and `google` / `microsoft` / `github` / `sso`
@@ -12,6 +12,20 @@ export interface Step {
12
12
  fields?: string[];
13
13
  /** needs_details from an invitation: the address it was sent to. */
14
14
  email?: string;
15
+ /** needs_two_step_setup: the QR code (an image address), its key to type by hand, its link. */
16
+ qr?: string;
17
+ secret?: string;
18
+ otpauthUri?: string;
19
+ /** needs_recovery_codes_saved: the codes, shown this once, and their file (name and text). */
20
+ recoveryCodes?: string[];
21
+ recoveryFileName?: string;
22
+ recoveryFile?: string;
23
+ /** needs_workspace: the person's workspaces to pick from. */
24
+ workspaces?: {
25
+ id: string;
26
+ slug: string;
27
+ name: string;
28
+ }[];
15
29
  reason?: string;
16
30
  termsUrl?: string;
17
31
  privacyUrl?: string;
@@ -82,6 +96,15 @@ export declare class HereFlow {
82
96
  lastName?: string;
83
97
  password: string;
84
98
  }): Promise<Step>;
99
+ /** needs_two_step_setup (the organization requires two-step): the set-up again — the same QR
100
+ * while it is open, a fresh one after it took too long (a 410 from `verifyTwoStepSetup`). */
101
+ twoStepSetup(): Promise<Step>;
102
+ /** The 6 digits the authenticator app shows: two-step is on; the recovery codes come next. */
103
+ verifyTwoStepSetup(code: string): Promise<Step>;
104
+ /** The person saved their recovery codes: the sign-in goes on. */
105
+ recoveryCodesSaved(): Promise<Step>;
106
+ /** needs_workspace: the workspace picked (its `id` or `slug`). */
107
+ chooseWorkspace(workspace: string): Promise<Step>;
85
108
  /** After `needs_aiveth`: the rest on Aiveth's page, then back to your app. */
86
109
  continueOnAiveth(): void;
87
110
  }
package/dist/here.js CHANGED
@@ -48,6 +48,8 @@ export class HereFlow {
48
48
  status: said.status, ways: said.ways, factors: said.factors, fields: said.fields,
49
49
  email: said.email, reason: said.reason, termsUrl: said.terms_url, privacyUrl: said.privacy_url,
50
50
  continueUrl: said.continue_url, error: said.error, errorDescription: said.error_description,
51
+ qr: said.qr, secret: said.secret, otpauthUri: said.otpauth_uri, recoveryCodes: said.recovery_codes,
52
+ recoveryFileName: said.recovery_file_name, recoveryFile: said.recovery_file, workspaces: said.workspaces,
51
53
  };
52
54
  }
53
55
  at(kind, step) {
@@ -83,6 +85,15 @@ export class HereFlow {
83
85
  details(d) {
84
86
  return this.send(this.at('sign-ups', 'details'), { first_name: d.firstName, last_name: d.lastName ?? '', password: d.password });
85
87
  }
88
+ /** needs_two_step_setup (the organization requires two-step): the set-up again — the same QR
89
+ * while it is open, a fresh one after it took too long (a 410 from `verifyTwoStepSetup`). */
90
+ twoStepSetup() { return this.send(this.at('attempts', 'two-step-setup')); }
91
+ /** The 6 digits the authenticator app shows: two-step is on; the recovery codes come next. */
92
+ verifyTwoStepSetup(code) { return this.send(this.at('attempts', 'two-step-setup/verify'), { code }); }
93
+ /** The person saved their recovery codes: the sign-in goes on. */
94
+ recoveryCodesSaved() { return this.send(this.at('attempts', 'two-step-setup/saved')); }
95
+ /** needs_workspace: the workspace picked (its `id` or `slug`). */
96
+ chooseWorkspace(workspace) { return this.send(this.at('attempts', 'workspace'), { workspace }); }
86
97
  /** After `needs_aiveth`: the rest on Aiveth's page, then back to your app. */
87
98
  continueOnAiveth() {
88
99
  if (!this.continueUrl)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiveth/react",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Official Aiveth SDK for React: sign in on Aiveth's page with PKCE, tokens kept in memory, and ready-made sign-in pieces.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Aiveth team",