@kivacore/signin 0.20.0 → 0.21.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kivacore/signin
2
2
 
3
- Authentication provider for Docyrus apps. Provides "Sign in with Docyrus" experience with automatic environment detection — standalone apps use OAuth2 Authorization Code + PKCE via page redirect, while iframe-embedded apps receive tokens via `window.postMessage` from the host.
3
+ Authentication provider for Kiva apps. Provides "Sign in with Kiva" experience with automatic environment detection — standalone apps use OAuth2 Authorization Code + PKCE via page redirect, while iframe-embedded apps receive tokens via `window.postMessage` from the host.
4
4
 
5
5
  Supports **React**, **Vue**, **React Native**, **Electron**, and **Next.js SSR** via separate entrypoints.
6
6
 
@@ -8,15 +8,15 @@ Supports **React**, **Vue**, **React Native**, **Electron**, and **Next.js SSR**
8
8
 
9
9
  - **Auto Environment Detection**: Detects standalone vs iframe mode automatically
10
10
  - **OAuth2 PKCE**: Full Authorization Code flow with PKCE (S256) for standalone apps
11
- - **Iframe Auth**: Receives tokens via `postMessage` from `*.docyrus.app` hosts
11
+ - **Iframe Auth**: Receives tokens via `postMessage` from `*.kiva.app` and `*.docyrus.app` hosts
12
12
  - **Host Message Hooks**: Subscribe to `navigation` and `notification` messages pushed by the host into the embedded app
13
13
  - **App → Host Actions**: Send to Docy, Send to Chat, Send to Email, and Send to Calendar — hand `text`/`adaptiveCard`/email/event payloads to host surfaces, with a `Promise` that resolves on the host's delivery acknowledgement
14
14
  - **Microsoft Graph Bridge**: Make **proxy-only** Microsoft Graph calls through the host's logged-in MSAL session (the access token never crosses the frame boundary)
15
15
  - **Route Sync**: Mirror the embedded app's route to the host so the host can reflect it in its address bar
16
16
  - **Token Auto-Refresh**: Proactive token refresh before expiry in both modes (opt out with `autoRefresh: false` when an external system owns the token lifecycle)
17
17
  - **Token Bootstrap**: Start a session from existing access/refresh tokens (e.g. device flow handoff)
18
- - **React Hooks**: `useDocyrusAuth()` and `useDocyrusClient()` for easy integration
19
- - **Vue Composables**: `useDocyrusAuth()` and `useDocyrusClient()` for Vue 3
18
+ - **React Hooks**: `useKivaAuth()` and `useKivaClient()` for easy integration
19
+ - **Vue Composables**: `useKivaAuth()` and `useKivaClient()` for Vue 3
20
20
  - **Authorization Helpers**: `hasRole()` and `hasPermission()` for role-based access control
21
21
  - **Electron Support**: `ElectronTokenStorage` for IPC-based token storage + `getAuthorizationUrl()` for external browser login
22
22
  - **Ready-to-Use API Client**: Exposes a configured `RestApiClient` from `@kivacore/api-client`
@@ -55,24 +55,24 @@ pnpm add @kivacore/signin
55
55
  ## Quick Start (React)
56
56
 
57
57
  ```tsx
58
- import { DocyrusAuthProvider, useDocyrusAuth, useDocyrusClient, SignInButton } from '@kivacore/signin';
58
+ import { KivaAuthProvider, useKivaAuth, useKivaClient, SignInButton } from '@kivacore/signin';
59
59
 
60
60
  function App() {
61
61
  return (
62
- <DocyrusAuthProvider
62
+ <KivaAuthProvider
63
63
  apiUrl="https://alpha-api.docyrus.com"
64
64
  clientId="your-oauth2-client-id"
65
65
  redirectUri="http://localhost:3000/callback"
66
66
  scopes={['offline_access', 'Read.All', 'Users.Read']}
67
67
  callbackPath="/callback">
68
68
  <Dashboard />
69
- </DocyrusAuthProvider>
69
+ </KivaAuthProvider>
70
70
  );
71
71
  }
72
72
 
73
73
  function Dashboard() {
74
- const { status, signOut } = useDocyrusAuth();
75
- const client = useDocyrusClient();
74
+ const { status, signOut } = useKivaAuth();
75
+ const client = useKivaClient();
76
76
 
77
77
  if (status === 'loading') return <div>Loading...</div>;
78
78
  if (status === 'unauthenticated') return <SignInButton />;
@@ -95,27 +95,27 @@ function Dashboard() {
95
95
  <!-- App.vue -->
96
96
  <script setup lang="ts">
97
97
  import { RouterView } from 'vue-router';
98
- import { DocyrusAuthProvider } from '@kivacore/signin/vue';
98
+ import { KivaAuthProvider } from '@kivacore/signin/vue';
99
99
  </script>
100
100
 
101
101
  <template>
102
- <DocyrusAuthProvider
102
+ <KivaAuthProvider
103
103
  apiUrl="https://alpha-api.docyrus.com"
104
104
  clientId="your-oauth2-client-id"
105
105
  redirectUri="http://localhost:5173/callback"
106
106
  :scopes="['offline_access', 'Read.All', 'Users.Read']"
107
107
  callbackPath="/callback">
108
108
  <RouterView />
109
- </DocyrusAuthProvider>
109
+ </KivaAuthProvider>
110
110
  </template>
111
111
  ```
112
112
 
113
113
  ```vue
114
114
  <!-- Dashboard.vue -->
115
115
  <script setup lang="ts">
116
- import { useDocyrusAuth } from '@kivacore/signin/vue';
116
+ import { useKivaAuth } from '@kivacore/signin/vue';
117
117
 
118
- const { status, client, signIn, signOut } = useDocyrusAuth();
118
+ const { status, client, signIn, signOut } = useKivaAuth();
119
119
  </script>
120
120
 
121
121
  <template>
@@ -131,27 +131,27 @@ const { status, client, signIn, signOut } = useDocyrusAuth();
131
131
  ## Quick Start (Electron)
132
132
 
133
133
  ```tsx
134
- import { DocyrusAuthProvider, useDocyrusAuth } from '@kivacore/signin';
134
+ import { KivaAuthProvider, useKivaAuth } from '@kivacore/signin';
135
135
  import { ElectronTokenStorage } from '@kivacore/signin/electron';
136
136
 
137
137
  const tokenStorage = new ElectronTokenStorage();
138
138
 
139
139
  function App() {
140
140
  return (
141
- <DocyrusAuthProvider
141
+ <KivaAuthProvider
142
142
  apiUrl="https://alpha-api.docyrus.com"
143
143
  clientId="your-oauth2-client-id"
144
- redirectUri="docyrus://callback"
144
+ redirectUri="kiva://callback"
145
145
  scopes={['offline_access', 'Read.All', 'Users.Read']}
146
146
  callbackPath="/callback"
147
147
  tokenStorage={tokenStorage}>
148
148
  <LoginPage />
149
- </DocyrusAuthProvider>
149
+ </KivaAuthProvider>
150
150
  );
151
151
  }
152
152
 
153
153
  function LoginPage() {
154
- const { status, getAuthorizationUrl } = useDocyrusAuth();
154
+ const { status, getAuthorizationUrl } = useKivaAuth();
155
155
 
156
156
  const handleLogin = async () => {
157
157
  const url = await getAuthorizationUrl();
@@ -168,7 +168,7 @@ function LoginPage() {
168
168
  ## Quick Start (React Native / Expo)
169
169
 
170
170
  ```tsx
171
- import { DocyrusAuthProvider, useDocyrusAuth } from '@kivacore/signin/react-native';
171
+ import { KivaAuthProvider, useKivaAuth } from '@kivacore/signin/react-native';
172
172
  import { createTokenStorage, ReactNativeCryptoProvider } from '@kivacore/api-client/react-native';
173
173
  import * as WebBrowser from 'expo-web-browser';
174
174
  import * as ExpoCrypto from 'expo-crypto';
@@ -182,7 +182,7 @@ const tokenStorage = createTokenStorage({
182
182
 
183
183
  function App() {
184
184
  return (
185
- <DocyrusAuthProvider
185
+ <KivaAuthProvider
186
186
  clientId="your-oauth2-client-id"
187
187
  forceMode="react-native"
188
188
  nativeRedirectUri="myapp://auth/callback"
@@ -190,13 +190,13 @@ function App() {
190
190
  tokenStorage={tokenStorage}
191
191
  cryptoProvider={new ReactNativeCryptoProvider(ExpoCrypto)}>
192
192
  <HomeScreen />
193
- </DocyrusAuthProvider>
193
+ </KivaAuthProvider>
194
194
  );
195
195
  }
196
196
 
197
197
  function HomeScreen() {
198
- const { status, signIn, signOut } = useDocyrusAuth();
199
- const client = useDocyrusClient();
198
+ const { status, signIn, signOut } = useKivaAuth();
199
+ const client = useKivaClient();
200
200
 
201
201
  if (status === 'loading') return <Text>Loading...</Text>;
202
202
  if (status === 'unauthenticated') return <Button title="Sign In" onPress={signIn} />;
@@ -222,10 +222,10 @@ function HomeScreen() {
222
222
 
223
223
  ## Configuration
224
224
 
225
- Pass props to `DocyrusAuthProvider` to override defaults:
225
+ Pass props to `KivaAuthProvider` to override defaults:
226
226
 
227
227
  ```tsx
228
- <DocyrusAuthProvider
228
+ <KivaAuthProvider
229
229
  apiUrl="https://alpha-api.docyrus.com"
230
230
  clientId="your-oauth2-client-id"
231
231
  redirectUri="http://localhost:3000/callback"
@@ -234,12 +234,12 @@ Pass props to `DocyrusAuthProvider` to override defaults:
234
234
  forceMode="standalone"
235
235
  >
236
236
  <App />
237
- </DocyrusAuthProvider>
237
+ </KivaAuthProvider>
238
238
  ```
239
239
 
240
240
  | Prop | Type | Default | Description |
241
241
  |------|------|---------|-------------|
242
- | `apiUrl` | `string` | `https://alpha-api.docyrus.com` | Docyrus API base URL |
242
+ | `apiUrl` | `string` | `https://alpha-api.docyrus.com` | Kiva API base URL |
243
243
  | `clientId` | `string` | **Required** | OAuth2 client ID (throws if missing) |
244
244
  | `redirectUri` | `string` | `window.location.origin + callbackPath` | OAuth2 redirect URI |
245
245
  | `scopes` | `string[]` | `['offline_access', 'Read.All', ...]` | OAuth2 scopes |
@@ -248,27 +248,27 @@ Pass props to `DocyrusAuthProvider` to override defaults:
248
248
  | `nativeRedirectUri` | `string` | — | Deep link URI for React Native OAuth2 callback |
249
249
  | `openAuthSession` | `Function` | — | `WebBrowser.openAuthSessionAsync` for React Native |
250
250
  | `cryptoProvider` | `CryptoProvider` | Browser crypto | Custom crypto for PKCE (React Native) |
251
- | `storageKeyPrefix` | `string` | `docyrus_oauth2_` | localStorage key prefix |
251
+ | `storageKeyPrefix` | `string` | `kiva_oauth2_` | localStorage key prefix |
252
252
  | `tokenStorage` | `OAuth2TokenStorage` | Browser localStorage | Custom token storage (e.g., `ElectronTokenStorage`) |
253
253
  | `initialTokens` | `OAuth2Tokens` | `undefined` | Bootstrap a standalone / React Native session from existing tokens |
254
254
  | `autoRefresh` | `boolean` | `true` | When `false`, the provider never refreshes tokens itself (no pre-expiry timer, no pre-request refresh, no reactive 401 refresh). The current access token is used until replaced via `signInWithTokens`. Use when an external system owns the token lifecycle. |
255
255
  | `allowedHostOrigins` | `string[]` | `undefined` | Extra trusted iframe origins |
256
256
  | `ssr` | `boolean` | `false` | Sync access token to cookie for server components |
257
- | `ssrCookieKey` | `string` | `docyrus-token` | Cookie name for SSR token sync |
257
+ | `ssrCookieKey` | `string` | `kiva-token` | Cookie name for SSR token sync |
258
258
  | `syncRouteToHost` | `boolean` | `false` | Iframe mode: post `route-change` to the host on every history change |
259
259
  | `enableGuidyBridge` | `boolean` | `false` | Iframe mode: let the host assistant (Guidy) scan, highlight, and click this app's visible UI (see below) |
260
260
  | `guidyRoutes` | `GuidyRoute[]` | `undefined` | Iframe mode: routes Guidy may navigate the user to inside this app (see below). Requires `enableGuidyBridge` |
261
261
 
262
262
  ## Guidy Bridge (host-driven guidance)
263
263
 
264
- When an app runs embedded in the Docyrus shell, the host AI assistant (Guidy)
264
+ When an app runs embedded in the Kiva shell, the host AI assistant (Guidy)
265
265
  can guide users _through the app_ — pointing at and clicking real in-app
266
266
  buttons — once the app opts in:
267
267
 
268
268
  ```tsx
269
- <DocyrusAuthProvider apiUrl="..." clientId="..." enableGuidyBridge>
269
+ <KivaAuthProvider apiUrl="..." clientId="..." enableGuidyBridge>
270
270
  <App />
271
- </DocyrusAuthProvider>
271
+ </KivaAuthProvider>
272
272
  ```
273
273
 
274
274
  This starts a small runtime (`GuidyBridge`) that, in iframe mode only:
@@ -302,7 +302,7 @@ navigation tree as deep links and drives them through the existing host→app
302
302
  `navigation` message. Declare them statically:
303
303
 
304
304
  ```tsx
305
- <DocyrusAuthProvider
305
+ <KivaAuthProvider
306
306
  apiUrl="..."
307
307
  clientId="..."
308
308
  enableGuidyBridge
@@ -312,19 +312,19 @@ navigation tree as deep links and drives them through the existing host→app
312
312
  ]}
313
313
  >
314
314
  <App />
315
- </DocyrusAuthProvider>
315
+ </KivaAuthProvider>
316
316
  ```
317
317
 
318
318
  …or dynamically (e.g. when routes depend on permissions) with the hook:
319
319
 
320
320
  ```tsx
321
- import { useDocyrusGuidyRoutes } from "@kivacore/signin"
321
+ import { useKivaGuidyRoutes } from "@kivacore/signin"
322
322
 
323
- useDocyrusGuidyRoutes(visibleRoutes) // re-syncs whenever the array changes
323
+ useKivaGuidyRoutes(visibleRoutes) // re-syncs whenever the array changes
324
324
  ```
325
325
 
326
326
  Driving a route requires the app to handle inbound host navigation — wire
327
- `useDocyrusHostNavigation` (or `syncRouteToHost`) so the deep link reaches your
327
+ `useKivaHostNavigation` (or `syncRouteToHost`) so the deep link reaches your
328
328
  router. `path` is app-internal (e.g. `/leads`); the host prefixes it with the
329
329
  app's mount path.
330
330
 
@@ -347,11 +347,11 @@ for "Send to Docy" / "Send to Chat" buttons and menu items. Two payload kinds:
347
347
  `text` and `adaptiveCard`.
348
348
 
349
349
  ```tsx
350
- import { useDocyrusSendToDocy, useDocyrusSendToChat } from '@kivacore/signin';
350
+ import { useKivaSendToDocy, useKivaSendToChat } from '@kivacore/signin';
351
351
 
352
352
  function ShareButtons({ record }) {
353
- const sendToDocy = useDocyrusSendToDocy();
354
- const sendToChat = useDocyrusSendToChat();
353
+ const sendToDocy = useKivaSendToDocy();
354
+ const sendToChat = useKivaSendToChat();
355
355
 
356
356
  return (
357
357
  <>
@@ -400,11 +400,11 @@ Hand a draft **email** or a **calendar event** to the host — for "Send to Emai
400
400
  acknowledges, so you can show loading / success / error UI.
401
401
 
402
402
  ```tsx
403
- import { useDocyrusSendToEmail, useDocyrusSendToCalendar } from '@kivacore/signin';
403
+ import { useKivaSendToEmail, useKivaSendToCalendar } from '@kivacore/signin';
404
404
 
405
405
  function RecordActions({ record }) {
406
- const sendToEmail = useDocyrusSendToEmail();
407
- const sendToCalendar = useDocyrusSendToCalendar();
406
+ const sendToEmail = useKivaSendToEmail();
407
+ const sendToCalendar = useKivaSendToCalendar();
408
408
 
409
409
  return (
410
410
  <>
@@ -458,10 +458,10 @@ calls **through the host**. This is **proxy-only**: the app sends
458
458
  MSAL access token never crosses the frame boundary** — the app cannot read it.
459
459
 
460
460
  ```tsx
461
- import { useDocyrusMsGraph } from '@kivacore/signin';
461
+ import { useKivaMsGraph } from '@kivacore/signin';
462
462
 
463
463
  function GraphPanel() {
464
- const graph = useDocyrusMsGraph(); // MsGraphClient | null (null outside iframe mode)
464
+ const graph = useKivaMsGraph(); // MsGraphClient | null (null outside iframe mode)
465
465
 
466
466
  async function load() {
467
467
  if (!graph) return;
@@ -502,12 +502,12 @@ Host → App: { type: 'msgraph:response', requestId, ok, status, data?, error?
502
502
  > for the full host-side contract, a reference `ExternalAppManager`, and the
503
503
  > MSAL proxy implementation.
504
504
 
505
- **Vue** — the same capabilities are on `getDocyrusAuth()`:
505
+ **Vue** — the same capabilities are on `getKivaAuth()`:
506
506
  `sendToDocy`, `sendToChat`, `sendToEmail`, `sendToCalendar`, and `msGraph`.
507
507
 
508
508
  ## Hooks / Composables
509
509
 
510
- ### useDocyrusAuth()
510
+ ### useKivaAuth()
511
511
 
512
512
  Returns the full authentication context. Available in both React and Vue (`@kivacore/signin/vue`).
513
513
 
@@ -517,8 +517,8 @@ const {
517
517
  mode, // 'standalone' | 'iframe'
518
518
  client, // RestApiClient | null
519
519
  tokens, // { accessToken, refreshToken, ... } | null
520
- user, // DocyrusUser | null (auto-fetched from /v1/users/me)
521
- signIn, // () => void (redirects to Docyrus login)
520
+ user, // KivaUser | null (auto-fetched from /v1/users/me)
521
+ signIn, // () => void (redirects to Kiva login)
522
522
  signInWithTokens, // (tokens) => Promise<void> (bootstrap from device flow / external auth)
523
523
  getAuthorizationUrl, // () => Promise<string | null> (returns URL without navigating — for Electron)
524
524
  signOut, // () => Promise<void>
@@ -536,15 +536,15 @@ const {
536
536
  sendToCalendar, // (payload) => Promise<void> — hand a calendar event to the host (iframe mode)
537
537
  msGraph, // MsGraphClient | null — host-proxied Microsoft Graph client (iframe mode)
538
538
  error // Error | null
539
- } = useDocyrusAuth();
539
+ } = useKivaAuth();
540
540
  ```
541
541
 
542
- ### useDocyrusSendToDocy() / useDocyrusSendToChat() / useDocyrusSendToEmail() / useDocyrusSendToCalendar() / useDocyrusMsGraph()
542
+ ### useKivaSendToDocy() / useKivaSendToChat() / useKivaSendToEmail() / useKivaSendToCalendar() / useKivaMsGraph()
543
543
 
544
544
  React-only convenience hooks for the app→host actions above. See
545
545
  [App → Host actions](#app--host-actions).
546
546
 
547
- ### useDocyrusHostNavigation() / useDocyrusHostNotification()
547
+ ### useKivaHostNavigation() / useKivaHostNotification()
548
548
 
549
549
  React-only convenience hooks for subscribing to host postMessage events
550
550
  from within an embedded iframe/WebView. Both subscribe on mount and
@@ -553,26 +553,26 @@ handler does not need to be memoized. No-op outside iframe mode.
553
553
 
554
554
  ```tsx
555
555
  import {
556
- useDocyrusHostNavigation,
557
- useDocyrusHostNotification,
558
- type DocyrusNotification
556
+ useKivaHostNavigation,
557
+ useKivaHostNotification,
558
+ type KivaNotification
559
559
  } from '@kivacore/signin';
560
560
 
561
- useDocyrusHostNavigation(({ url }) => {
561
+ useKivaHostNavigation(({ url }) => {
562
562
  navigate(url);
563
563
  });
564
564
 
565
- useDocyrusHostNotification((notification: DocyrusNotification) => {
565
+ useKivaHostNotification((notification: KivaNotification) => {
566
566
  showToast(notification.subject, notification.message);
567
567
  });
568
568
  ```
569
569
 
570
- ### useDocyrusClient()
570
+ ### useKivaClient()
571
571
 
572
572
  Shorthand hook/composable that returns just the API client:
573
573
 
574
574
  ```tsx
575
- const client = useDocyrusClient(); // RestApiClient | null
575
+ const client = useKivaClient(); // RestApiClient | null
576
576
 
577
577
  if (client) {
578
578
  const response = await client.get('/v1/users/me');
@@ -591,7 +591,7 @@ Unstyled button that triggers sign-in. Automatically hidden when authenticated o
591
591
  <SignInButton />
592
592
 
593
593
  // With custom styling
594
- <SignInButton className="btn btn-primary" label="Log in with Docyrus" />
594
+ <SignInButton className="btn btn-primary" label="Log in with Kiva" />
595
595
 
596
596
  // Render prop for full customization
597
597
  <SignInButton>
@@ -638,28 +638,28 @@ The Electron preload script must expose `storeGet`, `storeSet`, and `storeDelete
638
638
 
639
639
  ## Bootstrap From Existing Tokens
640
640
 
641
- If you already have Docyrus `accessToken` and `refreshToken` from another flow such as device authorization, you can start a web session without redirecting through the browser login flow again.
641
+ If you already have Kiva `accessToken` and `refreshToken` from another flow such as device authorization, you can start a web session without redirecting through the browser login flow again.
642
642
 
643
643
  The simplest option is `initialTokens`:
644
644
 
645
645
  ```tsx
646
- <DocyrusAuthProvider
646
+ <KivaAuthProvider
647
647
  apiUrl="https://alpha-api.docyrus.com"
648
648
  clientId="your-oauth2-client-id"
649
649
  initialTokens={deviceFlowTokens}
650
650
  forceMode="standalone">
651
651
  <App />
652
- </DocyrusAuthProvider>
652
+ </KivaAuthProvider>
653
653
  ```
654
654
 
655
655
  Or bootstrap later with `signInWithTokens()`:
656
656
 
657
657
  ```tsx
658
658
  import { useEffect } from 'react';
659
- import { useDocyrusAuth } from '@kivacore/signin';
659
+ import { useKivaAuth } from '@kivacore/signin';
660
660
 
661
661
  function TokenHandoff({ deviceFlowTokens }) {
662
- const { signInWithTokens } = useDocyrusAuth();
662
+ const { signInWithTokens } = useKivaAuth();
663
663
 
664
664
  useEffect(() => {
665
665
  if (!deviceFlowTokens) return;
@@ -679,14 +679,14 @@ function TokenHandoff({ deviceFlowTokens }) {
679
679
  Used when the app runs directly in the browser (not in an iframe). The flow:
680
680
 
681
681
  1. User clicks sign-in
682
- 2. Page redirects to Docyrus authorization endpoint
682
+ 2. Page redirects to Kiva authorization endpoint
683
683
  3. After login, redirects back with authorization code
684
684
  4. Provider automatically exchanges code for tokens
685
685
  5. Tokens stored in localStorage (or custom `tokenStorage`), auto-refreshed before expiry
686
686
 
687
687
  ### Iframe Mode (postMessage)
688
688
 
689
- Used when the app is embedded in an iframe on `*.docyrus.app`. The flow:
689
+ Used when the app is embedded in an iframe on `*.kiva.app` or `*.docyrus.app`. The flow:
690
690
 
691
691
  1. Provider detects iframe environment and validates host origin
692
692
  2. Host sends `{ type: 'signin', accessToken, refreshToken }` via `postMessage`
@@ -703,7 +703,7 @@ refresh performed by the app. Iframe token refresh still asks the host for new
703
703
  tokens over postMessage.
704
704
 
705
705
  The accepted hosts are `localhost`, `127.0.0.1`, and `[::1]` over HTTP or HTTPS
706
- on any port, and `docyrus.com`, `attornaid.com`, and their subdomains over HTTPS.
706
+ on any port, and `kiva.app`, `docyrus.com`, `attornaid.com`, and their subdomains over HTTPS.
707
707
  Supply a base URL without credentials, a query, or a fragment. Apps opened
708
708
  without `embedded=true` and embedded apps whose URL omits `apiUrl` use the
709
709
  provider's configured `apiUrl` or the default `https://alpha-api.docyrus.com`.
@@ -731,7 +731,7 @@ that the embedded app can subscribe to:
731
731
  | Message | Payload | Purpose |
732
732
  |---------|---------|---------|
733
733
  | `{ type: 'navigation', url }` | `url: string` | Host asks the app to navigate (e.g. deep-link from a host menu) |
734
- | `{ type: 'notification', notification }` | `DocyrusNotification` | Host pushes a notification to the embedded app |
734
+ | `{ type: 'notification', notification }` | `KivaNotification` | Host pushes a notification to the embedded app |
735
735
 
736
736
  The embedded app can also **initiate** app→host actions over the same channel —
737
737
  Send to Docy, Send to Chat, and host-proxied Microsoft Graph calls. See
@@ -742,18 +742,18 @@ always invoked, no need to memoize):
742
742
 
743
743
  ```tsx
744
744
  import {
745
- useDocyrusHostNavigation,
746
- useDocyrusHostNotification
745
+ useKivaHostNavigation,
746
+ useKivaHostNotification
747
747
  } from '@kivacore/signin';
748
748
 
749
749
  function Shell() {
750
750
  const navigate = useNavigate();
751
751
 
752
- useDocyrusHostNavigation(({ url }) => {
752
+ useKivaHostNavigation(({ url }) => {
753
753
  navigate(url);
754
754
  });
755
755
 
756
- useDocyrusHostNotification((notification) => {
756
+ useKivaHostNotification((notification) => {
757
757
  toast({
758
758
  title: notification.subject,
759
759
  description: notification.message
@@ -770,9 +770,9 @@ unsubscribe function:
770
770
  ```vue
771
771
  <script setup lang="ts">
772
772
  import { onMounted, onUnmounted } from 'vue';
773
- import { getDocyrusAuth } from '@kivacore/signin/vue';
773
+ import { getKivaAuth } from '@kivacore/signin/vue';
774
774
 
775
- const auth = getDocyrusAuth();
775
+ const auth = getKivaAuth();
776
776
  let stopNav: (() => void) | undefined;
777
777
  let stopNote: (() => void) | undefined;
778
778
 
@@ -811,18 +811,18 @@ so every route change in the embedded app — regardless of router
811
811
  (React Router, TanStack Router, Next, plain history) — posts a message:
812
812
 
813
813
  ```tsx
814
- <DocyrusAuthProvider apiUrl="..." clientId="..." syncRouteToHost>
814
+ <KivaAuthProvider apiUrl="..." clientId="..." syncRouteToHost>
815
815
  <App />
816
- </DocyrusAuthProvider>
816
+ </KivaAuthProvider>
817
817
  ```
818
818
 
819
819
  Or opt in scoped to a component with the hook:
820
820
 
821
821
  ```tsx
822
- import { useDocyrusHostRouteSync } from '@kivacore/signin';
822
+ import { useKivaHostRouteSync } from '@kivacore/signin';
823
823
 
824
824
  function Shell() {
825
- useDocyrusHostRouteSync();
825
+ useKivaHostRouteSync();
826
826
  return <Routes />;
827
827
  }
828
828
  ```
@@ -831,10 +831,10 @@ Or report routes manually from a router subscription (avoids history
831
831
  patching, lets the router be the source of truth):
832
832
 
833
833
  ```tsx
834
- import { useDocyrusAuth } from '@kivacore/signin';
834
+ import { useKivaAuth } from '@kivacore/signin';
835
835
 
836
836
  function RouteReporter() {
837
- const { notifyRouteChange } = useDocyrusAuth();
837
+ const { notifyRouteChange } = useKivaAuth();
838
838
  const location = useLocation(); // React Router / TanStack Router / etc.
839
839
 
840
840
  useEffect(() => {
@@ -866,14 +866,14 @@ The host decides how to honour the request (push/replace its own router, open a
866
866
  new tab, etc.). Unlike `route-change` — which passively reports where the app
867
867
  already is — this is an explicit request to move the host.
868
868
 
869
- **React** — call `requestHostNavigation` from `useDocyrusAuth()`, or use the
870
- `useDocyrusRequestHostNavigation` convenience hook:
869
+ **React** — call `requestHostNavigation` from `useKivaAuth()`, or use the
870
+ `useKivaRequestHostNavigation` convenience hook:
871
871
 
872
872
  ```tsx
873
- import { useDocyrusRequestHostNavigation } from '@kivacore/signin';
873
+ import { useKivaRequestHostNavigation } from '@kivacore/signin';
874
874
 
875
875
  function OpenSettingsButton() {
876
- const requestHostNavigation = useDocyrusRequestHostNavigation();
876
+ const requestHostNavigation = useKivaRequestHostNavigation();
877
877
 
878
878
  return (
879
879
  <button onClick={() => requestHostNavigation('/settings/billing')}>
@@ -885,7 +885,7 @@ function OpenSettingsButton() {
885
885
 
886
886
  ```tsx
887
887
  // With options
888
- const { requestHostNavigation } = useDocyrusAuth();
888
+ const { requestHostNavigation } = useKivaAuth();
889
889
 
890
890
  requestHostNavigation('/reports/q3', { replace: true });
891
891
  requestHostNavigation('https://docs.docyrus.com', { newTab: true });
@@ -895,9 +895,9 @@ requestHostNavigation('https://docs.docyrus.com', { newTab: true });
895
895
 
896
896
  ```vue
897
897
  <script setup lang="ts">
898
- import { getDocyrusAuth } from '@kivacore/signin/vue';
898
+ import { getKivaAuth } from '@kivacore/signin/vue';
899
899
 
900
- const auth = getDocyrusAuth();
900
+ const auth = getKivaAuth();
901
901
 
902
902
  function goToBilling() {
903
903
  auth.requestHostNavigation('/settings/billing');
@@ -914,14 +914,14 @@ Enable `ssr` on the client-side provider to sync the access token to a cookie. T
914
914
  ### 1. Client — Enable SSR in AuthProvider
915
915
 
916
916
  ```tsx
917
- <DocyrusAuthProvider
917
+ <KivaAuthProvider
918
918
  apiUrl="https://alpha-api.docyrus.com"
919
919
  clientId="your-oauth2-client-id"
920
920
  scopes={['offline_access', 'Read.All', 'Users.Read']}
921
921
  callbackPath="/auth/callback"
922
922
  ssr>
923
923
  {children}
924
- </DocyrusAuthProvider>
924
+ </KivaAuthProvider>
925
925
  ```
926
926
 
927
927
  The cookie is automatically **set** on login and token refresh, **cleared** on sign out, and **expires** with the token (via `max-age`).
@@ -1016,7 +1016,7 @@ export async function getUser() {
1016
1016
  ```tsx
1017
1017
  import { getTokenFromCookie } from '@kivacore/signin';
1018
1018
 
1019
- const token = getTokenFromCookie(); // reads 'docyrus-token' cookie
1019
+ const token = getTokenFromCookie(); // reads 'kiva-token' cookie
1020
1020
  const token = getTokenFromCookie('custom-key'); // custom cookie name
1021
1021
  ```
1022
1022
 
@@ -1028,7 +1028,7 @@ The provider auto-fetches the current user from `/v1/users/me` after authenticat
1028
1028
 
1029
1029
  ```tsx
1030
1030
  function DataSourceView({ dataSourceId }: { dataSourceId: string }) {
1031
- const { user, hasRole, hasPermission } = useDocyrusAuth();
1031
+ const { user, hasRole, hasPermission } = useKivaAuth();
1032
1032
 
1033
1033
  if (!user) return <div>Loading user...</div>;
1034
1034
 
@@ -1060,9 +1060,9 @@ function DataSourceView({ dataSourceId }: { dataSourceId: string }) {
1060
1060
 
1061
1061
  ```tsx
1062
1062
  import { hasRole, hasPermission, getAllowedOperations } from '@kivacore/signin/core';
1063
- import type { DocyrusUser } from '@kivacore/signin/core';
1063
+ import type { KivaUser } from '@kivacore/signin/core';
1064
1064
 
1065
- function checkAccess(user: DocyrusUser) {
1065
+ function checkAccess(user: KivaUser) {
1066
1066
  // hasRole returns true when role arg is null/undefined (no requirement)
1067
1067
  hasRole(user, null); // true
1068
1068
  hasRole(user, 'super_admin'); // checks slug or uid
@@ -1124,7 +1124,7 @@ hasPermission(user, 'allow', { aiToolId });
1124
1124
  If roles or permissions change while the app is running:
1125
1125
 
1126
1126
  ```tsx
1127
- const { refreshUser } = useDocyrusAuth();
1127
+ const { refreshUser } = useKivaAuth();
1128
1128
 
1129
1129
  // After a role change
1130
1130
  await refreshUser();
@@ -1149,9 +1149,9 @@ import {
1149
1149
 
1150
1150
  ```tsx
1151
1151
  import {
1152
- DocyrusAuthProvider,
1153
- useDocyrusAuth,
1154
- useDocyrusClient,
1152
+ KivaAuthProvider,
1153
+ useKivaAuth,
1154
+ useKivaClient,
1155
1155
  SignInButton,
1156
1156
  AuthManager,
1157
1157
  detectAuthMode
@@ -1162,13 +1162,30 @@ import {
1162
1162
 
1163
1163
  ```tsx
1164
1164
  import {
1165
- DocyrusAuthProvider,
1166
- useDocyrusAuth,
1167
- useDocyrusClient,
1165
+ KivaAuthProvider,
1166
+ useKivaAuth,
1167
+ useKivaClient,
1168
1168
  SignInButton
1169
1169
  } from '@kivacore/signin/vue';
1170
1170
  ```
1171
1171
 
1172
+ ## Migrating from the Docyrus names
1173
+
1174
+ Earlier versions used Docyrus in export names, storage keys and the SSR cookie. The old export names still work but are deprecated, and they will be removed in a future major release.
1175
+
1176
+ | Before | Now |
1177
+ | --- | --- |
1178
+ | `DocyrusAuthProvider`, `DocyrusAuthContext`, `useDocyrusAuth`, `useDocyrusClient` | `KivaAuthProvider`, `KivaAuthContext`, `useKivaAuth`, `useKivaClient` |
1179
+ | `useDocyrusHostNavigation`, `useDocyrusSendToDocy` and the other `useDocyrus*` hooks | `useKivaHostNavigation`, `useKivaSendToDocy`, … |
1180
+ | `getDocyrusAuth`, `getDocyrusClient` (Vue) | `getKivaAuth`, `getKivaClient` |
1181
+ | `DocyrusUser`, `DocyrusAuthConfig`, `DocyrusSharePayload` and the other `Docyrus*` types | `KivaUser`, `KivaAuthConfig`, `KivaSharePayload`, … |
1182
+
1183
+ Users stay signed in after the upgrade:
1184
+
1185
+ - Tokens saved under `docyrus_oauth2_*` move to `kiva_oauth2_*` the first time they are read (browser and Electron storage).
1186
+ - The SSR cookie is now `kiva-token`. With the default cookie name, `getSession`, `createServerClient`, `getMiddlewareSession`, `createMiddlewareClient` and `authMiddleware` still read the old `docyrus-token` cookie, and the client deletes it on its next token sync. If your own code reads the cookie by name, read `kiva-token`.
1187
+ - Iframe mode trusts `*.kiva.app` hosts as well as `*.docyrus.app`, and a host-provided `apiUrl` on `kiva.app` is accepted alongside `docyrus.com`.
1188
+
1172
1189
  ## Development
1173
1190
 
1174
1191
  ```bash