@aiveth/react 0.14.0 → 0.16.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 +9 -1
- package/README.md +3 -0
- package/dist/box.js +9 -2
- package/dist/here.d.ts +5 -1
- package/dist/here.js +27 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.16.0 — unreleased
|
|
4
|
+
|
|
5
|
+
- Same version as `@aiveth/node` 0.16.0. No change in behaviour.
|
|
6
|
+
|
|
7
|
+
## 0.15.0 — 2026-11-30
|
|
8
|
+
|
|
9
|
+
- A new device (Aiveth's Client Trust: a right password from a device the person hasn't used to sign in before, on an account without two-step): `needs_device_code`. `sendDeviceCode()` emails the code, `verifyDeviceCode(code)` signs in. `<SignIn />` sends the code at once and shows the step. This browser keeps the device's token for the app (in `localStorage`) and sends it with each sign-in, so the code is asked once per device.
|
|
10
|
+
|
|
11
|
+
## 0.14.0 — 2026-11-30
|
|
4
12
|
|
|
5
13
|
- 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
14
|
- `<SignIn />` no longer stretches to the height of a flex parent.
|
package/README.md
CHANGED
|
@@ -67,6 +67,9 @@ After the password, two more steps can come: `needs_two_step_setup` where your o
|
|
|
67
67
|
requires two-step (`step.qr`, `step.secret`; `verifyTwoStepSetup(code)`, then
|
|
68
68
|
`needs_recovery_codes_saved` with `step.recoveryCodes` shown once and `recoveryCodesSaved()`), and
|
|
69
69
|
`needs_workspace` where your app requires a workspace (`step.workspaces`; `chooseWorkspace(id)`).
|
|
70
|
+
A right password from a device the person hasn't used before answers `needs_device_code`:
|
|
71
|
+
`sendDeviceCode()`, then `verifyDeviceCode(code)`. The browser keeps the device's token for your app,
|
|
72
|
+
so the code is asked once per device.
|
|
70
73
|
|
|
71
74
|
## A ready-made sign-in box
|
|
72
75
|
|
package/dist/box.js
CHANGED
|
@@ -79,6 +79,9 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
|
|
|
79
79
|
setAsSignUp(false); // an account already: its sign-in
|
|
80
80
|
if (next.email)
|
|
81
81
|
setEmail(next.email);
|
|
82
|
+
// A new device: the code goes out at once — the step asks for it (Clerk's prepare step).
|
|
83
|
+
if (next.status === 'needs_device_code' && step?.status !== 'needs_device_code')
|
|
84
|
+
void flow.current?.sendDeviceCode().catch(() => undefined);
|
|
82
85
|
setStep(next);
|
|
83
86
|
}
|
|
84
87
|
catch (e) {
|
|
@@ -135,6 +138,9 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
|
|
|
135
138
|
const ways = step.ways ?? [];
|
|
136
139
|
body = (_jsxs(_Fragment, { children: [who, ways.includes('password') && (_jsxs("form", { onSubmit: submit((f) => flow.current.password(text(f, 'password'))), children: [field('password', say(w, 'Password'), { type: 'password', autoComplete: 'current-password', autoFocus: true }), _jsx("p", { style: { ...s.note, textAlign: 'end' }, children: _jsx("button", { type: "button", style: s.link, onClick: () => void run(() => flow.current.sendResetCode()), children: say(w, 'Forgot password?') }) }), _jsx("button", { type: "submit", style: s.button, disabled: busy, children: say(w, 'Continue') })] })), ways.includes('email_code') && _jsx("button", { type: "button", style: s.quiet, disabled: busy, onClick: () => void run(() => flow.current.sendEmailCode()), children: say(w, 'Email me a code') }), ways.filter((x) => PROVIDERS[x]).map((x) => (_jsx("button", { type: "button", style: s.quiet, onClick: () => setup.withProvider(x, email), children: say(w, 'Continue with {name}', { name: PROVIDERS[x] ?? x }) }, x))), ways.includes('sso') && _jsx("button", { type: "button", style: s.quiet, onClick: () => setup.withProvider('sso', email), children: say(w, 'Single sign-on (SSO)') })] }));
|
|
137
140
|
}
|
|
141
|
+
else if (status === 'needs_device_code') {
|
|
142
|
+
body = (_jsxs("form", { onSubmit: submit((f) => flow.current.verifyDeviceCode(text(f, 'code'))), children: [_jsx("p", { style: s.note, children: say(w, "You're signing in on a new device. To make sure it's you, enter the code we emailed.") }), _jsx("p", { style: s.note, children: say(w, 'We sent a code to {email}. It ends in 10 minutes.', { email }) }), field('code', say(w, '8-digit code'), { inputMode: 'numeric', autoComplete: 'one-time-code', autoFocus: true }), _jsx("button", { type: "submit", style: s.button, disabled: busy, children: say(w, 'Continue') }), _jsx("button", { type: "button", style: s.quiet, disabled: busy, onClick: () => void run(() => flow.current.sendDeviceCode()), children: say(w, 'Send the code again') })] }));
|
|
143
|
+
}
|
|
138
144
|
else if (status === 'needs_email_code' || status === 'needs_reset_code') {
|
|
139
145
|
const signUp = asSignUp && status === 'needs_email_code';
|
|
140
146
|
body = (_jsxs("form", { onSubmit: submit((f) => {
|
|
@@ -180,8 +186,9 @@ export function SignInBox({ setup, mode, locale, invitation, className, style })
|
|
|
180
186
|
: status === 'needs_two_step_setup' ? say(w, 'Set up two-step sign-in')
|
|
181
187
|
: status === 'needs_recovery_codes_saved' ? say(w, 'Save your recovery codes')
|
|
182
188
|
: status === 'needs_workspace' ? say(w, 'Choose a workspace')
|
|
183
|
-
:
|
|
184
|
-
: say(w, '
|
|
189
|
+
: status === 'needs_device_code' ? say(w, 'Check your email')
|
|
190
|
+
: asSignUp ? say(w, 'Create your account for {name}', { name: settings.name })
|
|
191
|
+
: say(w, 'Sign in to {name}', { name: settings.name });
|
|
185
192
|
const fontUrl = settings.look.font?.url;
|
|
186
193
|
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' }) })] }));
|
|
187
194
|
}
|
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' | 'needs_two_step_setup' | 'needs_recovery_codes_saved' | 'needs_workspace' | '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' | 'needs_device_code' | '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`
|
|
@@ -103,6 +103,10 @@ export declare class HereFlow {
|
|
|
103
103
|
verifyTwoStepSetup(code: string): Promise<Step>;
|
|
104
104
|
/** The person saved their recovery codes: the sign-in goes on. */
|
|
105
105
|
recoveryCodesSaved(): Promise<Step>;
|
|
106
|
+
/** needs_device_code (a password from a new device): email the code — then `verifyDeviceCode`. */
|
|
107
|
+
sendDeviceCode(): Promise<Step>;
|
|
108
|
+
/** The code from the email: the device is known from now (kept in this browser). */
|
|
109
|
+
verifyDeviceCode(code: string): Promise<Step>;
|
|
106
110
|
/** needs_workspace: the workspace picked (its `id` or `slug`). */
|
|
107
111
|
chooseWorkspace(workspace: string): Promise<Step>;
|
|
108
112
|
/** After `needs_aiveth`: the rest on Aiveth's page, then back to your app. */
|
package/dist/here.js
CHANGED
|
@@ -12,6 +12,24 @@ export class StepRefused extends Error {
|
|
|
12
12
|
this.name = 'StepRefused';
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
/** This browser's device token for the app (Aiveth's Client Trust: a password from a device the
|
|
16
|
+
* person hasn't proved asks for an emailed code first). Not a credential — the password is still
|
|
17
|
+
* asked; kept so the person isn't asked for a code on every sign-in. */
|
|
18
|
+
const DEVICE_KEY = 'aiveth.device.';
|
|
19
|
+
function readDevice(clientId) {
|
|
20
|
+
try {
|
|
21
|
+
return globalThis.localStorage?.getItem(DEVICE_KEY + clientId) ?? '';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function keepDevice(clientId, token) {
|
|
28
|
+
try {
|
|
29
|
+
globalThis.localStorage?.setItem(DEVICE_KEY + clientId, token);
|
|
30
|
+
}
|
|
31
|
+
catch { /* private mode: asked again */ }
|
|
32
|
+
}
|
|
15
33
|
/** One sign-in, sign-up, new password or invitation on your page. Each method sends one step
|
|
16
34
|
* and answers the next; a `complete` answer is finished at once (`signed_in`). */
|
|
17
35
|
export class HereFlow {
|
|
@@ -40,6 +58,8 @@ export class HereFlow {
|
|
|
40
58
|
throw new StepRefused(res.status, typeof said.detail === 'string' ? said.detail : `Aiveth answered ${res.status}.`);
|
|
41
59
|
if (said.attempt)
|
|
42
60
|
this.attempt = said.attempt;
|
|
61
|
+
if (said.device_token)
|
|
62
|
+
keepDevice(this.setup.clientId, said.device_token);
|
|
43
63
|
if (said.status === 'complete')
|
|
44
64
|
return this.setup.finish(said.code ?? '', said.state ?? null);
|
|
45
65
|
if (said.continue_url)
|
|
@@ -57,15 +77,15 @@ export class HereFlow {
|
|
|
57
77
|
}
|
|
58
78
|
/** @internal Begin with the address (a sign-in) — through `signInHere.start`. */
|
|
59
79
|
begin(request, email) {
|
|
60
|
-
return this.send('/attempts', { ...request, email });
|
|
80
|
+
return this.send('/attempts', { ...request, email, device: readDevice(this.setup.clientId) });
|
|
61
81
|
}
|
|
62
82
|
/** @internal Begin a sign-up — through `signInHere.signUp`. */
|
|
63
83
|
beginSignUp(request, email) {
|
|
64
|
-
return this.send('/sign-ups', { ...request, email });
|
|
84
|
+
return this.send('/sign-ups', { ...request, email, device: readDevice(this.setup.clientId) });
|
|
65
85
|
}
|
|
66
86
|
/** @internal Begin from an invitation link's token — through `signInHere.invitation`. */
|
|
67
87
|
beginInvitation(request, invitation) {
|
|
68
|
-
return this.send('/invitations', { ...request, invitation });
|
|
88
|
+
return this.send('/invitations', { ...request, invitation, device: readDevice(this.setup.clientId) });
|
|
69
89
|
}
|
|
70
90
|
password(password) { return this.send(this.at('attempts', 'password'), { password }); }
|
|
71
91
|
sendEmailCode() { return this.send(this.at('attempts', 'email-code')); }
|
|
@@ -92,6 +112,10 @@ export class HereFlow {
|
|
|
92
112
|
verifyTwoStepSetup(code) { return this.send(this.at('attempts', 'two-step-setup/verify'), { code }); }
|
|
93
113
|
/** The person saved their recovery codes: the sign-in goes on. */
|
|
94
114
|
recoveryCodesSaved() { return this.send(this.at('attempts', 'two-step-setup/saved')); }
|
|
115
|
+
/** needs_device_code (a password from a new device): email the code — then `verifyDeviceCode`. */
|
|
116
|
+
sendDeviceCode() { return this.send(this.at('attempts', 'device-code')); }
|
|
117
|
+
/** The code from the email: the device is known from now (kept in this browser). */
|
|
118
|
+
verifyDeviceCode(code) { return this.send(this.at('attempts', 'device-code/verify'), { code }); }
|
|
95
119
|
/** needs_workspace: the workspace picked (its `id` or `slug`). */
|
|
96
120
|
chooseWorkspace(workspace) { return this.send(this.at('attempts', 'workspace'), { workspace }); }
|
|
97
121
|
/** After `needs_aiveth`: the rest on Aiveth's page, then back to your app. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiveth/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|