@aiveth/react 0.9.1 → 0.11.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,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 — unreleased
4
+
5
+ - `signIn` and `<SignInButton>` / `<AivethButton>` take `invitation`: the token your own sign-in page got from an invitation email (`?invitation=`). The person joins the organization, signs in and comes back to your app. `authorizeHints()` passes it too.
6
+ - `loginHint` now opens Aiveth's page on that address's ways in, skipping the address screen.
7
+
8
+ ## 0.10.0 — 2026-11-28
9
+
10
+ - `signIn` and `<SignInButton>` / `<AivethButton>` take `connection` (`'google'`, `'microsoft'`, `'github'`, `'sso'`: straight to that way in, skipping Aiveth's page), `loginHint`, `locale` (`ui_locales`) and `screenHint: 'sign-up'` (`prompt=create`). `authorizeHints()` builds the same parameters.
11
+
3
12
  ## 0.9.1 — 2026-11-28
4
13
 
5
14
  - Package details only: a clearer description, the author is Aiveth team, and the README names the product as Aiveth. No change in behaviour.
package/README.md CHANGED
@@ -34,6 +34,16 @@ Add `audience="https://api.your-app.com"` (registered under Developers → Your
34
34
  `AivethProvider`. The access token is then a signed token your API checks with
35
35
  `verifyAccessToken` from `@aiveth/node`, with no call to Aiveth.
36
36
 
37
+ ## Your own sign-in buttons
38
+
39
+ ```tsx
40
+ <SignInButton connection="google">Continue with Google</SignInButton> {/* straight to Google */}
41
+ <SignInButton screenHint="sign-up">Create an account</SignInButton>
42
+ ```
43
+
44
+ `signIn` and both buttons take `connection` (`'google' | 'microsoft' | 'github' | 'sso'`, when your
45
+ organization has it on), `loginHint`, `locale` and `screenHint: 'sign-up'`.
46
+
37
47
  ## Sign in in your organization's own look
38
48
 
39
49
  `<AivethButton>` draws "Sign in" with what you set in Aiveth → Branding — colours (light and
package/dist/client.d.ts CHANGED
@@ -100,6 +100,27 @@ export declare class RefusedError extends SignInError {
100
100
  readonly code: string;
101
101
  constructor(code: string, message: string);
102
102
  }
103
+ /** A way in Aiveth can go straight to, skipping its sign-in page. */
104
+ export type Connection = 'google' | 'microsoft' | 'github' | 'sso';
105
+ /** What `signIn` may ask of Aiveth's sign-in (the `/oauth/authorize` hints). */
106
+ export interface SignInOptions {
107
+ /** Where your app goes after the sign-in (back from `handleRedirect`). */
108
+ returnTo?: string;
109
+ /** Signed in to that workspace (a member's only). */
110
+ workspace?: string;
111
+ /** Straight to Google, Microsoft, GitHub or your single sign-on — when your organization has it on. */
112
+ connection?: Connection;
113
+ /** The address you already know: Aiveth's page opens on its ways in (the person can change it). */
114
+ loginHint?: string;
115
+ /** The sign-in page's language, e.g. `'hi'` or `'ta en'` (OpenID Connect `ui_locales`). */
116
+ locale?: string;
117
+ /** `'sign-up'`: the sign-up page, where your organization lets people join (`prompt=create`). */
118
+ screenHint?: 'sign-in' | 'sign-up';
119
+ /** The `invitation` your sign-in page got from an invitation email: join, then back here. */
120
+ invitation?: string;
121
+ }
122
+ /** The authorize parameters for these hints — the same names in every Aiveth SDK. */
123
+ export declare function authorizeHints({ connection, loginHint, locale, screenHint, invitation }: Omit<SignInOptions, 'returnTo' | 'workspace'>): Record<string, string>;
103
124
  export declare class AivethClient {
104
125
  private readonly config;
105
126
  private readonly issuer;
@@ -117,11 +138,12 @@ export declare class AivethClient {
117
138
  subscribe(listener: () => void): () => void;
118
139
  private changed;
119
140
  private discover;
120
- /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. */
121
- signIn({ returnTo, workspace }?: {
122
- returnTo?: string;
123
- workspace?: string;
124
- }): Promise<void>;
141
+ /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. `connection`
142
+ * skips the page and goes straight to that way in (when your organization has it on);
143
+ * `loginHint` opens on that address's ways in; `locale` picks the page's language (`ui_locales`);
144
+ * `screenHint: 'sign-up'` opens sign-up where your organization lets people join;
145
+ * `invitation` (from your sign-in page's address) joins the organization first. */
146
+ signIn({ returnTo, workspace, ...hints }?: SignInOptions): Promise<void>;
125
147
  /** On the return address: swap the code for tokens. Answers where the app wanted to go
126
148
  * (`returnTo`), or null when this page load isn't a return from Aiveth. */
127
149
  handleRedirect(url: string): Promise<Returned>;
package/dist/client.js CHANGED
@@ -58,6 +58,21 @@ export class RefusedError extends SignInError {
58
58
  this.name = 'RefusedError';
59
59
  }
60
60
  }
61
+ /** The authorize parameters for these hints — the same names in every Aiveth SDK. */
62
+ export function authorizeHints({ connection, loginHint, locale, screenHint, invitation }) {
63
+ const out = {};
64
+ if (invitation)
65
+ out.invitation = invitation;
66
+ if (connection)
67
+ out.connection = connection;
68
+ if (loginHint)
69
+ out.login_hint = loginHint;
70
+ if (locale)
71
+ out.ui_locales = locale;
72
+ if (screenHint === 'sign-up')
73
+ out.prompt = 'create';
74
+ return out;
75
+ }
61
76
  export class AivethClient {
62
77
  config;
63
78
  issuer;
@@ -102,8 +117,12 @@ export class AivethClient {
102
117
  });
103
118
  return this.discovery;
104
119
  }
105
- /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. */
106
- async signIn({ returnTo, workspace } = {}) {
120
+ /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. `connection`
121
+ * skips the page and goes straight to that way in (when your organization has it on);
122
+ * `loginHint` opens on that address's ways in; `locale` picks the page's language (`ui_locales`);
123
+ * `screenHint: 'sign-up'` opens sign-up where your organization lets people join;
124
+ * `invitation` (from your sign-in page's address) joins the organization first. */
125
+ async signIn({ returnTo, workspace, ...hints } = {}) {
107
126
  const found = await this.discover();
108
127
  const verifier = random(48);
109
128
  const pending = { state: random(), nonce: random(), verifier, returnTo: returnTo ?? null };
@@ -117,6 +136,8 @@ export class AivethClient {
117
136
  query.set('resource', this.config.audience); // RFC 8707
118
137
  if (workspace)
119
138
  query.set('workspace', workspace); // signed in to that workspace (a member's only)
139
+ for (const [key, value] of Object.entries(authorizeHints(hints)))
140
+ query.set(key, value);
120
141
  this.navigate(`${found.authorization_endpoint}?${query}`);
121
142
  }
122
143
  /** On the return address: swap the code for tokens. Answers where the app wanted to go
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { AivethClient, RefusedError, SignInError, claimsOf, myWorkspaceAudience, type MyWorkspace, type WorkspaceMember, type WorkspaceInvitationView, type Actor, type AivethConfig, type Returned, type User } from './client.js';
1
+ export { AivethClient, RefusedError, SignInError, authorizeHints, claimsOf, type Connection, type SignInOptions, myWorkspaceAudience, type MyWorkspace, type WorkspaceMember, type WorkspaceInvitationView, type Actor, type AivethConfig, type Returned, type User } from './client.js';
2
2
  export { AivethProvider, useAiveth, SignedIn, SignedOut, SignInButton, AivethButton, SignOutButton, UserButton, ActingBanner, type AivethProviderProps, type UseAiveth } from './react.js';
3
3
  export { BrandedButton, useBrandLook, type BrandLook, type BrandedButtonProps } from './brand.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { AivethClient, RefusedError, SignInError, claimsOf, myWorkspaceAudience } from './client.js';
1
+ export { AivethClient, RefusedError, SignInError, authorizeHints, claimsOf, myWorkspaceAudience } from './client.js';
2
2
  export { AivethProvider, useAiveth, SignedIn, SignedOut, SignInButton, AivethButton, SignOutButton, UserButton, ActingBanner } from './react.js';
3
3
  export { BrandedButton, useBrandLook } from './brand.js';
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties, type ReactNode } from 'react';
2
- import { AivethClient, type Actor, type AivethConfig, type User } from './client.js';
2
+ import { AivethClient, type Actor, type AivethConfig, type SignInOptions, type User } from './client.js';
3
3
  export interface AivethProviderProps extends AivethConfig {
4
4
  children: ReactNode;
5
5
  /** After a return from Aiveth: where to go (your router's navigate), given `returnTo`. */
@@ -13,10 +13,7 @@ export interface UseAiveth {
13
13
  user: User | null;
14
14
  /** A sign-in that went wrong (Aiveth refused, or the round trip didn't start here). */
15
15
  error: Error | null;
16
- signIn: (options?: {
17
- returnTo?: string;
18
- workspace?: string;
19
- }) => Promise<void>;
16
+ signIn: (options?: SignInOptions) => Promise<void>;
20
17
  signOut: () => Promise<void>;
21
18
  /** For your API calls: `Authorization: Bearer …`. Null when signed out. */
22
19
  getAccessToken: () => Promise<string | null>;
@@ -40,16 +37,14 @@ export declare function SignedIn({ children }: {
40
37
  export declare function SignedOut({ children }: {
41
38
  children: ReactNode;
42
39
  }): import("react/jsx-runtime").JSX.Element | null;
43
- export declare function SignInButton({ children, returnTo, className }: {
40
+ export declare function SignInButton({ children, className, ...options }: SignInOptions & {
44
41
  children?: ReactNode;
45
- returnTo?: string;
46
42
  className?: string;
47
43
  }): import("react/jsx-runtime").JSX.Element;
48
44
  /** "Sign in" in the organization's own look (its colours, corners, font, filled or outlined —
49
45
  * as set in Aiveth → Branding), so the app's page and Aiveth's sign-in page look the same. */
50
- export declare function AivethButton({ children, returnTo, showLogo, className, style }: {
46
+ export declare function AivethButton({ children, showLogo, className, style, ...options }: SignInOptions & {
51
47
  children?: ReactNode;
52
- returnTo?: string;
53
48
  showLogo?: boolean;
54
49
  className?: string;
55
50
  style?: CSSProperties;
package/dist/react.js CHANGED
@@ -61,19 +61,19 @@ export function SignedOut({ children }) {
61
61
  const { isLoaded, isSignedIn } = useAiveth();
62
62
  return isLoaded && !isSignedIn ? _jsx(_Fragment, { children: children }) : null;
63
63
  }
64
- export function SignInButton({ children = 'Sign in', returnTo, className }) {
64
+ export function SignInButton({ children = 'Sign in', className, ...options }) {
65
65
  const { signIn } = useAiveth();
66
- return _jsx("button", { type: "button", className: className, onClick: () => { void signIn({ returnTo }); }, children: children });
66
+ return _jsx("button", { type: "button", className: className, onClick: () => { void signIn(options); }, children: children });
67
67
  }
68
68
  /** "Sign in" in the organization's own look (its colours, corners, font, filled or outlined —
69
69
  * as set in Aiveth → Branding), so the app's page and Aiveth's sign-in page look the same. */
70
- export function AivethButton({ children = 'Sign in', returnTo, showLogo, className, style }) {
70
+ export function AivethButton({ children = 'Sign in', showLogo, className, style, ...options }) {
71
71
  const found = useContext(Context);
72
72
  if (!found)
73
73
  throw new Error('AivethButton needs <AivethProvider> around your app.');
74
74
  const { signIn } = useAiveth();
75
75
  const look = useBrandLook(found.brandAddress);
76
- return _jsx(BrandedButton, { look: look, showLogo: showLogo, className: className, style: style, onClick: () => { void signIn({ returnTo }); }, children: children });
76
+ return _jsx(BrandedButton, { look: look, showLogo: showLogo, className: className, style: style, onClick: () => { void signIn(options); }, children: children });
77
77
  }
78
78
  export function SignOutButton({ children = 'Sign out', className }) {
79
79
  const { signOut } = useAiveth();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiveth/react",
3
- "version": "0.9.1",
3
+ "version": "0.11.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",