@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.
@@ -0,0 +1,122 @@
1
+ import { OAuth2Tokens } from '@kivacore/api-client';
2
+ import { a as KivaAuthConfig, y as GuidyElementsMessage, H as GuidyRoutesMessage, z as GuidyPointAckMessage, F as GuidyRoute, w as GuidyCommandMessage, p as AuthMode } from './types-DF2C4eb6.js';
3
+
4
+ /**
5
+ * Standalone OAuth2 authorization code flow with PKCE via page redirect.
6
+ * Wraps api-client's OAuth2Client and BrowserOAuth2TokenStorage.
7
+ */
8
+ declare class StandaloneOAuth2Auth {
9
+ private oauth2Client;
10
+ private storage;
11
+ private callbackPath;
12
+ constructor(config?: KivaAuthConfig);
13
+ /**
14
+ * Check if the current page URL is the OAuth2 callback.
15
+ * Called on app initialization to detect returning from the auth server.
16
+ */
17
+ isCallbackUrl(): boolean;
18
+ /**
19
+ * Initiate the OAuth2 authorization code flow.
20
+ * Stores the current URL for post-auth redirect, then navigates
21
+ * the page to the authorization endpoint.
22
+ *
23
+ * PKCE state (codeVerifier, state) is stored in localStorage
24
+ * by the OAuth2Client and survives the page redirect.
25
+ */
26
+ initiateLogin(): Promise<void>;
27
+ /**
28
+ * Get the authorization URL without navigating.
29
+ * Useful for Electron apps that open the URL in an external browser.
30
+ * PKCE state is stored in storage just like initiateLogin().
31
+ */
32
+ getAuthorizationUrl(): Promise<string>;
33
+ /**
34
+ * Handle the OAuth2 callback URL.
35
+ * Reads PKCE state from localStorage, validates the state param,
36
+ * exchanges the authorization code for tokens, and stores them.
37
+ */
38
+ handleCallback(): Promise<OAuth2Tokens>;
39
+ /**
40
+ * Get the URL the user was on before the OAuth redirect.
41
+ * Clears the stored value after retrieval.
42
+ */
43
+ getReturnUrl(): string | null;
44
+ /** Get currently stored tokens (e.g., on page reload). */
45
+ getStoredTokens(): Promise<OAuth2Tokens | null>;
46
+ /** Persist externally obtained tokens for immediate authenticated use. */
47
+ setTokens(tokens: OAuth2Tokens): Promise<void>;
48
+ /** Check if the stored token is expired (with 60s buffer). */
49
+ isTokenExpired(): Promise<boolean>;
50
+ /** Refresh the access token using the stored refresh token. */
51
+ refreshToken(): Promise<OAuth2Tokens>;
52
+ /** Get a valid access token, refreshing if needed. */
53
+ getValidAccessToken(): Promise<string>;
54
+ /** Logout: revoke token and clear storage. */
55
+ logout(): Promise<void>;
56
+ }
57
+
58
+ /** Post an app → host message (elements, routes, or a point ack). */
59
+ type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyRoutesMessage | GuidyPointAckMessage) => void;
60
+ /**
61
+ * Runs inside an embedded Kiva app and lets the host assistant (Guidy)
62
+ * inspect and drive the app's visible UI over the existing postMessage
63
+ * channel.
64
+ *
65
+ * It only ever exposes labels/ids of already-visible interactive elements and
66
+ * only executes a fixed command vocabulary (scan / point / click) — the same
67
+ * exposure profile the host assistant already has on its own chrome. No
68
+ * arbitrary script is accepted from the host.
69
+ *
70
+ * Protocol (paired with the host's ExternalAppManager):
71
+ * - App → Host: `guidy:elements` (pushed on start, route change, mutation)
72
+ * - App → Host: `guidy:routes` (pushed on start and when routes change)
73
+ * - Host → App: `guidy:scan` → app re-posts `guidy:elements` + `guidy:routes`
74
+ * - Host → App: `guidy:point` → app scrolls/highlights/(clicks), then
75
+ * - App → Host: `guidy:point-ack`
76
+ */
77
+ declare class GuidyBridge {
78
+ private send;
79
+ private routes;
80
+ private started;
81
+ private observer;
82
+ private scanTimer;
83
+ private routeListener;
84
+ private highlightTimer;
85
+ private clickTimer;
86
+ private annotationTimer;
87
+ constructor(send: GuidyBridgeSender, routes?: GuidyRoute[]);
88
+ /** Replace the declared navigable routes and re-post them to the host. */
89
+ setRoutes(routes: GuidyRoute[]): void;
90
+ /**
91
+ * Begin reporting the element inventory and watching for changes.
92
+ * Idempotent. No-op outside a browser document.
93
+ */
94
+ start(): void;
95
+ /** Stop watching and tear down any injected overlay. Idempotent. */
96
+ stop(): void;
97
+ /** Dispatch a host `guidy:*` command. Wired to `IframeAuth.onGuidyCommand`. */
98
+ handleCommand(message: GuidyCommandMessage): void;
99
+ /** Collect every visible anchor/button that exposes an id and a label. */
100
+ private collectElements;
101
+ private postElements;
102
+ private postRoutes;
103
+ private scheduleScan;
104
+ private handlePoint;
105
+ private ensureStyle;
106
+ private highlight;
107
+ private clearHighlight;
108
+ private annotate;
109
+ private clearAnnotation;
110
+ private clearTimer;
111
+ }
112
+
113
+ /**
114
+ * Detect whether the app is inside an iframe from a trusted *.docyrus.app host
115
+ * or running as a standalone page.
116
+ *
117
+ * If we are in an iframe but NOT from a trusted origin, we fall back
118
+ * to standalone mode (graceful degradation).
119
+ */
120
+ declare function detectAuthMode(allowedOrigins?: string[], allowedPattern?: RegExp): AuthMode;
121
+
122
+ export { GuidyBridge as G, StandaloneOAuth2Auth as S, detectAuthMode as d };
@@ -1,11 +1,11 @@
1
1
  import { OAuth2Tokens, RestApiClient } from '@kivacore/api-client';
2
- import { D as DocyrusAuthConfig, c as AuthMode, e as AuthStatus, o as DocyrusUser, G as GuidyRoute, R as RouteChangePayload, w as HostNavigationRequestOptions, m as DocyrusSharePayload, i as DocyrusEmailPayload, h as DocyrusCalendarEventPayload, p as MsGraphClient, H as HostNavigationHandler, v as HostNotificationHandler, k as DocyrusRole, u as PermissionScope, P as PermissionConfig } from './types-DmIgZa_v.js';
2
+ import { a as KivaAuthConfig, p as AuthMode, q as AuthStatus, k as KivaUser, F as GuidyRoute, a1 as RouteChangePayload, M as HostNavigationRequestOptions, i as KivaSharePayload, d as KivaEmailPayload, c as KivaCalendarEventPayload, S as MsGraphClient, J as HostNavigationHandler, N as HostNotificationHandler, g as KivaRole, a0 as PermissionScope, $ as PermissionConfig } from './types-DF2C4eb6.js';
3
3
 
4
4
  type AuthStateListener = (state: {
5
5
  status: AuthStatus;
6
6
  tokens: OAuth2Tokens | null;
7
7
  error: Error | null;
8
- user: DocyrusUser | null;
8
+ user: KivaUser | null;
9
9
  }) => void;
10
10
  /**
11
11
  * Unified authentication manager.
@@ -37,7 +37,7 @@ declare class AuthManager {
37
37
  private navigationHandlers;
38
38
  private notificationHandlers;
39
39
  private config;
40
- constructor(config?: DocyrusAuthConfig);
40
+ constructor(config?: KivaAuthConfig);
41
41
  /** Whether the provider may refresh tokens on its own. Default: true. */
42
42
  private get autoRefreshEnabled();
43
43
  getMode(): AuthMode;
@@ -45,7 +45,7 @@ declare class AuthManager {
45
45
  getTokens(): OAuth2Tokens | null;
46
46
  getClient(): RestApiClient | null;
47
47
  getError(): Error | null;
48
- getUser(): DocyrusUser | null;
48
+ getUser(): KivaUser | null;
49
49
  /** Re-fetch the current user from the API. No-op if not authenticated. */
50
50
  refreshUser(): Promise<void>;
51
51
  subscribe(listener: AuthStateListener): () => void;
@@ -99,22 +99,22 @@ declare class AuthManager {
99
99
  * Iframe/WebView mode: hand a payload to the host AI assistant (Docy).
100
100
  * Resolves when the host acknowledges delivery. Rejects outside iframe mode.
101
101
  */
102
- sendToDocy(payload: DocyrusSharePayload): Promise<void>;
102
+ sendToDocy(payload: KivaSharePayload): Promise<void>;
103
103
  /**
104
104
  * Iframe/WebView mode: hand a payload to the host team-chat app.
105
105
  * Resolves when the host acknowledges delivery. Rejects outside iframe mode.
106
106
  */
107
- sendToChat(payload: DocyrusSharePayload): Promise<void>;
107
+ sendToChat(payload: KivaSharePayload): Promise<void>;
108
108
  /**
109
109
  * Iframe/WebView mode: hand a draft email to the host. Resolves when the
110
110
  * host acknowledges. Rejects outside iframe mode.
111
111
  */
112
- sendToEmail(payload: DocyrusEmailPayload): Promise<void>;
112
+ sendToEmail(payload: KivaEmailPayload): Promise<void>;
113
113
  /**
114
114
  * Iframe/WebView mode: hand a calendar event to the host. Resolves when the
115
115
  * host acknowledges. Rejects outside iframe mode.
116
116
  */
117
- sendToCalendar(payload: DocyrusCalendarEventPayload): Promise<void>;
117
+ sendToCalendar(payload: KivaCalendarEventPayload): Promise<void>;
118
118
  /**
119
119
  * Iframe/WebView mode: get the client for the host's Microsoft Graph (MSAL)
120
120
  * session. Returns `null` outside iframe mode.
@@ -226,7 +226,7 @@ declare class AuthManager {
226
226
  /**
227
227
  * Get all roles for a user (primaryRole + roles array), deduplicated by uid.
228
228
  */
229
- declare function getAllRoles(user: DocyrusUser | null | undefined): DocyrusRole[];
229
+ declare function getAllRoles(user: KivaUser | null | undefined): KivaRole[];
230
230
  /**
231
231
  * Check if the user has a specific role.
232
232
  *
@@ -234,7 +234,7 @@ declare function getAllRoles(user: DocyrusUser | null | undefined): DocyrusRole[
234
234
  * - Checks both primaryRole and roles array.
235
235
  * - Matches by slug or uid.
236
236
  */
237
- declare function hasRole(user: DocyrusUser | null | undefined, role: string | string[] | null | undefined): boolean;
237
+ declare function hasRole(user: KivaUser | null | undefined, role: string | string[] | null | undefined): boolean;
238
238
  /**
239
239
  * Every operation the user is granted within a scope, merged across roles.
240
240
  *
@@ -244,7 +244,7 @@ declare function hasRole(user: DocyrusUser | null | undefined, role: string | st
244
244
  * Role shortcuts are deliberately excluded — this reports what the user's rules
245
245
  * actually carry. Use {@link hasPermission} for an access decision.
246
246
  */
247
- declare function getAllowedOperations(user: DocyrusUser | null | undefined, scope?: string | null | PermissionScope): string[];
247
+ declare function getAllowedOperations(user: KivaUser | null | undefined, scope?: string | null | PermissionScope): string[];
248
248
  /**
249
249
  * Check if the user has permission for an operation.
250
250
  *
@@ -259,13 +259,13 @@ declare function getAllowedOperations(user: DocyrusUser | null | undefined, scop
259
259
  * 4. Always-permitted data sources (configurable)
260
260
  * 5. The user's permissions for the scope (`permissions`, falling back to `aclRules`)
261
261
  */
262
- declare function hasPermission(user: DocyrusUser | null | undefined, operation: string, scope?: string | null | PermissionScope, config?: PermissionConfig): boolean;
262
+ declare function hasPermission(user: KivaUser | null | undefined, operation: string, scope?: string | null | PermissionScope, config?: PermissionConfig): boolean;
263
263
 
264
264
  declare const DEFAULT_API_URL = "https://alpha-api.docyrus.com";
265
265
  declare const DEFAULT_OAUTH_SCOPES: string[];
266
266
  declare const DEFAULT_CALLBACK_PATH = "/auth/callback";
267
267
  /** Default cookie name for SSR token sync */
268
- declare const DEFAULT_SSR_COOKIE_KEY = "docyrus-token";
268
+ declare const DEFAULT_SSR_COOKIE_KEY = "kiva-token";
269
269
 
270
- export { AuthManager as A, DEFAULT_API_URL as D, DEFAULT_OAUTH_SCOPES as a, getAllowedOperations as b, hasRole as c, DEFAULT_CALLBACK_PATH as d, DEFAULT_SSR_COOKIE_KEY as e, getAllRoles as g, hasPermission as h };
271
- export type { AuthStateListener as f };
270
+ export { AuthManager as A, DEFAULT_API_URL as D, DEFAULT_CALLBACK_PATH as b, DEFAULT_OAUTH_SCOPES as c, getAllowedOperations as d, hasRole as e, DEFAULT_SSR_COOKIE_KEY as f, getAllRoles as g, hasPermission as h };
271
+ export type { AuthStateListener as a };
@@ -1,124 +1,33 @@
1
- export { A as AuthManager, f as AuthStateListener, D as DEFAULT_API_URL, d as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, g as getAllRoles, b as getAllowedOperations, h as hasPermission, c as hasRole } from './constants-jx2_MXlr.js';
2
- import { OAuth2Tokens } from '@kivacore/api-client';
3
- import { D as DocyrusAuthConfig, T as GuidyElementsMessage, W as GuidyRoutesMessage, U as GuidyPointAckMessage, G as GuidyRoute, Q as GuidyCommandMessage, c as AuthMode } from './types-DmIgZa_v.js';
4
- export { A as AclOperation, a as AclTargetType, b as AdaptiveCard, x as AppNavigationRequestMessage, y as AppRouteChangeMessage, e as AuthStatus, C as CalendarSendAckMessage, z as CalendarSendMessage, B as ChatSendAckMessage, E as ChatSendMessage, F as DocySendAckMessage, I as DocySendMessage, f as DocyrusAclRule, g as DocyrusAuthContextValue, h as DocyrusCalendarEventPayload, i as DocyrusEmailPayload, J as DocyrusNotification, j as DocyrusPermission, k as DocyrusRole, l as DocyrusShareAdaptiveCardPayload, m as DocyrusSharePayload, n as DocyrusShareTextPayload, o as DocyrusUser, K as EmailSendAckMessage, L as EmailSendMessage, N as GuidyCommandHandler, S as GuidyElement, V as GuidyPointMessage, X as GuidyScanMessage, H as HostNavigationHandler, Y as HostNavigationMessage, w as HostNavigationRequestOptions, v as HostNotificationHandler, Z as HostNotificationMessage, _ as HostSignInMessage, $ as IframeAuth, M as MsGraphAccount, p as MsGraphClient, q as MsGraphRequest, a0 as MsGraphRequestMessage, r as MsGraphRequestOptions, s as MsGraphResponse, a1 as MsGraphResponseMessage, t as MsGraphStatus, a2 as MsGraphStatusRequestMessage, a3 as MsGraphStatusResponseMessage, P as PermissionConfig, u as PermissionScope, R as RouteChangePayload, a4 as TokenRefreshRequestMessage } from './types-DmIgZa_v.js';
1
+ export { A as AuthManager, a as AuthStateListener, D as DEFAULT_API_URL, b as DEFAULT_CALLBACK_PATH, c as DEFAULT_OAUTH_SCOPES, g as getAllRoles, d as getAllowedOperations, h as hasPermission, e as hasRole } from './constants-DbICcNnA.js';
2
+ export { G as GuidyBridge, S as StandaloneOAuth2Auth, d as detectAuthMode } from './auth-detector-CRKg56LT.js';
3
+ import { K as KivaAclRule, a as KivaAuthConfig, b as KivaAuthContextValue, c as KivaCalendarEventPayload, d as KivaEmailPayload, e as KivaNotification, f as KivaPermission, g as KivaRole, h as KivaShareAdaptiveCardPayload, i as KivaSharePayload, j as KivaShareTextPayload, k as KivaUser } from './types-DF2C4eb6.js';
4
+ export { A as AclOperation, l as AclTargetType, m as AdaptiveCard, n as AppNavigationRequestMessage, o as AppRouteChangeMessage, p as AuthMode, q as AuthStatus, C as CalendarSendAckMessage, r as CalendarSendMessage, s as ChatSendAckMessage, t as ChatSendMessage, D as DocySendAckMessage, u as DocySendMessage, E as EmailSendAckMessage, v as EmailSendMessage, G as GuidyCommandHandler, w as GuidyCommandMessage, x as GuidyElement, y as GuidyElementsMessage, z as GuidyPointAckMessage, B as GuidyPointMessage, F as GuidyRoute, H as GuidyRoutesMessage, I as GuidyScanMessage, J as HostNavigationHandler, L as HostNavigationMessage, M as HostNavigationRequestOptions, N as HostNotificationHandler, O as HostNotificationMessage, P as HostSignInMessage, Q as IframeAuth, R as MsGraphAccount, S as MsGraphClient, T as MsGraphRequest, U as MsGraphRequestMessage, V as MsGraphRequestOptions, W as MsGraphResponse, X as MsGraphResponseMessage, Y as MsGraphStatus, Z as MsGraphStatusRequestMessage, _ as MsGraphStatusResponseMessage, $ as PermissionConfig, a0 as PermissionScope, a1 as RouteChangePayload, a2 as TokenRefreshRequestMessage } from './types-DF2C4eb6.js';
5
+ import '@kivacore/api-client';
5
6
 
6
- /**
7
- * Standalone OAuth2 authorization code flow with PKCE via page redirect.
8
- * Wraps api-client's OAuth2Client and BrowserOAuth2TokenStorage.
9
- */
10
- declare class StandaloneOAuth2Auth {
11
- private oauth2Client;
12
- private storage;
13
- private callbackPath;
14
- constructor(config?: DocyrusAuthConfig);
15
- /**
16
- * Check if the current page URL is the OAuth2 callback.
17
- * Called on app initialization to detect returning from the auth server.
18
- */
19
- isCallbackUrl(): boolean;
20
- /**
21
- * Initiate the OAuth2 authorization code flow.
22
- * Stores the current URL for post-auth redirect, then navigates
23
- * the page to the authorization endpoint.
24
- *
25
- * PKCE state (codeVerifier, state) is stored in localStorage
26
- * by the OAuth2Client and survives the page redirect.
27
- */
28
- initiateLogin(): Promise<void>;
29
- /**
30
- * Get the authorization URL without navigating.
31
- * Useful for Electron apps that open the URL in an external browser.
32
- * PKCE state is stored in storage just like initiateLogin().
33
- */
34
- getAuthorizationUrl(): Promise<string>;
35
- /**
36
- * Handle the OAuth2 callback URL.
37
- * Reads PKCE state from localStorage, validates the state param,
38
- * exchanges the authorization code for tokens, and stores them.
39
- */
40
- handleCallback(): Promise<OAuth2Tokens>;
41
- /**
42
- * Get the URL the user was on before the OAuth redirect.
43
- * Clears the stored value after retrieval.
44
- */
45
- getReturnUrl(): string | null;
46
- /** Get currently stored tokens (e.g., on page reload). */
47
- getStoredTokens(): Promise<OAuth2Tokens | null>;
48
- /** Persist externally obtained tokens for immediate authenticated use. */
49
- setTokens(tokens: OAuth2Tokens): Promise<void>;
50
- /** Check if the stored token is expired (with 60s buffer). */
51
- isTokenExpired(): Promise<boolean>;
52
- /** Refresh the access token using the stored refresh token. */
53
- refreshToken(): Promise<OAuth2Tokens>;
54
- /** Get a valid access token, refreshing if needed. */
55
- getValidAccessToken(): Promise<string>;
56
- /** Logout: revoke token and clear storage. */
57
- logout(): Promise<void>;
58
- }
7
+ /** @deprecated Use `KivaAuthConfig` instead. */
8
+ type DocyrusAuthConfig = KivaAuthConfig;
9
+ /** @deprecated Use `KivaAuthContextValue` instead. */
10
+ type DocyrusAuthContextValue = KivaAuthContextValue;
11
+ /** @deprecated Use `KivaUser` instead. */
12
+ type DocyrusUser = KivaUser;
13
+ /** @deprecated Use `KivaRole` instead. */
14
+ type DocyrusRole = KivaRole;
15
+ /** @deprecated Use `KivaAclRule` instead. */
16
+ type DocyrusAclRule = KivaAclRule;
17
+ /** @deprecated Use `KivaPermission` instead. */
18
+ type DocyrusPermission = KivaPermission;
19
+ /** @deprecated Use `KivaNotification` instead. */
20
+ type DocyrusNotification = KivaNotification;
21
+ /** @deprecated Use `KivaSharePayload` instead. */
22
+ type DocyrusSharePayload = KivaSharePayload;
23
+ /** @deprecated Use `KivaShareTextPayload` instead. */
24
+ type DocyrusShareTextPayload = KivaShareTextPayload;
25
+ /** @deprecated Use `KivaShareAdaptiveCardPayload` instead. */
26
+ type DocyrusShareAdaptiveCardPayload = KivaShareAdaptiveCardPayload;
27
+ /** @deprecated Use `KivaEmailPayload` instead. */
28
+ type DocyrusEmailPayload = KivaEmailPayload;
29
+ /** @deprecated Use `KivaCalendarEventPayload` instead. */
30
+ type DocyrusCalendarEventPayload = KivaCalendarEventPayload;
59
31
 
60
- /** Post an app → host message (elements, routes, or a point ack). */
61
- type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyRoutesMessage | GuidyPointAckMessage) => void;
62
- /**
63
- * Runs inside an embedded Docyrus app and lets the host assistant (Guidy)
64
- * inspect and drive the app's visible UI over the existing postMessage
65
- * channel.
66
- *
67
- * It only ever exposes labels/ids of already-visible interactive elements and
68
- * only executes a fixed command vocabulary (scan / point / click) — the same
69
- * exposure profile the host assistant already has on its own chrome. No
70
- * arbitrary script is accepted from the host.
71
- *
72
- * Protocol (paired with the host's ExternalAppManager):
73
- * - App → Host: `guidy:elements` (pushed on start, route change, mutation)
74
- * - App → Host: `guidy:routes` (pushed on start and when routes change)
75
- * - Host → App: `guidy:scan` → app re-posts `guidy:elements` + `guidy:routes`
76
- * - Host → App: `guidy:point` → app scrolls/highlights/(clicks), then
77
- * - App → Host: `guidy:point-ack`
78
- */
79
- declare class GuidyBridge {
80
- private send;
81
- private routes;
82
- private started;
83
- private observer;
84
- private scanTimer;
85
- private routeListener;
86
- private highlightTimer;
87
- private clickTimer;
88
- private annotationTimer;
89
- constructor(send: GuidyBridgeSender, routes?: GuidyRoute[]);
90
- /** Replace the declared navigable routes and re-post them to the host. */
91
- setRoutes(routes: GuidyRoute[]): void;
92
- /**
93
- * Begin reporting the element inventory and watching for changes.
94
- * Idempotent. No-op outside a browser document.
95
- */
96
- start(): void;
97
- /** Stop watching and tear down any injected overlay. Idempotent. */
98
- stop(): void;
99
- /** Dispatch a host `guidy:*` command. Wired to `IframeAuth.onGuidyCommand`. */
100
- handleCommand(message: GuidyCommandMessage): void;
101
- /** Collect every visible anchor/button that exposes an id and a label. */
102
- private collectElements;
103
- private postElements;
104
- private postRoutes;
105
- private scheduleScan;
106
- private handlePoint;
107
- private ensureStyle;
108
- private highlight;
109
- private clearHighlight;
110
- private annotate;
111
- private clearAnnotation;
112
- private clearTimer;
113
- }
114
-
115
- /**
116
- * Detect whether the app is inside an iframe from a trusted *.docyrus.app host
117
- * or running as a standalone page.
118
- *
119
- * If we are in an iframe but NOT from a trusted origin, we fall back
120
- * to standalone mode (graceful degradation).
121
- */
122
- declare function detectAuthMode(allowedOrigins?: string[], allowedPattern?: RegExp): AuthMode;
123
-
124
- export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, GuidyRoute, GuidyRoutesMessage, StandaloneOAuth2Auth, detectAuthMode };
32
+ export { KivaAclRule, KivaAuthConfig, KivaAuthContextValue, KivaCalendarEventPayload, KivaEmailPayload, KivaNotification, KivaPermission, KivaRole, KivaShareAdaptiveCardPayload, KivaSharePayload, KivaShareTextPayload, KivaUser };
33
+ export type { DocyrusAclRule, DocyrusAuthConfig, DocyrusAuthContextValue, DocyrusCalendarEventPayload, DocyrusEmailPayload, DocyrusNotification, DocyrusPermission, DocyrusRole, DocyrusShareAdaptiveCardPayload, DocyrusSharePayload, DocyrusShareTextPayload, DocyrusUser };
@@ -14,8 +14,9 @@ var DEFAULT_OAUTH_SCOPES = [
14
14
  "DS.Read.All"
15
15
  ];
16
16
  var DEFAULT_CALLBACK_PATH = "/auth/callback";
17
- var DEFAULT_ALLOWED_HOST_PATTERN = /^https:\/\/[^/]+\.docyrus\.app$/;
18
- var REDIRECT_RETURN_KEY = "docyrus_auth_return_url";
17
+ var DEFAULT_ALLOWED_HOST_PATTERN = /^https:\/\/[^/]+\.(?:kiva|docyrus)\.app$/;
18
+ var REDIRECT_RETURN_KEY = "kiva_auth_return_url";
19
+ var LEGACY_REDIRECT_RETURN_KEY = "docyrus_auth_return_url";
19
20
  var TOKEN_EXPIRY_BUFFER_SECONDS = 60;
20
21
  var MIN_TOKEN_REFRESH_INTERVAL_MS = 1e4;
21
22
  var IFRAME_TOKEN_REFRESH_TIMEOUT_MS = 1e4;
@@ -60,7 +61,7 @@ var StandaloneOAuth2Auth = class {
60
61
  const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
61
62
  if (!config.clientId) {
62
63
  throw new Error(
63
- 'DocyrusAuthProvider: "clientId" is required. Set it via the clientId prop or the VITE_DOCYRUS_CLIENT_ID / NEXT_PUBLIC_DOCYRUS_CLIENT_ID environment variable.'
64
+ 'KivaAuthProvider: "clientId" is required. Set it via the clientId prop or the VITE_KIVA_CLIENT_ID / NEXT_PUBLIC_KIVA_CLIENT_ID environment variable.'
64
65
  );
65
66
  }
66
67
  const { clientId } = config;
@@ -69,7 +70,7 @@ var StandaloneOAuth2Auth = class {
69
70
  const redirectUri = config.redirectUri ?? `${window.location.origin}${this.callbackPath}`;
70
71
  this.storage = config.tokenStorage ?? new BrowserOAuth2TokenStorage(
71
72
  window.localStorage,
72
- config.storageKeyPrefix ?? "docyrus_oauth2"
73
+ config.storageKeyPrefix ?? "kiva_oauth2"
73
74
  );
74
75
  this.oauth2Client = new OAuth2Client({
75
76
  baseURL: apiUrl,
@@ -123,8 +124,9 @@ var StandaloneOAuth2Auth = class {
123
124
  * Clears the stored value after retrieval.
124
125
  */
125
126
  getReturnUrl() {
126
- const url = window.localStorage.getItem(REDIRECT_RETURN_KEY);
127
+ const url = window.localStorage.getItem(REDIRECT_RETURN_KEY) ?? window.localStorage.getItem(LEGACY_REDIRECT_RETURN_KEY);
127
128
  window.localStorage.removeItem(REDIRECT_RETURN_KEY);
129
+ window.localStorage.removeItem(LEGACY_REDIRECT_RETURN_KEY);
128
130
  return url;
129
131
  }
130
132
  /** Get currently stored tokens (e.g., on page reload). */
@@ -186,7 +188,7 @@ function getJwtSessionKey(accessToken) {
186
188
  // src/core/iframe-auth.ts
187
189
  function postToHost(data) {
188
190
  const rnwv = window.ReactNativeWebView;
189
- const tap = window.__DOCYRUS_DEVTOOLS_MESSAGE_TAP__;
191
+ const tap = window.__KIVA_DEVTOOLS_MESSAGE_TAP__ ?? window.__DOCYRUS_DEVTOOLS_MESSAGE_TAP__;
190
192
  if (rnwv && typeof rnwv.postMessage === "function") {
191
193
  if (typeof tap === "function") tap("out", data, { transport: "webview" });
192
194
  rnwv.postMessage(JSON.stringify(data));
@@ -592,7 +594,7 @@ var IframeAuth = class {
592
594
  try {
593
595
  handler(message);
594
596
  } catch (err) {
595
- console.warn("[docyrus-signin] guidy command handler threw:", err);
597
+ console.warn("[kiva-signin] guidy command handler threw:", err);
596
598
  }
597
599
  }
598
600
  }
@@ -618,7 +620,7 @@ var IframeAuth = class {
618
620
  try {
619
621
  handler(message);
620
622
  } catch (err) {
621
- console.warn("[docyrus-signin] host navigation handler threw:", err);
623
+ console.warn("[kiva-signin] host navigation handler threw:", err);
622
624
  }
623
625
  }
624
626
  }
@@ -631,7 +633,7 @@ var IframeAuth = class {
631
633
  try {
632
634
  handler(notification);
633
635
  } catch (err) {
634
- console.warn("[docyrus-signin] host notification handler threw:", err);
636
+ console.warn("[kiva-signin] host notification handler threw:", err);
635
637
  }
636
638
  }
637
639
  }
@@ -1010,17 +1012,17 @@ var ReactNativeOAuth2Auth = class {
1010
1012
  const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
1011
1013
  if (!config.clientId) {
1012
1014
  throw new Error(
1013
- 'DocyrusAuthProvider: "clientId" is required for React Native mode.'
1015
+ 'KivaAuthProvider: "clientId" is required for React Native mode.'
1014
1016
  );
1015
1017
  }
1016
1018
  if (!config.nativeRedirectUri) {
1017
1019
  throw new Error(
1018
- `DocyrusAuthProvider: "nativeRedirectUri" is required for React Native mode. Set it to your app's deep link URI (e.g., "myapp://auth/callback").`
1020
+ `KivaAuthProvider: "nativeRedirectUri" is required for React Native mode. Set it to your app's deep link URI (e.g., "myapp://auth/callback").`
1019
1021
  );
1020
1022
  }
1021
1023
  if (!config.openAuthSession) {
1022
1024
  throw new Error(
1023
- 'DocyrusAuthProvider: "openAuthSession" is required for React Native mode. Pass WebBrowser.openAuthSessionAsync from expo-web-browser.'
1025
+ 'KivaAuthProvider: "openAuthSession" is required for React Native mode. Pass WebBrowser.openAuthSessionAsync from expo-web-browser.'
1024
1026
  );
1025
1027
  }
1026
1028
  const scopes = config.scopes ?? DEFAULT_OAUTH_SCOPES;
@@ -1079,7 +1081,12 @@ var ReactNativeOAuth2Auth = class {
1079
1081
  };
1080
1082
 
1081
1083
  // src/core/cookie-sync.ts
1082
- var DEFAULT_SSR_COOKIE_KEY = "docyrus-token";
1084
+ var DEFAULT_SSR_COOKIE_KEY = "kiva-token";
1085
+ var LEGACY_SSR_COOKIE_KEY = "docyrus-token";
1086
+ function removeCookie(key) {
1087
+ const secure = window.location.protocol === "https:" ? ";Secure" : "";
1088
+ document.cookie = `${key}=;path=/;max-age=0;SameSite=Lax${secure}`;
1089
+ }
1083
1090
  function syncTokenToCookie(accessToken, cookieKey, expiresAt) {
1084
1091
  if (typeof document === "undefined") return;
1085
1092
  const key = cookieKey ?? DEFAULT_SSR_COOKIE_KEY;
@@ -1090,12 +1097,13 @@ function syncTokenToCookie(accessToken, cookieKey, expiresAt) {
1090
1097
  if (seconds > 0) maxAge = `;max-age=${seconds}`;
1091
1098
  }
1092
1099
  document.cookie = `${key}=${encodeURIComponent(accessToken)};path=/;SameSite=Lax${secure}${maxAge}`;
1100
+ if (key === DEFAULT_SSR_COOKIE_KEY) removeCookie(LEGACY_SSR_COOKIE_KEY);
1093
1101
  }
1094
1102
  function clearTokenCookie(cookieKey) {
1095
1103
  if (typeof document === "undefined") return;
1096
1104
  const key = cookieKey ?? DEFAULT_SSR_COOKIE_KEY;
1097
- const secure = window.location.protocol === "https:" ? ";Secure" : "";
1098
- document.cookie = `${key}=;path=/;max-age=0;SameSite=Lax${secure}`;
1105
+ removeCookie(key);
1106
+ if (key === DEFAULT_SSR_COOKIE_KEY) removeCookie(LEGACY_SSR_COOKIE_KEY);
1099
1107
  }
1100
1108
 
1101
1109
  // src/core/host-api-url.ts
@@ -1104,7 +1112,11 @@ var LOOPBACK_HOSTS = [
1104
1112
  "127.0.0.1",
1105
1113
  "[::1]"
1106
1114
  ];
1107
- var TRUSTED_DOMAINS = ["docyrus.com", "attornaid.com"];
1115
+ var TRUSTED_DOMAINS = [
1116
+ "kiva.app",
1117
+ "docyrus.com",
1118
+ "attornaid.com"
1119
+ ];
1108
1120
  function readHostApiUrl() {
1109
1121
  if (typeof window === "undefined" || !window.location) return void 0;
1110
1122
  const params = new URLSearchParams(window.location.search);
@@ -1212,7 +1224,7 @@ var AuthManager = class {
1212
1224
  /** Initialize the auth manager. Must be called once on mount. */
1213
1225
  async initialize() {
1214
1226
  if (this.status === "error") {
1215
- console.error("[docyrus-signin]", UNTRUSTED_BACKEND_MESSAGE);
1227
+ console.error("[kiva-signin]", UNTRUSTED_BACKEND_MESSAGE);
1216
1228
  this.notify();
1217
1229
  return;
1218
1230
  }
@@ -1254,7 +1266,7 @@ var AuthManager = class {
1254
1266
  ssoAuth.cleanUrl();
1255
1267
  return;
1256
1268
  } catch (err) {
1257
- console.warn("[docyrus-signin] SSO token exchange failed:", err);
1269
+ console.warn("[kiva-signin] SSO token exchange failed:", err);
1258
1270
  }
1259
1271
  }
1260
1272
  }
@@ -1310,7 +1322,7 @@ var AuthManager = class {
1310
1322
  try {
1311
1323
  handler(message);
1312
1324
  } catch (err) {
1313
- console.warn("[docyrus-signin] host navigation handler threw:", err);
1325
+ console.warn("[kiva-signin] host navigation handler threw:", err);
1314
1326
  }
1315
1327
  }
1316
1328
  });
@@ -1319,7 +1331,7 @@ var AuthManager = class {
1319
1331
  try {
1320
1332
  handler(notification);
1321
1333
  } catch (err) {
1322
- console.warn("[docyrus-signin] host notification handler threw:", err);
1334
+ console.warn("[kiva-signin] host notification handler threw:", err);
1323
1335
  }
1324
1336
  }
1325
1337
  });