@docyrus/signin 0.15.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/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { D as DocyrusAuthContext, a as DocyrusAuthProvider, b as DocyrusAuthProviderProps, u as useDocyrusAuth, c as useDocyrusClient } from './use-docyrus-client-pU5z5ZHe.js';
2
- import { G as GuidyRoute, H as HostNavigationHandler, h as HostNotificationHandler, i as HostNavigationRequestOptions, c as AuthStatus } from './types-DzwC4Dk7.js';
3
- export { A as AclOperation, j as AppNavigationRequestMessage, k as AppRouteChangeMessage, a as AuthMode, d as DocyrusAclRule, D as DocyrusAuthConfig, e as DocyrusAuthContextValue, l as DocyrusNotification, f as DocyrusRole, g as DocyrusUser, m as GuidyCommandHandler, n as GuidyCommandMessage, o as GuidyElement, p as GuidyElementsMessage, q as GuidyPointAckMessage, r as GuidyPointMessage, s as GuidyRoutesMessage, t as GuidyScanMessage, u as HostNavigationMessage, v as HostNotificationMessage, w as HostSignInMessage, P as PermissionConfig, R as RouteChangePayload, T as TokenRefreshRequestMessage } from './types-DzwC4Dk7.js';
1
+ export { D as DocyrusAuthContext, a as DocyrusAuthProvider, b as DocyrusAuthProviderProps, u as useDocyrusAuth, c as useDocyrusClient } from './use-docyrus-client-BfbEowBC.js';
2
+ import { G as GuidyRoute, H as HostNavigationHandler, s as HostNotificationHandler, n as MsGraphClient, t as HostNavigationRequestOptions, g as DocyrusCalendarEventPayload, k as DocyrusSharePayload, h as DocyrusEmailPayload, d as AuthStatus } from './types-C_i-KhUS.js';
3
+ export { A as AclOperation, a as AdaptiveCard, u as AppNavigationRequestMessage, v as AppRouteChangeMessage, b as AuthMode, C as CalendarSendAckMessage, w as CalendarSendMessage, x as ChatSendAckMessage, y as ChatSendMessage, z as DocySendAckMessage, B as DocySendMessage, e as DocyrusAclRule, D as DocyrusAuthConfig, f as DocyrusAuthContextValue, E as DocyrusNotification, i as DocyrusRole, j as DocyrusShareAdaptiveCardPayload, l as DocyrusShareTextPayload, m as DocyrusUser, F as EmailSendAckMessage, I as EmailSendMessage, J as GuidyCommandHandler, K as GuidyCommandMessage, L as GuidyElement, N as GuidyElementsMessage, Q as GuidyPointAckMessage, S as GuidyPointMessage, T as GuidyRoutesMessage, U as GuidyScanMessage, V as HostNavigationMessage, W as HostNotificationMessage, X as HostSignInMessage, Y as IframeAuth, M as MsGraphAccount, o as MsGraphRequest, Z as MsGraphRequestMessage, p as MsGraphRequestOptions, q as MsGraphResponse, _ as MsGraphResponseMessage, r as MsGraphStatus, $ as MsGraphStatusRequestMessage, a0 as MsGraphStatusResponseMessage, P as PermissionConfig, R as RouteChangePayload, a1 as TokenRefreshRequestMessage } from './types-C_i-KhUS.js';
4
4
  import * as react from 'react';
5
5
  import { CSSProperties, ReactNode } from 'react';
6
- export { A as AuthManager, D as DEFAULT_API_URL, c as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, d as DEFAULT_SSR_COOKIE_KEY, g as getAllRoles, h as hasPermission, b as hasRole } from './constants-BoAqIz2O.js';
7
- export { GuidyBridge, IframeAuth, StandaloneOAuth2Auth, detectAuthMode } from './core-index.js';
6
+ export { A as AuthManager, D as DEFAULT_API_URL, c as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, d as DEFAULT_SSR_COOKIE_KEY, g as getAllRoles, h as hasPermission, b as hasRole } from './constants-BhPyFHNf.js';
7
+ export { GuidyBridge, StandaloneOAuth2Auth, detectAuthMode } from './core-index.js';
8
8
  import '@docyrus/api-client';
9
9
 
10
10
  /**
@@ -38,6 +38,41 @@ declare function useDocyrusRequestHostNavigation(): (url: string, options?: Host
38
38
  * `enableGuidyBridge` on the provider; no-op in non-iframe modes.
39
39
  */
40
40
  declare function useDocyrusGuidyRoutes(routes: GuidyRoute[]): void;
41
+ /**
42
+ * Get a stable function that hands a payload to the host AI assistant (Docy)
43
+ * from within an embedded iframe/WebView. Resolves when the host acknowledges
44
+ * delivery; rejects on host error or timeout (and immediately outside iframe
45
+ * mode). Use for "Send to Docy" buttons/menu items.
46
+ */
47
+ declare function useDocyrusSendToDocy(): (payload: DocyrusSharePayload) => Promise<void>;
48
+ /**
49
+ * Get a stable function that hands a payload to the host team-chat app from
50
+ * within an embedded iframe/WebView. Resolves when the host acknowledges
51
+ * delivery; rejects on host error or timeout (and immediately outside iframe
52
+ * mode). Use for "Send to Chat" buttons/menu items.
53
+ */
54
+ declare function useDocyrusSendToChat(): (payload: DocyrusSharePayload) => Promise<void>;
55
+ /**
56
+ * Get a stable function that hands a draft email (to/subject/body/cc) to the
57
+ * host from within an embedded iframe/WebView. Resolves when the host
58
+ * acknowledges; rejects on host error or timeout (and immediately outside
59
+ * iframe mode). Use for "Send to Email" buttons/menu items.
60
+ */
61
+ declare function useDocyrusSendToEmail(): (payload: DocyrusEmailPayload) => Promise<void>;
62
+ /**
63
+ * Get a stable function that hands a calendar event (subject/description/
64
+ * participants/start/end) to the host from within an embedded iframe/WebView.
65
+ * Resolves when the host acknowledges; rejects on host error or timeout (and
66
+ * immediately outside iframe mode). Use for "Send to Calendar" buttons/menu
67
+ * items.
68
+ */
69
+ declare function useDocyrusSendToCalendar(): (payload: DocyrusCalendarEventPayload) => Promise<void>;
70
+ /**
71
+ * Get the client for the host's Microsoft Graph (MSAL) session. Check
72
+ * `isSignedIn()` and make host-proxied Graph requests. Returns `null` outside
73
+ * iframe/WebView mode.
74
+ */
75
+ declare function useDocyrusMsGraph(): MsGraphClient | null;
41
76
 
42
77
  interface SignInButtonProps {
43
78
  /** Custom label. Defaults to "Sign in with Docyrus" */
@@ -87,4 +122,4 @@ declare function clearTokenCookie(cookieKey?: string): void;
87
122
  */
88
123
  declare function getTokenFromCookie(cookieKey?: string): string | null;
89
124
 
90
- export { AuthStatus, GuidyRoute, HostNavigationHandler, HostNavigationRequestOptions, HostNotificationHandler, SignInButton, type SignInButtonProps, clearTokenCookie, getTokenFromCookie, syncTokenToCookie, useDocyrusGuidyRoutes, useDocyrusHostNavigation, useDocyrusHostNotification, useDocyrusHostRouteSync, useDocyrusRequestHostNavigation };
125
+ export { AuthStatus, DocyrusCalendarEventPayload, DocyrusEmailPayload, DocyrusSharePayload, GuidyRoute, HostNavigationHandler, HostNavigationRequestOptions, HostNotificationHandler, MsGraphClient, SignInButton, type SignInButtonProps, clearTokenCookie, getTokenFromCookie, syncTokenToCookie, useDocyrusGuidyRoutes, useDocyrusHostNavigation, useDocyrusHostNotification, useDocyrusHostRouteSync, useDocyrusMsGraph, useDocyrusRequestHostNavigation, useDocyrusSendToCalendar, useDocyrusSendToChat, useDocyrusSendToDocy, useDocyrusSendToEmail };
package/dist/index.js CHANGED
@@ -18,6 +18,8 @@ var DEFAULT_ALLOWED_HOST_PATTERN = /^https:\/\/[^/]+\.docyrus\.app$/;
18
18
  var REDIRECT_RETURN_KEY = "docyrus_auth_return_url";
19
19
  var TOKEN_EXPIRY_BUFFER_SECONDS = 60;
20
20
  var IFRAME_TOKEN_REFRESH_TIMEOUT_MS = 1e4;
21
+ var HOST_ACTION_TIMEOUT_MS = 15e3;
22
+ var MSGRAPH_REQUEST_TIMEOUT_MS = 3e4;
21
23
  var DEFAULT_SSR_COOKIE_KEY = "docyrus-token";
22
24
  var SSO_TOKEN_PARAM = "sso_token";
23
25
 
@@ -192,6 +194,13 @@ var IframeAuth = class {
192
194
  stopped = false;
193
195
  refreshPromise = null;
194
196
  messageHandler = null;
197
+ /**
198
+ * In-flight app→host requests awaiting a correlated host reply, keyed by
199
+ * requestId. Powers Send to Docy / Send to Chat / the MS Graph bridge.
200
+ */
201
+ pendingRequests = /* @__PURE__ */ new Map();
202
+ /** Fallback monotonic counter for request ids when crypto.randomUUID is absent. */
203
+ requestCounter = 0;
195
204
  constructor(allowedOrigins, allowedPattern) {
196
205
  this.allowedOrigins = allowedOrigins ?? [];
197
206
  this.allowedPattern = allowedPattern ?? DEFAULT_ALLOWED_HOST_PATTERN;
@@ -215,6 +224,7 @@ var IframeAuth = class {
215
224
  this.messageHandler = null;
216
225
  }
217
226
  this.rejectPendingRefresh("IframeAuth stopped");
227
+ this.rejectAllPendingRequests("IframeAuth stopped");
218
228
  this.navigationHandlers.clear();
219
229
  this.notificationHandlers.clear();
220
230
  this.guidyHandlers.clear();
@@ -341,6 +351,119 @@ var IframeAuth = class {
341
351
  if (this.stopped) return;
342
352
  postToHost(message);
343
353
  }
354
+ /**
355
+ * Hand a payload to the host AI assistant (Docy). Resolves when the host
356
+ * acknowledges delivery, rejects on host error or timeout.
357
+ */
358
+ sendToDocy(payload) {
359
+ const requestId = this.nextRequestId();
360
+ return this.request(
361
+ { type: "docy:send", requestId, payload },
362
+ HOST_ACTION_TIMEOUT_MS
363
+ );
364
+ }
365
+ /**
366
+ * Hand a payload to the host team-chat app. Resolves when the host
367
+ * acknowledges delivery, rejects on host error or timeout.
368
+ */
369
+ sendToChat(payload) {
370
+ const requestId = this.nextRequestId();
371
+ return this.request(
372
+ { type: "chat:send", requestId, payload },
373
+ HOST_ACTION_TIMEOUT_MS
374
+ );
375
+ }
376
+ /**
377
+ * Hand a draft email to the host. Resolves when the host acknowledges,
378
+ * rejects on host error or timeout.
379
+ */
380
+ sendToEmail(payload) {
381
+ const requestId = this.nextRequestId();
382
+ return this.request(
383
+ { type: "email:send", requestId, payload },
384
+ HOST_ACTION_TIMEOUT_MS
385
+ );
386
+ }
387
+ /**
388
+ * Hand a calendar event to the host. Resolves when the host acknowledges,
389
+ * rejects on host error or timeout.
390
+ */
391
+ sendToCalendar(payload) {
392
+ const requestId = this.nextRequestId();
393
+ return this.request(
394
+ { type: "calendar:send", requestId, payload },
395
+ HOST_ACTION_TIMEOUT_MS
396
+ );
397
+ }
398
+ /** Ask the host whether its MSAL session is signed in. */
399
+ requestMsGraphStatus() {
400
+ const requestId = this.nextRequestId();
401
+ return this.request(
402
+ { type: "msgraph:status-request", requestId },
403
+ HOST_ACTION_TIMEOUT_MS
404
+ );
405
+ }
406
+ /** Perform a Microsoft Graph request through the host's MSAL session. */
407
+ requestMsGraph(request) {
408
+ const requestId = this.nextRequestId();
409
+ return this.request(
410
+ { type: "msgraph:request", requestId, request },
411
+ MSGRAPH_REQUEST_TIMEOUT_MS
412
+ );
413
+ }
414
+ /**
415
+ * Post a correlated app→host request and await the matching host reply.
416
+ * The reply is matched by `requestId` in `handleMessage`. Rejects on timeout
417
+ * or when the bridge is stopped.
418
+ */
419
+ request(message, timeoutMs) {
420
+ if (this.stopped) {
421
+ return Promise.reject(new Error("Cannot send host request: iframe bridge stopped"));
422
+ }
423
+ const { requestId } = message;
424
+ return new Promise((resolve, reject) => {
425
+ const timeoutId = setTimeout(() => {
426
+ this.pendingRequests.delete(requestId);
427
+ reject(new Error(`Host request "${message.type}" timed out`));
428
+ }, timeoutMs);
429
+ this.pendingRequests.set(requestId, {
430
+ resolve,
431
+ reject,
432
+ timeoutId
433
+ });
434
+ this.sendToHost(message);
435
+ });
436
+ }
437
+ /** Generate a correlation id, preferring crypto.randomUUID when available. */
438
+ nextRequestId() {
439
+ const cryptoObj = typeof crypto !== "undefined" ? crypto : void 0;
440
+ if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
441
+ return cryptoObj.randomUUID();
442
+ }
443
+ this.requestCounter += 1;
444
+ return `req-${Date.now().toString(36)}-${this.requestCounter}-${Math.random().toString(36).slice(2, 10)}`;
445
+ }
446
+ resolvePendingRequest(requestId, value) {
447
+ const pending = this.pendingRequests.get(requestId);
448
+ if (!pending) return;
449
+ clearTimeout(pending.timeoutId);
450
+ this.pendingRequests.delete(requestId);
451
+ pending.resolve(value);
452
+ }
453
+ rejectPendingRequest(requestId, error) {
454
+ const pending = this.pendingRequests.get(requestId);
455
+ if (!pending) return;
456
+ clearTimeout(pending.timeoutId);
457
+ this.pendingRequests.delete(requestId);
458
+ pending.reject(error);
459
+ }
460
+ rejectAllPendingRequests(reason) {
461
+ for (const pending of this.pendingRequests.values()) {
462
+ clearTimeout(pending.timeoutId);
463
+ pending.reject(new Error(reason));
464
+ }
465
+ this.pendingRequests.clear();
466
+ }
344
467
  /**
345
468
  * Request fresh tokens from the host.
346
469
  * Posts a "token-refresh-request" to the host, then waits for
@@ -397,8 +520,57 @@ var IframeAuth = class {
397
520
  }
398
521
  if (data.type === "guidy:point" || data.type === "guidy:scan") {
399
522
  this.handleGuidyCommand(data);
523
+ return;
524
+ }
525
+ if (data.type === "docy:send-ack" || data.type === "chat:send-ack" || data.type === "email:send-ack" || data.type === "calendar:send-ack") {
526
+ this.handleActionAck(data);
527
+ return;
528
+ }
529
+ if (data.type === "msgraph:status-response") {
530
+ this.handleMsGraphStatusResponse(data);
531
+ return;
532
+ }
533
+ if (data.type === "msgraph:response") {
534
+ this.handleMsGraphResponse(data);
400
535
  }
401
536
  }
537
+ handleActionAck(message) {
538
+ if (typeof message.requestId !== "string") return;
539
+ if (message.ok) {
540
+ this.resolvePendingRequest(message.requestId, void 0);
541
+ } else {
542
+ this.rejectPendingRequest(
543
+ message.requestId,
544
+ new Error(message.error || `Host rejected ${message.type}`)
545
+ );
546
+ }
547
+ }
548
+ handleMsGraphStatusResponse(message) {
549
+ if (typeof message.requestId !== "string") return;
550
+ if (message.error) {
551
+ this.rejectPendingRequest(message.requestId, new Error(message.error));
552
+ return;
553
+ }
554
+ const status = {
555
+ signedIn: !!message.signedIn,
556
+ account: message.account ?? null
557
+ };
558
+ this.resolvePendingRequest(message.requestId, status);
559
+ }
560
+ handleMsGraphResponse(message) {
561
+ if (typeof message.requestId !== "string") return;
562
+ if (message.error && typeof message.status !== "number") {
563
+ this.rejectPendingRequest(message.requestId, new Error(message.error));
564
+ return;
565
+ }
566
+ const response = {
567
+ ok: !!message.ok,
568
+ status: typeof message.status === "number" ? message.status : 0,
569
+ data: message.data,
570
+ error: message.error
571
+ };
572
+ this.resolvePendingRequest(message.requestId, response);
573
+ }
402
574
  handleGuidyCommand(message) {
403
575
  for (const handler of this.guidyHandlers) {
404
576
  try {
@@ -700,6 +872,66 @@ var GuidyBridge = class {
700
872
  }
701
873
  };
702
874
 
875
+ // src/core/ms-graph-client.ts
876
+ var MsGraphClient = class {
877
+ iframeAuth;
878
+ constructor(iframeAuth) {
879
+ this.iframeAuth = iframeAuth;
880
+ }
881
+ /** Whether the host's MSAL session is signed in, plus optional account info. */
882
+ status() {
883
+ return this.iframeAuth.requestMsGraphStatus();
884
+ }
885
+ /** Convenience: resolves to whether the host's MSAL session is signed in. */
886
+ async isSignedIn() {
887
+ const status = await this.iframeAuth.requestMsGraphStatus();
888
+ return status.signedIn;
889
+ }
890
+ /** Perform an arbitrary Microsoft Graph request via the host's MSAL session. */
891
+ request(request) {
892
+ return this.iframeAuth.requestMsGraph(request);
893
+ }
894
+ /** GET a Graph resource, e.g. `get('/me/messages?$top=5')`. */
895
+ get(path, options) {
896
+ return this.iframeAuth.requestMsGraph({ method: "GET", path, ...options });
897
+ }
898
+ /** POST a JSON body to a Graph resource. */
899
+ post(path, body, options) {
900
+ return this.iframeAuth.requestMsGraph({
901
+ method: "POST",
902
+ path,
903
+ body,
904
+ ...options
905
+ });
906
+ }
907
+ /** PATCH a JSON body to a Graph resource. */
908
+ patch(path, body, options) {
909
+ return this.iframeAuth.requestMsGraph({
910
+ method: "PATCH",
911
+ path,
912
+ body,
913
+ ...options
914
+ });
915
+ }
916
+ /** PUT a JSON body to a Graph resource. */
917
+ put(path, body, options) {
918
+ return this.iframeAuth.requestMsGraph({
919
+ method: "PUT",
920
+ path,
921
+ body,
922
+ ...options
923
+ });
924
+ }
925
+ /** DELETE a Graph resource. */
926
+ delete(path, options) {
927
+ return this.iframeAuth.requestMsGraph({ method: "DELETE", path, ...options });
928
+ }
929
+ /** Convenience: GET `/me` — the signed-in user's profile. */
930
+ getMe() {
931
+ return this.iframeAuth.requestMsGraph({ method: "GET", path: "/me" });
932
+ }
933
+ };
934
+
703
935
  // src/core/sso-auth.ts
704
936
  var SsoAuth = class {
705
937
  config;
@@ -867,6 +1099,7 @@ var AuthManager = class {
867
1099
  standaloneAuth = null;
868
1100
  iframeAuth = null;
869
1101
  guidyBridge = null;
1102
+ msGraphClient = null;
870
1103
  reactNativeAuth = null;
871
1104
  tokenRefreshTimer = null;
872
1105
  /** Shared in-flight refresh, so concurrent requests don't trigger parallel refreshes. */
@@ -1009,6 +1242,7 @@ var AuthManager = class {
1009
1242
  */
1010
1243
  initializeIframeMode() {
1011
1244
  this.iframeAuth = new IframeAuth(this.config.allowedHostOrigins);
1245
+ this.msGraphClient = new MsGraphClient(this.iframeAuth);
1012
1246
  this.iframeAuth.start((tokens) => {
1013
1247
  this.setAuthenticated(tokens);
1014
1248
  });
@@ -1084,6 +1318,53 @@ var AuthManager = class {
1084
1318
  requestHostNavigation(url, options) {
1085
1319
  this.iframeAuth?.requestHostNavigation(url, options);
1086
1320
  }
1321
+ /**
1322
+ * Iframe/WebView mode: hand a payload to the host AI assistant (Docy).
1323
+ * Resolves when the host acknowledges delivery. Rejects outside iframe mode.
1324
+ */
1325
+ sendToDocy(payload) {
1326
+ if (!this.iframeAuth) {
1327
+ return Promise.reject(new Error("sendToDocy() is only available in iframe/WebView mode"));
1328
+ }
1329
+ return this.iframeAuth.sendToDocy(payload);
1330
+ }
1331
+ /**
1332
+ * Iframe/WebView mode: hand a payload to the host team-chat app.
1333
+ * Resolves when the host acknowledges delivery. Rejects outside iframe mode.
1334
+ */
1335
+ sendToChat(payload) {
1336
+ if (!this.iframeAuth) {
1337
+ return Promise.reject(new Error("sendToChat() is only available in iframe/WebView mode"));
1338
+ }
1339
+ return this.iframeAuth.sendToChat(payload);
1340
+ }
1341
+ /**
1342
+ * Iframe/WebView mode: hand a draft email to the host. Resolves when the
1343
+ * host acknowledges. Rejects outside iframe mode.
1344
+ */
1345
+ sendToEmail(payload) {
1346
+ if (!this.iframeAuth) {
1347
+ return Promise.reject(new Error("sendToEmail() is only available in iframe/WebView mode"));
1348
+ }
1349
+ return this.iframeAuth.sendToEmail(payload);
1350
+ }
1351
+ /**
1352
+ * Iframe/WebView mode: hand a calendar event to the host. Resolves when the
1353
+ * host acknowledges. Rejects outside iframe mode.
1354
+ */
1355
+ sendToCalendar(payload) {
1356
+ if (!this.iframeAuth) {
1357
+ return Promise.reject(new Error("sendToCalendar() is only available in iframe/WebView mode"));
1358
+ }
1359
+ return this.iframeAuth.sendToCalendar(payload);
1360
+ }
1361
+ /**
1362
+ * Iframe/WebView mode: get the client for the host's Microsoft Graph (MSAL)
1363
+ * session. Returns `null` outside iframe mode.
1364
+ */
1365
+ getMsGraphClient() {
1366
+ return this.msGraphClient;
1367
+ }
1087
1368
  /**
1088
1369
  * Subscribe to host `navigation` messages. Returns an unsubscribe function.
1089
1370
  * Handlers registered before iframe mode is initialized are retained and
@@ -1205,6 +1486,7 @@ var AuthManager = class {
1205
1486
  this.guidyBridge = null;
1206
1487
  }
1207
1488
  this.iframeAuth.stop();
1489
+ this.msGraphClient = null;
1208
1490
  }
1209
1491
  if (this.config.ssr) {
1210
1492
  clearTokenCookie(this.config.ssrCookieKey);
@@ -1384,6 +1666,7 @@ var AuthManager = class {
1384
1666
  this.guidyBridge = null;
1385
1667
  }
1386
1668
  if (this.iframeAuth) this.iframeAuth.stop();
1669
+ this.msGraphClient = null;
1387
1670
  this.listeners.clear();
1388
1671
  this.navigationHandlers.clear();
1389
1672
  this.notificationHandlers.clear();
@@ -1584,6 +1867,29 @@ function DocyrusAuthProvider({
1584
1867
  managerRef.current?.setGuidyRoutes(routes);
1585
1868
  };
1586
1869
  }, []);
1870
+ const sendToDocy = useMemo(() => {
1871
+ return (payload) => {
1872
+ return managerRef.current?.sendToDocy(payload) ?? Promise.reject(new Error("Auth manager not initialized"));
1873
+ };
1874
+ }, []);
1875
+ const sendToChat = useMemo(() => {
1876
+ return (payload) => {
1877
+ return managerRef.current?.sendToChat(payload) ?? Promise.reject(new Error("Auth manager not initialized"));
1878
+ };
1879
+ }, []);
1880
+ const sendToEmail = useMemo(() => {
1881
+ return (payload) => {
1882
+ return managerRef.current?.sendToEmail(payload) ?? Promise.reject(new Error("Auth manager not initialized"));
1883
+ };
1884
+ }, []);
1885
+ const sendToCalendar = useMemo(() => {
1886
+ return (payload) => {
1887
+ return managerRef.current?.sendToCalendar(payload) ?? Promise.reject(new Error("Auth manager not initialized"));
1888
+ };
1889
+ }, []);
1890
+ const msGraph = useMemo(() => {
1891
+ return managerRef.current?.getMsGraphClient() ?? null;
1892
+ }, []);
1587
1893
  const value = useMemo(() => ({
1588
1894
  status,
1589
1895
  mode,
@@ -1603,6 +1909,11 @@ function DocyrusAuthProvider({
1603
1909
  notifyRouteChange,
1604
1910
  requestHostNavigation,
1605
1911
  setGuidyRoutes,
1912
+ sendToDocy,
1913
+ sendToChat,
1914
+ sendToEmail,
1915
+ sendToCalendar,
1916
+ msGraph,
1606
1917
  error
1607
1918
  }), [
1608
1919
  status,
@@ -1623,6 +1934,11 @@ function DocyrusAuthProvider({
1623
1934
  notifyRouteChange,
1624
1935
  requestHostNavigation,
1625
1936
  setGuidyRoutes,
1937
+ sendToDocy,
1938
+ sendToChat,
1939
+ sendToEmail,
1940
+ sendToCalendar,
1941
+ msGraph,
1626
1942
  error
1627
1943
  ]);
1628
1944
  return /* @__PURE__ */ jsx(DocyrusAuthContext, { value, children });
@@ -1678,6 +1994,26 @@ function useDocyrusGuidyRoutes(routes) {
1678
1994
  setGuidyRoutes(routes);
1679
1995
  }, [setGuidyRoutes, routes]);
1680
1996
  }
1997
+ function useDocyrusSendToDocy() {
1998
+ const { sendToDocy } = useDocyrusAuth();
1999
+ return sendToDocy;
2000
+ }
2001
+ function useDocyrusSendToChat() {
2002
+ const { sendToChat } = useDocyrusAuth();
2003
+ return sendToChat;
2004
+ }
2005
+ function useDocyrusSendToEmail() {
2006
+ const { sendToEmail } = useDocyrusAuth();
2007
+ return sendToEmail;
2008
+ }
2009
+ function useDocyrusSendToCalendar() {
2010
+ const { sendToCalendar } = useDocyrusAuth();
2011
+ return sendToCalendar;
2012
+ }
2013
+ function useDocyrusMsGraph() {
2014
+ const { msGraph } = useDocyrusAuth();
2015
+ return msGraph;
2016
+ }
1681
2017
  var ICON_SIZE = 20;
1682
2018
  function DocyrusLogo({ size = ICON_SIZE }) {
1683
2019
  return /* @__PURE__ */ jsx(
@@ -1762,6 +2098,6 @@ function SignInButton({
1762
2098
  );
1763
2099
  }
1764
2100
 
1765
- export { AuthManager, DEFAULT_API_URL, DEFAULT_CALLBACK_PATH, DEFAULT_OAUTH_SCOPES, DEFAULT_SSR_COOKIE_KEY, DocyrusAuthContext, DocyrusAuthProvider, GuidyBridge, IframeAuth, SignInButton, StandaloneOAuth2Auth, clearTokenCookie, detectAuthMode, getAllRoles, getTokenFromCookie, hasPermission, hasRole, syncTokenToCookie, useDocyrusAuth, useDocyrusClient, useDocyrusGuidyRoutes, useDocyrusHostNavigation, useDocyrusHostNotification, useDocyrusHostRouteSync, useDocyrusRequestHostNavigation };
2101
+ export { AuthManager, DEFAULT_API_URL, DEFAULT_CALLBACK_PATH, DEFAULT_OAUTH_SCOPES, DEFAULT_SSR_COOKIE_KEY, DocyrusAuthContext, DocyrusAuthProvider, GuidyBridge, IframeAuth, MsGraphClient, SignInButton, StandaloneOAuth2Auth, clearTokenCookie, detectAuthMode, getAllRoles, getTokenFromCookie, hasPermission, hasRole, syncTokenToCookie, useDocyrusAuth, useDocyrusClient, useDocyrusGuidyRoutes, useDocyrusHostNavigation, useDocyrusHostNotification, useDocyrusHostRouteSync, useDocyrusMsGraph, useDocyrusRequestHostNavigation, useDocyrusSendToCalendar, useDocyrusSendToChat, useDocyrusSendToDocy, useDocyrusSendToEmail };
1766
2102
  //# sourceMappingURL=index.js.map
1767
2103
  //# sourceMappingURL=index.js.map