@docyrus/signin 0.12.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 +289 -1
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +289 -1
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -4
- package/dist/react-native/index.js +288 -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 +288 -0
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -247,6 +247,7 @@ var IframeAuth = class {
|
|
|
247
247
|
onTokensReceived = null;
|
|
248
248
|
navigationHandlers = /* @__PURE__ */ new Set();
|
|
249
249
|
notificationHandlers = /* @__PURE__ */ new Set();
|
|
250
|
+
guidyHandlers = /* @__PURE__ */ new Set();
|
|
250
251
|
routeSyncEnabled = false;
|
|
251
252
|
originalPushState = null;
|
|
252
253
|
originalReplaceState = null;
|
|
@@ -279,6 +280,7 @@ var IframeAuth = class {
|
|
|
279
280
|
this.rejectPendingRefresh("IframeAuth stopped");
|
|
280
281
|
this.navigationHandlers.clear();
|
|
281
282
|
this.notificationHandlers.clear();
|
|
283
|
+
this.guidyHandlers.clear();
|
|
282
284
|
this.teardownRouteSync();
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
@@ -370,6 +372,25 @@ var IframeAuth = class {
|
|
|
370
372
|
this.notificationHandlers.delete(handler);
|
|
371
373
|
};
|
|
372
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Subscribe to host `guidy:*` command messages (point/scan).
|
|
377
|
+
* Returns an unsubscribe function. Used by the Guidy bridge runtime.
|
|
378
|
+
*/
|
|
379
|
+
onGuidyCommand(handler) {
|
|
380
|
+
this.guidyHandlers.add(handler);
|
|
381
|
+
return () => {
|
|
382
|
+
this.guidyHandlers.delete(handler);
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Post an app → host message over the same validated channel used for
|
|
387
|
+
* route-change and token-refresh. Used by the Guidy bridge to push its
|
|
388
|
+
* element inventory and point acknowledgements.
|
|
389
|
+
*/
|
|
390
|
+
sendToHost(message) {
|
|
391
|
+
if (this.stopped) return;
|
|
392
|
+
postToHost(message);
|
|
393
|
+
}
|
|
373
394
|
/**
|
|
374
395
|
* Request fresh tokens from the host.
|
|
375
396
|
* Posts a "token-refresh-request" to the host, then waits for
|
|
@@ -422,6 +443,19 @@ var IframeAuth = class {
|
|
|
422
443
|
}
|
|
423
444
|
if (data.type === "notification") {
|
|
424
445
|
this.handleNotification(data);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (data.type === "guidy:point" || data.type === "guidy:scan") {
|
|
449
|
+
this.handleGuidyCommand(data);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
handleGuidyCommand(message) {
|
|
453
|
+
for (const handler of this.guidyHandlers) {
|
|
454
|
+
try {
|
|
455
|
+
handler(message);
|
|
456
|
+
} catch (err) {
|
|
457
|
+
console.warn("[docyrus-signin] guidy command handler threw:", err);
|
|
458
|
+
}
|
|
425
459
|
}
|
|
426
460
|
}
|
|
427
461
|
handleSignin(signinData) {
|
|
@@ -471,6 +505,237 @@ var IframeAuth = class {
|
|
|
471
505
|
}
|
|
472
506
|
};
|
|
473
507
|
|
|
508
|
+
// src/core/guidy-bridge.ts
|
|
509
|
+
var GUIDY_INTERNAL_PREFIX = "guidy-";
|
|
510
|
+
var HIGHLIGHT_CLASS = "guidy-bridge-highlight";
|
|
511
|
+
var HIGHLIGHT_STYLE_ID = "guidy-bridge-style";
|
|
512
|
+
var ANNOTATION_ID = "guidy-bridge-annotation";
|
|
513
|
+
var HIGHLIGHT_DURATION_MS = 5200;
|
|
514
|
+
var SCAN_DEBOUNCE_MS = 250;
|
|
515
|
+
var CLICK_DELAY_MS = 450;
|
|
516
|
+
function elementLabel(node) {
|
|
517
|
+
const aria = node.getAttribute("aria-label")?.trim();
|
|
518
|
+
if (aria) return aria;
|
|
519
|
+
const text = node.textContent?.replace(/\s+/g, " ").trim();
|
|
520
|
+
if (text) return text;
|
|
521
|
+
return node.getAttribute("title")?.trim() ?? "";
|
|
522
|
+
}
|
|
523
|
+
function isVisible(node) {
|
|
524
|
+
const rect = node.getBoundingClientRect();
|
|
525
|
+
if (rect.width === 0 && rect.height === 0) return false;
|
|
526
|
+
const style = window.getComputedStyle(node);
|
|
527
|
+
return style.visibility !== "hidden" && style.display !== "none";
|
|
528
|
+
}
|
|
529
|
+
var GuidyBridge = class {
|
|
530
|
+
send;
|
|
531
|
+
started = false;
|
|
532
|
+
observer = null;
|
|
533
|
+
scanTimer = null;
|
|
534
|
+
routeListener = null;
|
|
535
|
+
highlightTimer = null;
|
|
536
|
+
clickTimer = null;
|
|
537
|
+
annotationTimer = null;
|
|
538
|
+
constructor(send) {
|
|
539
|
+
this.send = send;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Begin reporting the element inventory and watching for changes.
|
|
543
|
+
* Idempotent. No-op outside a browser document.
|
|
544
|
+
*/
|
|
545
|
+
start() {
|
|
546
|
+
if (this.started || typeof document === "undefined") return;
|
|
547
|
+
this.started = true;
|
|
548
|
+
this.ensureStyle();
|
|
549
|
+
this.postElements();
|
|
550
|
+
this.observer = new MutationObserver(() => this.scheduleScan());
|
|
551
|
+
this.observer.observe(document.body, {
|
|
552
|
+
childList: true,
|
|
553
|
+
subtree: true,
|
|
554
|
+
attributes: true,
|
|
555
|
+
attributeFilter: [
|
|
556
|
+
"id",
|
|
557
|
+
"hidden",
|
|
558
|
+
"aria-label",
|
|
559
|
+
"title",
|
|
560
|
+
"style"
|
|
561
|
+
]
|
|
562
|
+
});
|
|
563
|
+
this.routeListener = () => this.scheduleScan();
|
|
564
|
+
window.addEventListener("popstate", this.routeListener);
|
|
565
|
+
window.addEventListener("hashchange", this.routeListener);
|
|
566
|
+
}
|
|
567
|
+
/** Stop watching and tear down any injected overlay. Idempotent. */
|
|
568
|
+
stop() {
|
|
569
|
+
if (!this.started) return;
|
|
570
|
+
this.started = false;
|
|
571
|
+
this.observer?.disconnect();
|
|
572
|
+
this.observer = null;
|
|
573
|
+
if (this.routeListener) {
|
|
574
|
+
window.removeEventListener("popstate", this.routeListener);
|
|
575
|
+
window.removeEventListener("hashchange", this.routeListener);
|
|
576
|
+
this.routeListener = null;
|
|
577
|
+
}
|
|
578
|
+
this.clearTimer("scanTimer");
|
|
579
|
+
this.clearTimer("highlightTimer");
|
|
580
|
+
this.clearTimer("clickTimer");
|
|
581
|
+
this.clearTimer("annotationTimer");
|
|
582
|
+
this.clearHighlight();
|
|
583
|
+
this.clearAnnotation();
|
|
584
|
+
}
|
|
585
|
+
/** Dispatch a host `guidy:*` command. Wired to `IframeAuth.onGuidyCommand`. */
|
|
586
|
+
handleCommand(message) {
|
|
587
|
+
if (message.type === "guidy:scan") {
|
|
588
|
+
this.postElements();
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (message.type === "guidy:point") {
|
|
592
|
+
this.handlePoint(message);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/** Collect every visible anchor/button that exposes an id and a label. */
|
|
596
|
+
collectElements() {
|
|
597
|
+
if (typeof document === "undefined") return [];
|
|
598
|
+
const nodes = document.querySelectorAll("a[id], button[id]");
|
|
599
|
+
const seen = /* @__PURE__ */ new Set();
|
|
600
|
+
const result = [];
|
|
601
|
+
nodes.forEach((node) => {
|
|
602
|
+
const { id } = node;
|
|
603
|
+
if (!id || id.startsWith(GUIDY_INTERNAL_PREFIX) || seen.has(id)) return;
|
|
604
|
+
if (!isVisible(node)) return;
|
|
605
|
+
const label = elementLabel(node);
|
|
606
|
+
if (!label) return;
|
|
607
|
+
seen.add(id);
|
|
608
|
+
result.push({
|
|
609
|
+
id,
|
|
610
|
+
label,
|
|
611
|
+
tag: node.tagName.toLowerCase() === "a" ? "a" : "button"
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
postElements() {
|
|
617
|
+
if (!this.started) return;
|
|
618
|
+
const path = typeof window === "undefined" ? "" : window.location.pathname;
|
|
619
|
+
this.send({
|
|
620
|
+
type: "guidy:elements",
|
|
621
|
+
path,
|
|
622
|
+
elements: this.collectElements()
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
scheduleScan() {
|
|
626
|
+
if (this.scanTimer) return;
|
|
627
|
+
this.scanTimer = setTimeout(() => {
|
|
628
|
+
this.scanTimer = null;
|
|
629
|
+
this.postElements();
|
|
630
|
+
}, SCAN_DEBOUNCE_MS);
|
|
631
|
+
}
|
|
632
|
+
handlePoint(message) {
|
|
633
|
+
const element = typeof document === "undefined" ? null : document.getElementById(message.id);
|
|
634
|
+
if (!element) {
|
|
635
|
+
this.send({ type: "guidy:point-ack", id: message.id, ok: false });
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
element.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
639
|
+
this.highlight(element);
|
|
640
|
+
if (message.message) {
|
|
641
|
+
this.annotate(element, message.message);
|
|
642
|
+
}
|
|
643
|
+
if (message.click) {
|
|
644
|
+
this.clearTimer("clickTimer");
|
|
645
|
+
this.clickTimer = setTimeout(() => {
|
|
646
|
+
this.clickTimer = null;
|
|
647
|
+
element.click();
|
|
648
|
+
}, CLICK_DELAY_MS);
|
|
649
|
+
}
|
|
650
|
+
this.send({ type: "guidy:point-ack", id: message.id, ok: true });
|
|
651
|
+
}
|
|
652
|
+
ensureStyle() {
|
|
653
|
+
if (typeof document === "undefined") return;
|
|
654
|
+
if (document.getElementById(HIGHLIGHT_STYLE_ID)) return;
|
|
655
|
+
const style = document.createElement("style");
|
|
656
|
+
style.id = HIGHLIGHT_STYLE_ID;
|
|
657
|
+
style.textContent = `
|
|
658
|
+
.${HIGHLIGHT_CLASS} {
|
|
659
|
+
outline: 2px solid #3b82f6 !important;
|
|
660
|
+
outline-offset: 2px;
|
|
661
|
+
border-radius: 8px;
|
|
662
|
+
animation: guidy-bridge-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
|
|
663
|
+
}
|
|
664
|
+
@keyframes guidy-bridge-ping {
|
|
665
|
+
0% {
|
|
666
|
+
box-shadow: 0 0 0 0 color-mix(in srgb, #3b82f6 50%, transparent);
|
|
667
|
+
}
|
|
668
|
+
75%, 100% {
|
|
669
|
+
box-shadow: 0 0 0 10px color-mix(in srgb, #3b82f6 0%, transparent);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
#${ANNOTATION_ID} {
|
|
673
|
+
position: fixed;
|
|
674
|
+
z-index: 2147483647;
|
|
675
|
+
max-width: 240px;
|
|
676
|
+
padding: 8px 12px;
|
|
677
|
+
border-radius: 10px;
|
|
678
|
+
background: #111827;
|
|
679
|
+
color: #f9fafb;
|
|
680
|
+
font: 13px/1.4 system-ui, -apple-system, sans-serif;
|
|
681
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
|
682
|
+
pointer-events: none;
|
|
683
|
+
}
|
|
684
|
+
`;
|
|
685
|
+
document.head.appendChild(style);
|
|
686
|
+
}
|
|
687
|
+
highlight(element) {
|
|
688
|
+
this.clearTimer("highlightTimer");
|
|
689
|
+
this.clearHighlight();
|
|
690
|
+
element.classList.add(HIGHLIGHT_CLASS);
|
|
691
|
+
this.highlightTimer = setTimeout(() => {
|
|
692
|
+
this.highlightTimer = null;
|
|
693
|
+
this.clearHighlight();
|
|
694
|
+
}, HIGHLIGHT_DURATION_MS);
|
|
695
|
+
}
|
|
696
|
+
clearHighlight() {
|
|
697
|
+
if (typeof document === "undefined") return;
|
|
698
|
+
document.querySelectorAll(`.${HIGHLIGHT_CLASS}`).forEach((node) => node.classList.remove(HIGHLIGHT_CLASS));
|
|
699
|
+
}
|
|
700
|
+
annotate(element, message) {
|
|
701
|
+
if (typeof document === "undefined") return;
|
|
702
|
+
this.clearTimer("annotationTimer");
|
|
703
|
+
this.clearAnnotation();
|
|
704
|
+
const bubble = document.createElement("div");
|
|
705
|
+
bubble.id = ANNOTATION_ID;
|
|
706
|
+
bubble.textContent = message;
|
|
707
|
+
document.body.appendChild(bubble);
|
|
708
|
+
const rect = element.getBoundingClientRect();
|
|
709
|
+
const bubbleRect = bubble.getBoundingClientRect();
|
|
710
|
+
const gap = 10;
|
|
711
|
+
let top = rect.bottom + gap;
|
|
712
|
+
if (top + bubbleRect.height > window.innerHeight) {
|
|
713
|
+
top = Math.max(gap, rect.top - bubbleRect.height - gap);
|
|
714
|
+
}
|
|
715
|
+
const left = Math.min(
|
|
716
|
+
Math.max(gap, rect.left),
|
|
717
|
+
window.innerWidth - bubbleRect.width - gap
|
|
718
|
+
);
|
|
719
|
+
bubble.style.top = `${Math.round(top)}px`;
|
|
720
|
+
bubble.style.left = `${Math.round(left)}px`;
|
|
721
|
+
this.annotationTimer = setTimeout(() => {
|
|
722
|
+
this.annotationTimer = null;
|
|
723
|
+
this.clearAnnotation();
|
|
724
|
+
}, HIGHLIGHT_DURATION_MS);
|
|
725
|
+
}
|
|
726
|
+
clearAnnotation() {
|
|
727
|
+
if (typeof document === "undefined") return;
|
|
728
|
+
document.getElementById(ANNOTATION_ID)?.remove();
|
|
729
|
+
}
|
|
730
|
+
clearTimer(key) {
|
|
731
|
+
const timer = this[key];
|
|
732
|
+
if (timer) {
|
|
733
|
+
clearTimeout(timer);
|
|
734
|
+
this[key] = null;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
|
|
474
739
|
// src/core/sso-auth.ts
|
|
475
740
|
var SsoAuth = class {
|
|
476
741
|
config;
|
|
@@ -555,6 +820,7 @@ var AuthManager = class {
|
|
|
555
820
|
user = null;
|
|
556
821
|
standaloneAuth = null;
|
|
557
822
|
iframeAuth = null;
|
|
823
|
+
guidyBridge = null;
|
|
558
824
|
reactNativeAuth = null;
|
|
559
825
|
tokenRefreshTimer = null;
|
|
560
826
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -719,6 +985,20 @@ var AuthManager = class {
|
|
|
719
985
|
if (this.config.syncRouteToHost) {
|
|
720
986
|
this.iframeAuth.enableRouteSync();
|
|
721
987
|
}
|
|
988
|
+
if (this.config.enableGuidyBridge) {
|
|
989
|
+
this.startGuidyBridge();
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Start the Guidy bridge runtime: report the app's clickable inventory to
|
|
994
|
+
* the host and execute host scan/point/click commands. Iframe mode only.
|
|
995
|
+
*/
|
|
996
|
+
startGuidyBridge() {
|
|
997
|
+
if (!this.iframeAuth || this.guidyBridge) return;
|
|
998
|
+
const bridge = new GuidyBridge((message) => this.iframeAuth?.sendToHost(message));
|
|
999
|
+
this.iframeAuth.onGuidyCommand((message) => bridge.handleCommand(message));
|
|
1000
|
+
bridge.start();
|
|
1001
|
+
this.guidyBridge = bridge;
|
|
722
1002
|
}
|
|
723
1003
|
/**
|
|
724
1004
|
* Iframe/WebView mode: start auto-syncing the embedded app's route
|
|
@@ -853,6 +1133,10 @@ var AuthManager = class {
|
|
|
853
1133
|
await this.reactNativeAuth.logout();
|
|
854
1134
|
}
|
|
855
1135
|
if (this.mode === "iframe" && this.iframeAuth) {
|
|
1136
|
+
if (this.guidyBridge) {
|
|
1137
|
+
this.guidyBridge.stop();
|
|
1138
|
+
this.guidyBridge = null;
|
|
1139
|
+
}
|
|
856
1140
|
this.iframeAuth.stop();
|
|
857
1141
|
}
|
|
858
1142
|
if (this.config.ssr) {
|
|
@@ -1023,6 +1307,10 @@ var AuthManager = class {
|
|
|
1023
1307
|
/** Cleanup: remove listeners, timers, stop iframe auth. */
|
|
1024
1308
|
destroy() {
|
|
1025
1309
|
this.clearTokenRefreshTimer();
|
|
1310
|
+
if (this.guidyBridge) {
|
|
1311
|
+
this.guidyBridge.stop();
|
|
1312
|
+
this.guidyBridge = null;
|
|
1313
|
+
}
|
|
1026
1314
|
if (this.iframeAuth) this.iframeAuth.stop();
|
|
1027
1315
|
this.listeners.clear();
|
|
1028
1316
|
this.navigationHandlers.clear();
|