@docyrus/signin 0.11.0 → 0.13.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 +35 -0
- package/dist/{constants-DuNDcs9I.d.ts → constants-BBGO2aU5.d.ts} +7 -1
- package/dist/core-index.d.ts +67 -4
- package/dist/core-index.js +292 -1
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +292 -1
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -4
- package/dist/react-native/index.js +291 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/{types-DjG8tL1X.d.ts → types-WOgdg9b0.d.ts} +71 -1
- package/dist/{use-docyrus-client-CQ0J_msv.d.ts → use-docyrus-client-DqdJWKrF.d.ts} +1 -1
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/index.js +291 -0
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -254,6 +254,41 @@ Pass props to `DocyrusAuthProvider` to override defaults:
|
|
|
254
254
|
| `ssr` | `boolean` | `false` | Sync access token to cookie for server components |
|
|
255
255
|
| `ssrCookieKey` | `string` | `docyrus-token` | Cookie name for SSR token sync |
|
|
256
256
|
| `syncRouteToHost` | `boolean` | `false` | Iframe mode: post `route-change` to the host on every history change |
|
|
257
|
+
| `enableGuidyBridge` | `boolean` | `false` | Iframe mode: let the host assistant (Guidy) scan, highlight, and click this app's visible UI (see below) |
|
|
258
|
+
|
|
259
|
+
## Guidy Bridge (host-driven guidance)
|
|
260
|
+
|
|
261
|
+
When an app runs embedded in the Docyrus shell, the host AI assistant (Guidy)
|
|
262
|
+
can guide users _through the app_ — pointing at and clicking real in-app
|
|
263
|
+
buttons — once the app opts in:
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
<DocyrusAuthProvider apiUrl="..." clientId="..." enableGuidyBridge>
|
|
267
|
+
<App />
|
|
268
|
+
</DocyrusAuthProvider>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
This starts a small runtime (`GuidyBridge`) that, in iframe mode only:
|
|
272
|
+
|
|
273
|
+
- pushes the app's clickable inventory (`a[id]` / `button[id]` that are visible
|
|
274
|
+
and labeled) to the host on mount, route change, and DOM mutation;
|
|
275
|
+
- on a host `guidy:point`, scrolls to, highlights, optionally annotates, and
|
|
276
|
+
optionally clicks the target element, then acknowledges.
|
|
277
|
+
|
|
278
|
+
It is opt-in and intentionally narrow: it only exposes already-visible
|
|
279
|
+
interactive elements and only runs a fixed command vocabulary — **no arbitrary
|
|
280
|
+
script is accepted from the host**. All traffic rides the same origin-validated
|
|
281
|
+
postMessage channel as auth.
|
|
282
|
+
|
|
283
|
+
```text
|
|
284
|
+
App → Host: { type: 'guidy:elements', path, elements: [{ id, label, tag }] }
|
|
285
|
+
Host → App: { type: 'guidy:scan' } // re-request inventory
|
|
286
|
+
Host → App: { type: 'guidy:point', id, click?, message? } // point / click / annotate
|
|
287
|
+
App → Host: { type: 'guidy:point-ack', id, ok }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Give the elements Guidy should reach a stable `id` and an accessible label
|
|
291
|
+
(`aria-label`, text content, or `title`).
|
|
257
292
|
|
|
258
293
|
## Hooks / Composables
|
|
259
294
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OAuth2Tokens, RestApiClient } from '@docyrus/api-client';
|
|
2
|
-
import { D as DocyrusAuthConfig, a as AuthMode, c as AuthStatus, g as DocyrusUser, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler, f as DocyrusRole, P as PermissionConfig } from './types-
|
|
2
|
+
import { D as DocyrusAuthConfig, a as AuthMode, c as AuthStatus, g as DocyrusUser, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler, f as DocyrusRole, P as PermissionConfig } from './types-WOgdg9b0.js';
|
|
3
3
|
|
|
4
4
|
type AuthStateListener = (state: {
|
|
5
5
|
status: AuthStatus;
|
|
@@ -21,6 +21,7 @@ declare class AuthManager {
|
|
|
21
21
|
private user;
|
|
22
22
|
private standaloneAuth;
|
|
23
23
|
private iframeAuth;
|
|
24
|
+
private guidyBridge;
|
|
24
25
|
private reactNativeAuth;
|
|
25
26
|
private tokenRefreshTimer;
|
|
26
27
|
private listeners;
|
|
@@ -56,6 +57,11 @@ declare class AuthManager {
|
|
|
56
57
|
* Status remains 'loading' until the host sends the first signin message.
|
|
57
58
|
*/
|
|
58
59
|
private initializeIframeMode;
|
|
60
|
+
/**
|
|
61
|
+
* Start the Guidy bridge runtime: report the app's clickable inventory to
|
|
62
|
+
* the host and execute host scan/point/click commands. Iframe mode only.
|
|
63
|
+
*/
|
|
64
|
+
private startGuidyBridge;
|
|
59
65
|
/**
|
|
60
66
|
* Iframe/WebView mode: start auto-syncing the embedded app's route
|
|
61
67
|
* to the host. Patches history methods and listens for popstate /
|
package/dist/core-index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AuthManager, e as AuthStateListener, D as DEFAULT_API_URL, c as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, g as getAllRoles, h as hasPermission, b as hasRole } from './constants-
|
|
1
|
+
export { A as AuthManager, e as AuthStateListener, D as DEFAULT_API_URL, c as DEFAULT_CALLBACK_PATH, a as DEFAULT_OAUTH_SCOPES, g as getAllRoles, h as hasPermission, b as hasRole } from './constants-BBGO2aU5.js';
|
|
2
2
|
import { OAuth2Tokens } from '@docyrus/api-client';
|
|
3
|
-
import { D as DocyrusAuthConfig, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler, a as AuthMode } from './types-
|
|
4
|
-
export { A as AclOperation, i as AppRouteChangeMessage, c as AuthStatus, d as DocyrusAclRule, e as DocyrusAuthContextValue, j as DocyrusNotification, f as DocyrusRole, g as DocyrusUser,
|
|
3
|
+
import { D as DocyrusAuthConfig, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler, G as GuidyCommandHandler, t as AppToHostMessage, m as GuidyElementsMessage, n as GuidyPointAckMessage, k as GuidyCommandMessage, a as AuthMode } from './types-WOgdg9b0.js';
|
|
4
|
+
export { A as AclOperation, i as AppRouteChangeMessage, c as AuthStatus, d as DocyrusAclRule, e as DocyrusAuthContextValue, j as DocyrusNotification, f as DocyrusRole, g as DocyrusUser, l as GuidyElement, o as GuidyPointMessage, p as GuidyScanMessage, q as HostNavigationMessage, r as HostNotificationMessage, s as HostSignInMessage, P as PermissionConfig, T as TokenRefreshRequestMessage } from './types-WOgdg9b0.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Standalone OAuth2 authorization code flow with PKCE via page redirect.
|
|
@@ -80,6 +80,7 @@ declare class IframeAuth {
|
|
|
80
80
|
private onTokensReceived;
|
|
81
81
|
private navigationHandlers;
|
|
82
82
|
private notificationHandlers;
|
|
83
|
+
private guidyHandlers;
|
|
83
84
|
private routeSyncEnabled;
|
|
84
85
|
private originalPushState;
|
|
85
86
|
private originalReplaceState;
|
|
@@ -118,6 +119,17 @@ declare class IframeAuth {
|
|
|
118
119
|
* Returns an unsubscribe function.
|
|
119
120
|
*/
|
|
120
121
|
onNotification(handler: HostNotificationHandler): () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to host `guidy:*` command messages (point/scan).
|
|
124
|
+
* Returns an unsubscribe function. Used by the Guidy bridge runtime.
|
|
125
|
+
*/
|
|
126
|
+
onGuidyCommand(handler: GuidyCommandHandler): () => void;
|
|
127
|
+
/**
|
|
128
|
+
* Post an app → host message over the same validated channel used for
|
|
129
|
+
* route-change and token-refresh. Used by the Guidy bridge to push its
|
|
130
|
+
* element inventory and point acknowledgements.
|
|
131
|
+
*/
|
|
132
|
+
sendToHost(message: AppToHostMessage): void;
|
|
121
133
|
/**
|
|
122
134
|
* Request fresh tokens from the host.
|
|
123
135
|
* Posts a "token-refresh-request" to the host, then waits for
|
|
@@ -129,12 +141,63 @@ declare class IframeAuth {
|
|
|
129
141
|
requestTokenRefresh(): Promise<OAuth2Tokens>;
|
|
130
142
|
private isOriginAllowed;
|
|
131
143
|
private handleMessage;
|
|
144
|
+
private handleGuidyCommand;
|
|
132
145
|
private handleSignin;
|
|
133
146
|
private handleNavigation;
|
|
134
147
|
private handleNotification;
|
|
135
148
|
private rejectPendingRefresh;
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
/** Post an app → host message (a `guidy:elements` or `guidy:point-ack`). */
|
|
152
|
+
type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyPointAckMessage) => void;
|
|
153
|
+
/**
|
|
154
|
+
* Runs inside an embedded Docyrus app and lets the host assistant (Guidy)
|
|
155
|
+
* inspect and drive the app's visible UI over the existing postMessage
|
|
156
|
+
* channel.
|
|
157
|
+
*
|
|
158
|
+
* It only ever exposes labels/ids of already-visible interactive elements and
|
|
159
|
+
* only executes a fixed command vocabulary (scan / point / click) — the same
|
|
160
|
+
* exposure profile the host assistant already has on its own chrome. No
|
|
161
|
+
* arbitrary script is accepted from the host.
|
|
162
|
+
*
|
|
163
|
+
* Protocol (paired with the host's ExternalAppManager):
|
|
164
|
+
* - App → Host: `guidy:elements` (pushed on start, route change, mutation)
|
|
165
|
+
* - Host → App: `guidy:scan` → app re-posts `guidy:elements`
|
|
166
|
+
* - Host → App: `guidy:point` → app scrolls/highlights/(clicks), then
|
|
167
|
+
* - App → Host: `guidy:point-ack`
|
|
168
|
+
*/
|
|
169
|
+
declare class GuidyBridge {
|
|
170
|
+
private send;
|
|
171
|
+
private started;
|
|
172
|
+
private observer;
|
|
173
|
+
private scanTimer;
|
|
174
|
+
private routeListener;
|
|
175
|
+
private highlightTimer;
|
|
176
|
+
private clickTimer;
|
|
177
|
+
private annotationTimer;
|
|
178
|
+
constructor(send: GuidyBridgeSender);
|
|
179
|
+
/**
|
|
180
|
+
* Begin reporting the element inventory and watching for changes.
|
|
181
|
+
* Idempotent. No-op outside a browser document.
|
|
182
|
+
*/
|
|
183
|
+
start(): void;
|
|
184
|
+
/** Stop watching and tear down any injected overlay. Idempotent. */
|
|
185
|
+
stop(): void;
|
|
186
|
+
/** Dispatch a host `guidy:*` command. Wired to `IframeAuth.onGuidyCommand`. */
|
|
187
|
+
handleCommand(message: GuidyCommandMessage): void;
|
|
188
|
+
/** Collect every visible anchor/button that exposes an id and a label. */
|
|
189
|
+
private collectElements;
|
|
190
|
+
private postElements;
|
|
191
|
+
private scheduleScan;
|
|
192
|
+
private handlePoint;
|
|
193
|
+
private ensureStyle;
|
|
194
|
+
private highlight;
|
|
195
|
+
private clearHighlight;
|
|
196
|
+
private annotate;
|
|
197
|
+
private clearAnnotation;
|
|
198
|
+
private clearTimer;
|
|
199
|
+
}
|
|
200
|
+
|
|
138
201
|
/**
|
|
139
202
|
* Detect whether the app is inside an iframe from a trusted *.docyrus.app host
|
|
140
203
|
* or running as a standalone page.
|
|
@@ -144,4 +207,4 @@ declare class IframeAuth {
|
|
|
144
207
|
*/
|
|
145
208
|
declare function detectAuthMode(allowedOrigins?: string[], allowedPattern?: RegExp): AuthMode;
|
|
146
209
|
|
|
147
|
-
export { AuthMode, DocyrusAuthConfig, HostNavigationHandler, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
|
210
|
+
export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandHandler, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, HostNavigationHandler, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
package/dist/core-index.js
CHANGED
|
@@ -151,10 +151,13 @@ var StandaloneOAuth2Auth = class {
|
|
|
151
151
|
// src/core/iframe-auth.ts
|
|
152
152
|
function postToHost(data) {
|
|
153
153
|
const rnwv = window.ReactNativeWebView;
|
|
154
|
+
const tap = window.__DOCYRUS_DEVTOOLS_MESSAGE_TAP__;
|
|
154
155
|
if (rnwv && typeof rnwv.postMessage === "function") {
|
|
156
|
+
if (typeof tap === "function") tap("out", data, { transport: "webview" });
|
|
155
157
|
rnwv.postMessage(JSON.stringify(data));
|
|
156
158
|
return;
|
|
157
159
|
}
|
|
160
|
+
if (typeof tap === "function") tap("out", data, { transport: "iframe", targetOrigin: "*" });
|
|
158
161
|
window.parent.postMessage(data, "*");
|
|
159
162
|
}
|
|
160
163
|
var IframeAuth = class {
|
|
@@ -164,6 +167,7 @@ var IframeAuth = class {
|
|
|
164
167
|
onTokensReceived = null;
|
|
165
168
|
navigationHandlers = /* @__PURE__ */ new Set();
|
|
166
169
|
notificationHandlers = /* @__PURE__ */ new Set();
|
|
170
|
+
guidyHandlers = /* @__PURE__ */ new Set();
|
|
167
171
|
routeSyncEnabled = false;
|
|
168
172
|
originalPushState = null;
|
|
169
173
|
originalReplaceState = null;
|
|
@@ -196,6 +200,7 @@ var IframeAuth = class {
|
|
|
196
200
|
this.rejectPendingRefresh("IframeAuth stopped");
|
|
197
201
|
this.navigationHandlers.clear();
|
|
198
202
|
this.notificationHandlers.clear();
|
|
203
|
+
this.guidyHandlers.clear();
|
|
199
204
|
this.teardownRouteSync();
|
|
200
205
|
}
|
|
201
206
|
/**
|
|
@@ -287,6 +292,25 @@ var IframeAuth = class {
|
|
|
287
292
|
this.notificationHandlers.delete(handler);
|
|
288
293
|
};
|
|
289
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Subscribe to host `guidy:*` command messages (point/scan).
|
|
297
|
+
* Returns an unsubscribe function. Used by the Guidy bridge runtime.
|
|
298
|
+
*/
|
|
299
|
+
onGuidyCommand(handler) {
|
|
300
|
+
this.guidyHandlers.add(handler);
|
|
301
|
+
return () => {
|
|
302
|
+
this.guidyHandlers.delete(handler);
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Post an app → host message over the same validated channel used for
|
|
307
|
+
* route-change and token-refresh. Used by the Guidy bridge to push its
|
|
308
|
+
* element inventory and point acknowledgements.
|
|
309
|
+
*/
|
|
310
|
+
sendToHost(message) {
|
|
311
|
+
if (this.stopped) return;
|
|
312
|
+
postToHost(message);
|
|
313
|
+
}
|
|
290
314
|
/**
|
|
291
315
|
* Request fresh tokens from the host.
|
|
292
316
|
* Posts a "token-refresh-request" to the host, then waits for
|
|
@@ -339,6 +363,19 @@ var IframeAuth = class {
|
|
|
339
363
|
}
|
|
340
364
|
if (data.type === "notification") {
|
|
341
365
|
this.handleNotification(data);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (data.type === "guidy:point" || data.type === "guidy:scan") {
|
|
369
|
+
this.handleGuidyCommand(data);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
handleGuidyCommand(message) {
|
|
373
|
+
for (const handler of this.guidyHandlers) {
|
|
374
|
+
try {
|
|
375
|
+
handler(message);
|
|
376
|
+
} catch (err) {
|
|
377
|
+
console.warn("[docyrus-signin] guidy command handler threw:", err);
|
|
378
|
+
}
|
|
342
379
|
}
|
|
343
380
|
}
|
|
344
381
|
handleSignin(signinData) {
|
|
@@ -388,6 +425,237 @@ var IframeAuth = class {
|
|
|
388
425
|
}
|
|
389
426
|
};
|
|
390
427
|
|
|
428
|
+
// src/core/guidy-bridge.ts
|
|
429
|
+
var GUIDY_INTERNAL_PREFIX = "guidy-";
|
|
430
|
+
var HIGHLIGHT_CLASS = "guidy-bridge-highlight";
|
|
431
|
+
var HIGHLIGHT_STYLE_ID = "guidy-bridge-style";
|
|
432
|
+
var ANNOTATION_ID = "guidy-bridge-annotation";
|
|
433
|
+
var HIGHLIGHT_DURATION_MS = 5200;
|
|
434
|
+
var SCAN_DEBOUNCE_MS = 250;
|
|
435
|
+
var CLICK_DELAY_MS = 450;
|
|
436
|
+
function elementLabel(node) {
|
|
437
|
+
const aria = node.getAttribute("aria-label")?.trim();
|
|
438
|
+
if (aria) return aria;
|
|
439
|
+
const text = node.textContent?.replace(/\s+/g, " ").trim();
|
|
440
|
+
if (text) return text;
|
|
441
|
+
return node.getAttribute("title")?.trim() ?? "";
|
|
442
|
+
}
|
|
443
|
+
function isVisible(node) {
|
|
444
|
+
const rect = node.getBoundingClientRect();
|
|
445
|
+
if (rect.width === 0 && rect.height === 0) return false;
|
|
446
|
+
const style = window.getComputedStyle(node);
|
|
447
|
+
return style.visibility !== "hidden" && style.display !== "none";
|
|
448
|
+
}
|
|
449
|
+
var GuidyBridge = class {
|
|
450
|
+
send;
|
|
451
|
+
started = false;
|
|
452
|
+
observer = null;
|
|
453
|
+
scanTimer = null;
|
|
454
|
+
routeListener = null;
|
|
455
|
+
highlightTimer = null;
|
|
456
|
+
clickTimer = null;
|
|
457
|
+
annotationTimer = null;
|
|
458
|
+
constructor(send) {
|
|
459
|
+
this.send = send;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Begin reporting the element inventory and watching for changes.
|
|
463
|
+
* Idempotent. No-op outside a browser document.
|
|
464
|
+
*/
|
|
465
|
+
start() {
|
|
466
|
+
if (this.started || typeof document === "undefined") return;
|
|
467
|
+
this.started = true;
|
|
468
|
+
this.ensureStyle();
|
|
469
|
+
this.postElements();
|
|
470
|
+
this.observer = new MutationObserver(() => this.scheduleScan());
|
|
471
|
+
this.observer.observe(document.body, {
|
|
472
|
+
childList: true,
|
|
473
|
+
subtree: true,
|
|
474
|
+
attributes: true,
|
|
475
|
+
attributeFilter: [
|
|
476
|
+
"id",
|
|
477
|
+
"hidden",
|
|
478
|
+
"aria-label",
|
|
479
|
+
"title",
|
|
480
|
+
"style"
|
|
481
|
+
]
|
|
482
|
+
});
|
|
483
|
+
this.routeListener = () => this.scheduleScan();
|
|
484
|
+
window.addEventListener("popstate", this.routeListener);
|
|
485
|
+
window.addEventListener("hashchange", this.routeListener);
|
|
486
|
+
}
|
|
487
|
+
/** Stop watching and tear down any injected overlay. Idempotent. */
|
|
488
|
+
stop() {
|
|
489
|
+
if (!this.started) return;
|
|
490
|
+
this.started = false;
|
|
491
|
+
this.observer?.disconnect();
|
|
492
|
+
this.observer = null;
|
|
493
|
+
if (this.routeListener) {
|
|
494
|
+
window.removeEventListener("popstate", this.routeListener);
|
|
495
|
+
window.removeEventListener("hashchange", this.routeListener);
|
|
496
|
+
this.routeListener = null;
|
|
497
|
+
}
|
|
498
|
+
this.clearTimer("scanTimer");
|
|
499
|
+
this.clearTimer("highlightTimer");
|
|
500
|
+
this.clearTimer("clickTimer");
|
|
501
|
+
this.clearTimer("annotationTimer");
|
|
502
|
+
this.clearHighlight();
|
|
503
|
+
this.clearAnnotation();
|
|
504
|
+
}
|
|
505
|
+
/** Dispatch a host `guidy:*` command. Wired to `IframeAuth.onGuidyCommand`. */
|
|
506
|
+
handleCommand(message) {
|
|
507
|
+
if (message.type === "guidy:scan") {
|
|
508
|
+
this.postElements();
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (message.type === "guidy:point") {
|
|
512
|
+
this.handlePoint(message);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
/** Collect every visible anchor/button that exposes an id and a label. */
|
|
516
|
+
collectElements() {
|
|
517
|
+
if (typeof document === "undefined") return [];
|
|
518
|
+
const nodes = document.querySelectorAll("a[id], button[id]");
|
|
519
|
+
const seen = /* @__PURE__ */ new Set();
|
|
520
|
+
const result = [];
|
|
521
|
+
nodes.forEach((node) => {
|
|
522
|
+
const { id } = node;
|
|
523
|
+
if (!id || id.startsWith(GUIDY_INTERNAL_PREFIX) || seen.has(id)) return;
|
|
524
|
+
if (!isVisible(node)) return;
|
|
525
|
+
const label = elementLabel(node);
|
|
526
|
+
if (!label) return;
|
|
527
|
+
seen.add(id);
|
|
528
|
+
result.push({
|
|
529
|
+
id,
|
|
530
|
+
label,
|
|
531
|
+
tag: node.tagName.toLowerCase() === "a" ? "a" : "button"
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
return result;
|
|
535
|
+
}
|
|
536
|
+
postElements() {
|
|
537
|
+
if (!this.started) return;
|
|
538
|
+
const path = typeof window === "undefined" ? "" : window.location.pathname;
|
|
539
|
+
this.send({
|
|
540
|
+
type: "guidy:elements",
|
|
541
|
+
path,
|
|
542
|
+
elements: this.collectElements()
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
scheduleScan() {
|
|
546
|
+
if (this.scanTimer) return;
|
|
547
|
+
this.scanTimer = setTimeout(() => {
|
|
548
|
+
this.scanTimer = null;
|
|
549
|
+
this.postElements();
|
|
550
|
+
}, SCAN_DEBOUNCE_MS);
|
|
551
|
+
}
|
|
552
|
+
handlePoint(message) {
|
|
553
|
+
const element = typeof document === "undefined" ? null : document.getElementById(message.id);
|
|
554
|
+
if (!element) {
|
|
555
|
+
this.send({ type: "guidy:point-ack", id: message.id, ok: false });
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
element.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
559
|
+
this.highlight(element);
|
|
560
|
+
if (message.message) {
|
|
561
|
+
this.annotate(element, message.message);
|
|
562
|
+
}
|
|
563
|
+
if (message.click) {
|
|
564
|
+
this.clearTimer("clickTimer");
|
|
565
|
+
this.clickTimer = setTimeout(() => {
|
|
566
|
+
this.clickTimer = null;
|
|
567
|
+
element.click();
|
|
568
|
+
}, CLICK_DELAY_MS);
|
|
569
|
+
}
|
|
570
|
+
this.send({ type: "guidy:point-ack", id: message.id, ok: true });
|
|
571
|
+
}
|
|
572
|
+
ensureStyle() {
|
|
573
|
+
if (typeof document === "undefined") return;
|
|
574
|
+
if (document.getElementById(HIGHLIGHT_STYLE_ID)) return;
|
|
575
|
+
const style = document.createElement("style");
|
|
576
|
+
style.id = HIGHLIGHT_STYLE_ID;
|
|
577
|
+
style.textContent = `
|
|
578
|
+
.${HIGHLIGHT_CLASS} {
|
|
579
|
+
outline: 2px solid #3b82f6 !important;
|
|
580
|
+
outline-offset: 2px;
|
|
581
|
+
border-radius: 8px;
|
|
582
|
+
animation: guidy-bridge-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
|
|
583
|
+
}
|
|
584
|
+
@keyframes guidy-bridge-ping {
|
|
585
|
+
0% {
|
|
586
|
+
box-shadow: 0 0 0 0 color-mix(in srgb, #3b82f6 50%, transparent);
|
|
587
|
+
}
|
|
588
|
+
75%, 100% {
|
|
589
|
+
box-shadow: 0 0 0 10px color-mix(in srgb, #3b82f6 0%, transparent);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
#${ANNOTATION_ID} {
|
|
593
|
+
position: fixed;
|
|
594
|
+
z-index: 2147483647;
|
|
595
|
+
max-width: 240px;
|
|
596
|
+
padding: 8px 12px;
|
|
597
|
+
border-radius: 10px;
|
|
598
|
+
background: #111827;
|
|
599
|
+
color: #f9fafb;
|
|
600
|
+
font: 13px/1.4 system-ui, -apple-system, sans-serif;
|
|
601
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
|
602
|
+
pointer-events: none;
|
|
603
|
+
}
|
|
604
|
+
`;
|
|
605
|
+
document.head.appendChild(style);
|
|
606
|
+
}
|
|
607
|
+
highlight(element) {
|
|
608
|
+
this.clearTimer("highlightTimer");
|
|
609
|
+
this.clearHighlight();
|
|
610
|
+
element.classList.add(HIGHLIGHT_CLASS);
|
|
611
|
+
this.highlightTimer = setTimeout(() => {
|
|
612
|
+
this.highlightTimer = null;
|
|
613
|
+
this.clearHighlight();
|
|
614
|
+
}, HIGHLIGHT_DURATION_MS);
|
|
615
|
+
}
|
|
616
|
+
clearHighlight() {
|
|
617
|
+
if (typeof document === "undefined") return;
|
|
618
|
+
document.querySelectorAll(`.${HIGHLIGHT_CLASS}`).forEach((node) => node.classList.remove(HIGHLIGHT_CLASS));
|
|
619
|
+
}
|
|
620
|
+
annotate(element, message) {
|
|
621
|
+
if (typeof document === "undefined") return;
|
|
622
|
+
this.clearTimer("annotationTimer");
|
|
623
|
+
this.clearAnnotation();
|
|
624
|
+
const bubble = document.createElement("div");
|
|
625
|
+
bubble.id = ANNOTATION_ID;
|
|
626
|
+
bubble.textContent = message;
|
|
627
|
+
document.body.appendChild(bubble);
|
|
628
|
+
const rect = element.getBoundingClientRect();
|
|
629
|
+
const bubbleRect = bubble.getBoundingClientRect();
|
|
630
|
+
const gap = 10;
|
|
631
|
+
let top = rect.bottom + gap;
|
|
632
|
+
if (top + bubbleRect.height > window.innerHeight) {
|
|
633
|
+
top = Math.max(gap, rect.top - bubbleRect.height - gap);
|
|
634
|
+
}
|
|
635
|
+
const left = Math.min(
|
|
636
|
+
Math.max(gap, rect.left),
|
|
637
|
+
window.innerWidth - bubbleRect.width - gap
|
|
638
|
+
);
|
|
639
|
+
bubble.style.top = `${Math.round(top)}px`;
|
|
640
|
+
bubble.style.left = `${Math.round(left)}px`;
|
|
641
|
+
this.annotationTimer = setTimeout(() => {
|
|
642
|
+
this.annotationTimer = null;
|
|
643
|
+
this.clearAnnotation();
|
|
644
|
+
}, HIGHLIGHT_DURATION_MS);
|
|
645
|
+
}
|
|
646
|
+
clearAnnotation() {
|
|
647
|
+
if (typeof document === "undefined") return;
|
|
648
|
+
document.getElementById(ANNOTATION_ID)?.remove();
|
|
649
|
+
}
|
|
650
|
+
clearTimer(key) {
|
|
651
|
+
const timer = this[key];
|
|
652
|
+
if (timer) {
|
|
653
|
+
clearTimeout(timer);
|
|
654
|
+
this[key] = null;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
391
659
|
// src/core/sso-auth.ts
|
|
392
660
|
var SsoAuth = class {
|
|
393
661
|
config;
|
|
@@ -548,6 +816,7 @@ var AuthManager = class {
|
|
|
548
816
|
user = null;
|
|
549
817
|
standaloneAuth = null;
|
|
550
818
|
iframeAuth = null;
|
|
819
|
+
guidyBridge = null;
|
|
551
820
|
reactNativeAuth = null;
|
|
552
821
|
tokenRefreshTimer = null;
|
|
553
822
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -712,6 +981,20 @@ var AuthManager = class {
|
|
|
712
981
|
if (this.config.syncRouteToHost) {
|
|
713
982
|
this.iframeAuth.enableRouteSync();
|
|
714
983
|
}
|
|
984
|
+
if (this.config.enableGuidyBridge) {
|
|
985
|
+
this.startGuidyBridge();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Start the Guidy bridge runtime: report the app's clickable inventory to
|
|
990
|
+
* the host and execute host scan/point/click commands. Iframe mode only.
|
|
991
|
+
*/
|
|
992
|
+
startGuidyBridge() {
|
|
993
|
+
if (!this.iframeAuth || this.guidyBridge) return;
|
|
994
|
+
const bridge = new GuidyBridge((message) => this.iframeAuth?.sendToHost(message));
|
|
995
|
+
this.iframeAuth.onGuidyCommand((message) => bridge.handleCommand(message));
|
|
996
|
+
bridge.start();
|
|
997
|
+
this.guidyBridge = bridge;
|
|
715
998
|
}
|
|
716
999
|
/**
|
|
717
1000
|
* Iframe/WebView mode: start auto-syncing the embedded app's route
|
|
@@ -846,6 +1129,10 @@ var AuthManager = class {
|
|
|
846
1129
|
await this.reactNativeAuth.logout();
|
|
847
1130
|
}
|
|
848
1131
|
if (this.mode === "iframe" && this.iframeAuth) {
|
|
1132
|
+
if (this.guidyBridge) {
|
|
1133
|
+
this.guidyBridge.stop();
|
|
1134
|
+
this.guidyBridge = null;
|
|
1135
|
+
}
|
|
849
1136
|
this.iframeAuth.stop();
|
|
850
1137
|
}
|
|
851
1138
|
if (this.config.ssr) {
|
|
@@ -1016,6 +1303,10 @@ var AuthManager = class {
|
|
|
1016
1303
|
/** Cleanup: remove listeners, timers, stop iframe auth. */
|
|
1017
1304
|
destroy() {
|
|
1018
1305
|
this.clearTokenRefreshTimer();
|
|
1306
|
+
if (this.guidyBridge) {
|
|
1307
|
+
this.guidyBridge.stop();
|
|
1308
|
+
this.guidyBridge = null;
|
|
1309
|
+
}
|
|
1019
1310
|
if (this.iframeAuth) this.iframeAuth.stop();
|
|
1020
1311
|
this.listeners.clear();
|
|
1021
1312
|
this.navigationHandlers.clear();
|
|
@@ -1123,6 +1414,6 @@ function hasPermission(user, operation, dataSourceId, config) {
|
|
|
1123
1414
|
);
|
|
1124
1415
|
}
|
|
1125
1416
|
|
|
1126
|
-
export { AuthManager, DEFAULT_API_URL, DEFAULT_CALLBACK_PATH, DEFAULT_OAUTH_SCOPES, IframeAuth, StandaloneOAuth2Auth, detectAuthMode, getAllRoles, hasPermission, hasRole };
|
|
1417
|
+
export { AuthManager, DEFAULT_API_URL, DEFAULT_CALLBACK_PATH, DEFAULT_OAUTH_SCOPES, GuidyBridge, IframeAuth, StandaloneOAuth2Auth, detectAuthMode, getAllRoles, hasPermission, hasRole };
|
|
1127
1418
|
//# sourceMappingURL=core-index.js.map
|
|
1128
1419
|
//# sourceMappingURL=core-index.js.map
|