@aiveth/react 0.9.0 → 0.10.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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0 — 2026-11-28
4
+
5
+ - `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.
6
+
7
+ ## 0.9.1 — 2026-11-28
8
+
9
+ - Package details only: a clearer description, the author is Aiveth team, and the README names the product as Aiveth. No change in behaviour.
10
+
3
11
  ## 0.9.0 — 2026-11-27
4
12
 
5
13
  - Same version as `@aiveth/node` 0.9.0. No change in behaviour.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @aiveth/react
2
2
 
3
- Aiveth by Gooclaim for React 18 single-page apps. Register a **public** app in the console whose
3
+ Aiveth for React 18 single-page apps. Register a **public** app in the console whose
4
4
  return address is your callback page; its origin may then call Aiveth's token endpoint.
5
5
 
6
6
  ```tsx
@@ -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
@@ -1,5 +1,5 @@
1
1
  export interface AivethConfig {
2
- /** Your Aiveth address, e.g. https://aiveth.dev.gooclaim.com */
2
+ /** Your Aiveth address, e.g. https://accounts.aiveth.com */
3
3
  issuer: string;
4
4
  clientId: string;
5
5
  /** Exactly one of the app's registered return addresses. */
@@ -100,6 +100,25 @@ 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 to fill 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
+ }
120
+ /** The authorize parameters for these hints — the same names in every Aiveth SDK. */
121
+ export declare function authorizeHints({ connection, loginHint, locale, screenHint }: Omit<SignInOptions, 'returnTo' | 'workspace'>): Record<string, string>;
103
122
  export declare class AivethClient {
104
123
  private readonly config;
105
124
  private readonly issuer;
@@ -117,11 +136,11 @@ export declare class AivethClient {
117
136
  subscribe(listener: () => void): () => void;
118
137
  private changed;
119
138
  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>;
139
+ /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. `connection`
140
+ * skips the page and goes straight to that way in (when your organization has it on);
141
+ * `loginHint` fills in the address; `locale` picks the page's language (`ui_locales`);
142
+ * `screenHint: 'sign-up'` opens sign-up where your organization lets people join. */
143
+ signIn({ returnTo, workspace, ...hints }?: SignInOptions): Promise<void>;
125
144
  /** On the return address: swap the code for tokens. Answers where the app wanted to go
126
145
  * (`returnTo`), or null when this page load isn't a return from Aiveth. */
127
146
  handleRedirect(url: string): Promise<Returned>;
package/dist/client.js CHANGED
@@ -58,6 +58,19 @@ 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 }) {
63
+ const out = {};
64
+ if (connection)
65
+ out.connection = connection;
66
+ if (loginHint)
67
+ out.login_hint = loginHint;
68
+ if (locale)
69
+ out.ui_locales = locale;
70
+ if (screenHint === 'sign-up')
71
+ out.prompt = 'create';
72
+ return out;
73
+ }
61
74
  export class AivethClient {
62
75
  config;
63
76
  issuer;
@@ -102,8 +115,11 @@ export class AivethClient {
102
115
  });
103
116
  return this.discovery;
104
117
  }
105
- /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. */
106
- async signIn({ returnTo, workspace } = {}) {
118
+ /** To Aiveth's sign-in page; back at `redirectUri`, `handleRedirect` finishes. `connection`
119
+ * skips the page and goes straight to that way in (when your organization has it on);
120
+ * `loginHint` fills in the address; `locale` picks the page's language (`ui_locales`);
121
+ * `screenHint: 'sign-up'` opens sign-up where your organization lets people join. */
122
+ async signIn({ returnTo, workspace, ...hints } = {}) {
107
123
  const found = await this.discover();
108
124
  const verifier = random(48);
109
125
  const pending = { state: random(), nonce: random(), verifier, returnTo: returnTo ?? null };
@@ -117,6 +133,8 @@ export class AivethClient {
117
133
  query.set('resource', this.config.audience); // RFC 8707
118
134
  if (workspace)
119
135
  query.set('workspace', workspace); // signed in to that workspace (a member's only)
136
+ for (const [key, value] of Object.entries(authorizeHints(hints)))
137
+ query.set(key, value);
120
138
  this.navigate(`${found.authorization_endpoint}?${query}`);
121
139
  }
122
140
  /** 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,12 +1,11 @@
1
1
  {
2
2
  "name": "@aiveth/react",
3
- "version": "0.9.0",
4
- "description": "Aiveth by Gooclaim for React: sign in on Aiveth's page (PKCE), tokens in memory, ready-made pieces.",
3
+ "version": "0.10.0",
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
- "author": "Gooclaim",
6
+ "author": "Aiveth team",
7
7
  "keywords": [
8
8
  "aiveth",
9
- "gooclaim",
10
9
  "react",
11
10
  "auth",
12
11
  "authentication",