@docyrus/signin 0.14.1 → 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/README.md +250 -0
- package/dist/{constants-DDOgvbL5.d.ts → constants-BhPyFHNf.d.ts} +33 -1
- package/dist/core-index.d.ts +4 -95
- package/dist/core-index.js +305 -1
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +47 -6
- package/dist/index.js +369 -1
- package/dist/index.js.map +1 -1
- package/dist/nextjs/index.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -4
- package/dist/react-native/index.js +344 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/types-C_i-KhUS.d.ts +773 -0
- package/dist/{use-docyrus-client-o9nPwayd.d.ts → use-docyrus-client-BfbEowBC.d.ts} +1 -1
- package/dist/vue/index.d.ts +9 -3
- package/dist/vue/index.js +328 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/types-D4ZAVj-B.d.ts +0 -337
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-
|
|
2
|
-
import { G as GuidyRoute, H as HostNavigationHandler,
|
|
3
|
-
export { A as AclOperation,
|
|
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-
|
|
7
|
-
export { GuidyBridge,
|
|
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
|
/**
|
|
@@ -26,12 +26,53 @@ declare function useDocyrusHostNavigation(handler: HostNavigationHandler): void;
|
|
|
26
26
|
* No-op in non-iframe modes.
|
|
27
27
|
*/
|
|
28
28
|
declare function useDocyrusHostNotification(handler: HostNotificationHandler): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get a stable function that asks the host shell to navigate to a path/URL
|
|
31
|
+
* from within an embedded iframe/WebView. The reverse of
|
|
32
|
+
* `useDocyrusHostNavigation`. No-op in non-iframe modes.
|
|
33
|
+
*/
|
|
34
|
+
declare function useDocyrusRequestHostNavigation(): (url: string, options?: HostNavigationRequestOptions) => void;
|
|
29
35
|
/**
|
|
30
36
|
* Declare the routes the host assistant (Guidy) may navigate the user to
|
|
31
37
|
* inside this embedded app. Re-syncs whenever `routes` changes. Requires
|
|
32
38
|
* `enableGuidyBridge` on the provider; no-op in non-iframe modes.
|
|
33
39
|
*/
|
|
34
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;
|
|
35
76
|
|
|
36
77
|
interface SignInButtonProps {
|
|
37
78
|
/** Custom label. Defaults to "Sign in with Docyrus" */
|
|
@@ -81,4 +122,4 @@ declare function clearTokenCookie(cookieKey?: string): void;
|
|
|
81
122
|
*/
|
|
82
123
|
declare function getTokenFromCookie(cookieKey?: string): string | null;
|
|
83
124
|
|
|
84
|
-
export { AuthStatus, GuidyRoute, HostNavigationHandler, HostNotificationHandler, SignInButton, type SignInButtonProps, clearTokenCookie, getTokenFromCookie, syncTokenToCookie, useDocyrusGuidyRoutes, useDocyrusHostNavigation, useDocyrusHostNotification, useDocyrusHostRouteSync };
|
|
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();
|
|
@@ -273,6 +283,19 @@ var IframeAuth = class {
|
|
|
273
283
|
url: `${path}${search}${hash}`
|
|
274
284
|
});
|
|
275
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Ask the host shell to navigate to a path/URL. The reverse of the
|
|
288
|
+
* host → app `navigation` message: posts a `navigation-request` over the
|
|
289
|
+
* same validated channel. The host decides how to honour it.
|
|
290
|
+
*/
|
|
291
|
+
requestHostNavigation(url, options) {
|
|
292
|
+
if (this.stopped) return;
|
|
293
|
+
if (typeof url !== "string" || url.length === 0) return;
|
|
294
|
+
const message = { type: "navigation-request", url };
|
|
295
|
+
if (options?.replace) message.replace = true;
|
|
296
|
+
if (options?.newTab) message.newTab = true;
|
|
297
|
+
this.sendToHost(message);
|
|
298
|
+
}
|
|
276
299
|
teardownRouteSync() {
|
|
277
300
|
if (!this.routeSyncEnabled) return;
|
|
278
301
|
if (typeof window !== "undefined") {
|
|
@@ -328,6 +351,119 @@ var IframeAuth = class {
|
|
|
328
351
|
if (this.stopped) return;
|
|
329
352
|
postToHost(message);
|
|
330
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
|
+
}
|
|
331
467
|
/**
|
|
332
468
|
* Request fresh tokens from the host.
|
|
333
469
|
* Posts a "token-refresh-request" to the host, then waits for
|
|
@@ -384,7 +520,56 @@ var IframeAuth = class {
|
|
|
384
520
|
}
|
|
385
521
|
if (data.type === "guidy:point" || data.type === "guidy:scan") {
|
|
386
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;
|
|
387
532
|
}
|
|
533
|
+
if (data.type === "msgraph:response") {
|
|
534
|
+
this.handleMsGraphResponse(data);
|
|
535
|
+
}
|
|
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);
|
|
388
573
|
}
|
|
389
574
|
handleGuidyCommand(message) {
|
|
390
575
|
for (const handler of this.guidyHandlers) {
|
|
@@ -687,6 +872,66 @@ var GuidyBridge = class {
|
|
|
687
872
|
}
|
|
688
873
|
};
|
|
689
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
|
+
|
|
690
935
|
// src/core/sso-auth.ts
|
|
691
936
|
var SsoAuth = class {
|
|
692
937
|
config;
|
|
@@ -854,6 +1099,7 @@ var AuthManager = class {
|
|
|
854
1099
|
standaloneAuth = null;
|
|
855
1100
|
iframeAuth = null;
|
|
856
1101
|
guidyBridge = null;
|
|
1102
|
+
msGraphClient = null;
|
|
857
1103
|
reactNativeAuth = null;
|
|
858
1104
|
tokenRefreshTimer = null;
|
|
859
1105
|
/** Shared in-flight refresh, so concurrent requests don't trigger parallel refreshes. */
|
|
@@ -996,6 +1242,7 @@ var AuthManager = class {
|
|
|
996
1242
|
*/
|
|
997
1243
|
initializeIframeMode() {
|
|
998
1244
|
this.iframeAuth = new IframeAuth(this.config.allowedHostOrigins);
|
|
1245
|
+
this.msGraphClient = new MsGraphClient(this.iframeAuth);
|
|
999
1246
|
this.iframeAuth.start((tokens) => {
|
|
1000
1247
|
this.setAuthenticated(tokens);
|
|
1001
1248
|
});
|
|
@@ -1063,6 +1310,61 @@ var AuthManager = class {
|
|
|
1063
1310
|
notifyHostRouteChange(payload) {
|
|
1064
1311
|
this.iframeAuth?.notifyRouteChange(payload);
|
|
1065
1312
|
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Iframe/WebView mode: ask the host shell to navigate to a path/URL.
|
|
1315
|
+
* Posts a `navigation-request` message; the host decides how to honour it.
|
|
1316
|
+
* No-op outside iframe mode.
|
|
1317
|
+
*/
|
|
1318
|
+
requestHostNavigation(url, options) {
|
|
1319
|
+
this.iframeAuth?.requestHostNavigation(url, options);
|
|
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
|
+
}
|
|
1066
1368
|
/**
|
|
1067
1369
|
* Subscribe to host `navigation` messages. Returns an unsubscribe function.
|
|
1068
1370
|
* Handlers registered before iframe mode is initialized are retained and
|
|
@@ -1184,6 +1486,7 @@ var AuthManager = class {
|
|
|
1184
1486
|
this.guidyBridge = null;
|
|
1185
1487
|
}
|
|
1186
1488
|
this.iframeAuth.stop();
|
|
1489
|
+
this.msGraphClient = null;
|
|
1187
1490
|
}
|
|
1188
1491
|
if (this.config.ssr) {
|
|
1189
1492
|
clearTokenCookie(this.config.ssrCookieKey);
|
|
@@ -1363,6 +1666,7 @@ var AuthManager = class {
|
|
|
1363
1666
|
this.guidyBridge = null;
|
|
1364
1667
|
}
|
|
1365
1668
|
if (this.iframeAuth) this.iframeAuth.stop();
|
|
1669
|
+
this.msGraphClient = null;
|
|
1366
1670
|
this.listeners.clear();
|
|
1367
1671
|
this.navigationHandlers.clear();
|
|
1368
1672
|
this.notificationHandlers.clear();
|
|
@@ -1553,11 +1857,39 @@ function DocyrusAuthProvider({
|
|
|
1553
1857
|
managerRef.current?.notifyHostRouteChange(payload);
|
|
1554
1858
|
};
|
|
1555
1859
|
}, []);
|
|
1860
|
+
const requestHostNavigation = useMemo(() => {
|
|
1861
|
+
return (url, options) => {
|
|
1862
|
+
managerRef.current?.requestHostNavigation(url, options);
|
|
1863
|
+
};
|
|
1864
|
+
}, []);
|
|
1556
1865
|
const setGuidyRoutes = useMemo(() => {
|
|
1557
1866
|
return (routes) => {
|
|
1558
1867
|
managerRef.current?.setGuidyRoutes(routes);
|
|
1559
1868
|
};
|
|
1560
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
|
+
}, []);
|
|
1561
1893
|
const value = useMemo(() => ({
|
|
1562
1894
|
status,
|
|
1563
1895
|
mode,
|
|
@@ -1575,7 +1907,13 @@ function DocyrusAuthProvider({
|
|
|
1575
1907
|
onHostNotification,
|
|
1576
1908
|
enableHostRouteSync,
|
|
1577
1909
|
notifyRouteChange,
|
|
1910
|
+
requestHostNavigation,
|
|
1578
1911
|
setGuidyRoutes,
|
|
1912
|
+
sendToDocy,
|
|
1913
|
+
sendToChat,
|
|
1914
|
+
sendToEmail,
|
|
1915
|
+
sendToCalendar,
|
|
1916
|
+
msGraph,
|
|
1579
1917
|
error
|
|
1580
1918
|
}), [
|
|
1581
1919
|
status,
|
|
@@ -1594,7 +1932,13 @@ function DocyrusAuthProvider({
|
|
|
1594
1932
|
onHostNotification,
|
|
1595
1933
|
enableHostRouteSync,
|
|
1596
1934
|
notifyRouteChange,
|
|
1935
|
+
requestHostNavigation,
|
|
1597
1936
|
setGuidyRoutes,
|
|
1937
|
+
sendToDocy,
|
|
1938
|
+
sendToChat,
|
|
1939
|
+
sendToEmail,
|
|
1940
|
+
sendToCalendar,
|
|
1941
|
+
msGraph,
|
|
1598
1942
|
error
|
|
1599
1943
|
]);
|
|
1600
1944
|
return /* @__PURE__ */ jsx(DocyrusAuthContext, { value, children });
|
|
@@ -1640,12 +1984,36 @@ function useDocyrusHostNotification(handler) {
|
|
|
1640
1984
|
});
|
|
1641
1985
|
}, [onHostNotification]);
|
|
1642
1986
|
}
|
|
1987
|
+
function useDocyrusRequestHostNavigation() {
|
|
1988
|
+
const { requestHostNavigation } = useDocyrusAuth();
|
|
1989
|
+
return requestHostNavigation;
|
|
1990
|
+
}
|
|
1643
1991
|
function useDocyrusGuidyRoutes(routes) {
|
|
1644
1992
|
const { setGuidyRoutes } = useDocyrusAuth();
|
|
1645
1993
|
useEffect(() => {
|
|
1646
1994
|
setGuidyRoutes(routes);
|
|
1647
1995
|
}, [setGuidyRoutes, routes]);
|
|
1648
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
|
+
}
|
|
1649
2017
|
var ICON_SIZE = 20;
|
|
1650
2018
|
function DocyrusLogo({ size = ICON_SIZE }) {
|
|
1651
2019
|
return /* @__PURE__ */ jsx(
|
|
@@ -1730,6 +2098,6 @@ function SignInButton({
|
|
|
1730
2098
|
);
|
|
1731
2099
|
}
|
|
1732
2100
|
|
|
1733
|
-
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 };
|
|
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 };
|
|
1734
2102
|
//# sourceMappingURL=index.js.map
|
|
1735
2103
|
//# sourceMappingURL=index.js.map
|