@docyrus/signin 0.13.0 → 0.14.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 +37 -1
- package/dist/{constants-BBGO2aU5.d.ts → constants-DtyJKJgJ.d.ts} +6 -1
- package/dist/core-index.d.ts +13 -8
- package/dist/core-index.js +26 -2
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -4
- package/dist/react-native/index.js +33 -2
- package/dist/react-native/index.js.map +1 -1
- package/dist/{types-WOgdg9b0.d.ts → types-D4ZAVj-B.d.ts} +36 -2
- package/dist/{use-docyrus-client-DqdJWKrF.d.ts → use-docyrus-client-o9nPwayd.d.ts} +1 -1
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/index.js +26 -2
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -255,6 +255,7 @@ Pass props to `DocyrusAuthProvider` to override defaults:
|
|
|
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
257
|
| `enableGuidyBridge` | `boolean` | `false` | Iframe mode: let the host assistant (Guidy) scan, highlight, and click this app's visible UI (see below) |
|
|
258
|
+
| `guidyRoutes` | `GuidyRoute[]` | `undefined` | Iframe mode: routes Guidy may navigate the user to inside this app (see below). Requires `enableGuidyBridge` |
|
|
258
259
|
|
|
259
260
|
## Guidy Bridge (host-driven guidance)
|
|
260
261
|
|
|
@@ -282,7 +283,8 @@ postMessage channel as auth.
|
|
|
282
283
|
|
|
283
284
|
```text
|
|
284
285
|
App → Host: { type: 'guidy:elements', path, elements: [{ id, label, tag }] }
|
|
285
|
-
|
|
286
|
+
App → Host: { type: 'guidy:routes', routes: [{ path, label }] }
|
|
287
|
+
Host → App: { type: 'guidy:scan' } // re-request inventory + routes
|
|
286
288
|
Host → App: { type: 'guidy:point', id, click?, message? } // point / click / annotate
|
|
287
289
|
App → Host: { type: 'guidy:point-ack', id, ok }
|
|
288
290
|
```
|
|
@@ -290,6 +292,40 @@ App → Host: { type: 'guidy:point-ack', id, ok }
|
|
|
290
292
|
Give the elements Guidy should reach a stable `id` and an accessible label
|
|
291
293
|
(`aria-label`, text content, or `title`).
|
|
292
294
|
|
|
295
|
+
### In-app navigation (routes)
|
|
296
|
+
|
|
297
|
+
Elements are auto-discovered from the DOM; routes are not, so the app declares
|
|
298
|
+
which pages Guidy may send the user to. The host merges them into Guidy's
|
|
299
|
+
navigation tree as deep links and drives them through the existing host→app
|
|
300
|
+
`navigation` message. Declare them statically:
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
<DocyrusAuthProvider
|
|
304
|
+
apiUrl="..."
|
|
305
|
+
clientId="..."
|
|
306
|
+
enableGuidyBridge
|
|
307
|
+
guidyRoutes={[
|
|
308
|
+
{ path: "/leads", label: "Leads" },
|
|
309
|
+
{ path: "/leads/new", label: "New Lead" }
|
|
310
|
+
]}
|
|
311
|
+
>
|
|
312
|
+
<App />
|
|
313
|
+
</DocyrusAuthProvider>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
…or dynamically (e.g. when routes depend on permissions) with the hook:
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
import { useDocyrusGuidyRoutes } from "@docyrus/signin"
|
|
320
|
+
|
|
321
|
+
useDocyrusGuidyRoutes(visibleRoutes) // re-syncs whenever the array changes
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Driving a route requires the app to handle inbound host navigation — wire
|
|
325
|
+
`useDocyrusHostNavigation` (or `syncRouteToHost`) so the deep link reaches your
|
|
326
|
+
router. `path` is app-internal (e.g. `/leads`); the host prefixes it with the
|
|
327
|
+
app's mount path.
|
|
328
|
+
|
|
293
329
|
## Hooks / Composables
|
|
294
330
|
|
|
295
331
|
### useDocyrusAuth()
|
|
@@ -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, G as GuidyRoute, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler, f as DocyrusRole, P as PermissionConfig } from './types-D4ZAVj-B.js';
|
|
3
3
|
|
|
4
4
|
type AuthStateListener = (state: {
|
|
5
5
|
status: AuthStatus;
|
|
@@ -62,6 +62,11 @@ declare class AuthManager {
|
|
|
62
62
|
* the host and execute host scan/point/click commands. Iframe mode only.
|
|
63
63
|
*/
|
|
64
64
|
private startGuidyBridge;
|
|
65
|
+
/**
|
|
66
|
+
* Iframe mode: replace the routes the Guidy bridge advertises to the host.
|
|
67
|
+
* No-op unless the bridge is running (`enableGuidyBridge`).
|
|
68
|
+
*/
|
|
69
|
+
setGuidyRoutes(routes: GuidyRoute[]): void;
|
|
65
70
|
/**
|
|
66
71
|
* Iframe/WebView mode: start auto-syncing the embedded app's route
|
|
67
72
|
* 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-DtyJKJgJ.js';
|
|
2
2
|
import { OAuth2Tokens } from '@docyrus/api-client';
|
|
3
|
-
import { D as DocyrusAuthConfig, R as RouteChangePayload, H as HostNavigationHandler, h as HostNotificationHandler,
|
|
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, k as GuidyCommandHandler, v as AppToHostMessage, n as GuidyElementsMessage, q as GuidyRoutesMessage, o as GuidyPointAckMessage, G as GuidyRoute, l as GuidyCommandMessage, a as AuthMode } from './types-D4ZAVj-B.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, m as GuidyElement, p as GuidyPointMessage, r as GuidyScanMessage, s as HostNavigationMessage, t as HostNotificationMessage, u as HostSignInMessage, P as PermissionConfig, T as TokenRefreshRequestMessage } from './types-D4ZAVj-B.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Standalone OAuth2 authorization code flow with PKCE via page redirect.
|
|
@@ -148,8 +148,8 @@ declare class IframeAuth {
|
|
|
148
148
|
private rejectPendingRefresh;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
/** Post an app → host message (
|
|
152
|
-
type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyPointAckMessage) => void;
|
|
151
|
+
/** Post an app → host message (elements, routes, or a point ack). */
|
|
152
|
+
type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyRoutesMessage | GuidyPointAckMessage) => void;
|
|
153
153
|
/**
|
|
154
154
|
* Runs inside an embedded Docyrus app and lets the host assistant (Guidy)
|
|
155
155
|
* inspect and drive the app's visible UI over the existing postMessage
|
|
@@ -162,12 +162,14 @@ type GuidyBridgeSender = (message: GuidyElementsMessage | GuidyPointAckMessage)
|
|
|
162
162
|
*
|
|
163
163
|
* Protocol (paired with the host's ExternalAppManager):
|
|
164
164
|
* - App → Host: `guidy:elements` (pushed on start, route change, mutation)
|
|
165
|
-
* -
|
|
165
|
+
* - App → Host: `guidy:routes` (pushed on start and when routes change)
|
|
166
|
+
* - Host → App: `guidy:scan` → app re-posts `guidy:elements` + `guidy:routes`
|
|
166
167
|
* - Host → App: `guidy:point` → app scrolls/highlights/(clicks), then
|
|
167
168
|
* - App → Host: `guidy:point-ack`
|
|
168
169
|
*/
|
|
169
170
|
declare class GuidyBridge {
|
|
170
171
|
private send;
|
|
172
|
+
private routes;
|
|
171
173
|
private started;
|
|
172
174
|
private observer;
|
|
173
175
|
private scanTimer;
|
|
@@ -175,7 +177,9 @@ declare class GuidyBridge {
|
|
|
175
177
|
private highlightTimer;
|
|
176
178
|
private clickTimer;
|
|
177
179
|
private annotationTimer;
|
|
178
|
-
constructor(send: GuidyBridgeSender);
|
|
180
|
+
constructor(send: GuidyBridgeSender, routes?: GuidyRoute[]);
|
|
181
|
+
/** Replace the declared navigable routes and re-post them to the host. */
|
|
182
|
+
setRoutes(routes: GuidyRoute[]): void;
|
|
179
183
|
/**
|
|
180
184
|
* Begin reporting the element inventory and watching for changes.
|
|
181
185
|
* Idempotent. No-op outside a browser document.
|
|
@@ -188,6 +192,7 @@ declare class GuidyBridge {
|
|
|
188
192
|
/** Collect every visible anchor/button that exposes an id and a label. */
|
|
189
193
|
private collectElements;
|
|
190
194
|
private postElements;
|
|
195
|
+
private postRoutes;
|
|
191
196
|
private scheduleScan;
|
|
192
197
|
private handlePoint;
|
|
193
198
|
private ensureStyle;
|
|
@@ -207,4 +212,4 @@ declare class GuidyBridge {
|
|
|
207
212
|
*/
|
|
208
213
|
declare function detectAuthMode(allowedOrigins?: string[], allowedPattern?: RegExp): AuthMode;
|
|
209
214
|
|
|
210
|
-
export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandHandler, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, HostNavigationHandler, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
|
215
|
+
export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandHandler, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, GuidyRoute, GuidyRoutesMessage, HostNavigationHandler, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
package/dist/core-index.js
CHANGED
|
@@ -448,6 +448,7 @@ function isVisible(node) {
|
|
|
448
448
|
}
|
|
449
449
|
var GuidyBridge = class {
|
|
450
450
|
send;
|
|
451
|
+
routes;
|
|
451
452
|
started = false;
|
|
452
453
|
observer = null;
|
|
453
454
|
scanTimer = null;
|
|
@@ -455,8 +456,14 @@ var GuidyBridge = class {
|
|
|
455
456
|
highlightTimer = null;
|
|
456
457
|
clickTimer = null;
|
|
457
458
|
annotationTimer = null;
|
|
458
|
-
constructor(send) {
|
|
459
|
+
constructor(send, routes = []) {
|
|
459
460
|
this.send = send;
|
|
461
|
+
this.routes = routes;
|
|
462
|
+
}
|
|
463
|
+
/** Replace the declared navigable routes and re-post them to the host. */
|
|
464
|
+
setRoutes(routes) {
|
|
465
|
+
this.routes = routes;
|
|
466
|
+
this.postRoutes();
|
|
460
467
|
}
|
|
461
468
|
/**
|
|
462
469
|
* Begin reporting the element inventory and watching for changes.
|
|
@@ -467,6 +474,7 @@ var GuidyBridge = class {
|
|
|
467
474
|
this.started = true;
|
|
468
475
|
this.ensureStyle();
|
|
469
476
|
this.postElements();
|
|
477
|
+
this.postRoutes();
|
|
470
478
|
this.observer = new MutationObserver(() => this.scheduleScan());
|
|
471
479
|
this.observer.observe(document.body, {
|
|
472
480
|
childList: true,
|
|
@@ -506,6 +514,7 @@ var GuidyBridge = class {
|
|
|
506
514
|
handleCommand(message) {
|
|
507
515
|
if (message.type === "guidy:scan") {
|
|
508
516
|
this.postElements();
|
|
517
|
+
this.postRoutes();
|
|
509
518
|
return;
|
|
510
519
|
}
|
|
511
520
|
if (message.type === "guidy:point") {
|
|
@@ -542,6 +551,10 @@ var GuidyBridge = class {
|
|
|
542
551
|
elements: this.collectElements()
|
|
543
552
|
});
|
|
544
553
|
}
|
|
554
|
+
postRoutes() {
|
|
555
|
+
if (!this.started) return;
|
|
556
|
+
this.send({ type: "guidy:routes", routes: this.routes });
|
|
557
|
+
}
|
|
545
558
|
scheduleScan() {
|
|
546
559
|
if (this.scanTimer) return;
|
|
547
560
|
this.scanTimer = setTimeout(() => {
|
|
@@ -991,11 +1004,22 @@ var AuthManager = class {
|
|
|
991
1004
|
*/
|
|
992
1005
|
startGuidyBridge() {
|
|
993
1006
|
if (!this.iframeAuth || this.guidyBridge) return;
|
|
994
|
-
const bridge = new GuidyBridge(
|
|
1007
|
+
const bridge = new GuidyBridge(
|
|
1008
|
+
(message) => this.iframeAuth?.sendToHost(message),
|
|
1009
|
+
this.config.guidyRoutes ?? []
|
|
1010
|
+
);
|
|
995
1011
|
this.iframeAuth.onGuidyCommand((message) => bridge.handleCommand(message));
|
|
996
1012
|
bridge.start();
|
|
997
1013
|
this.guidyBridge = bridge;
|
|
998
1014
|
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Iframe mode: replace the routes the Guidy bridge advertises to the host.
|
|
1017
|
+
* No-op unless the bridge is running (`enableGuidyBridge`).
|
|
1018
|
+
*/
|
|
1019
|
+
setGuidyRoutes(routes) {
|
|
1020
|
+
this.config.guidyRoutes = routes;
|
|
1021
|
+
this.guidyBridge?.setRoutes(routes);
|
|
1022
|
+
}
|
|
999
1023
|
/**
|
|
1000
1024
|
* Iframe/WebView mode: start auto-syncing the embedded app's route
|
|
1001
1025
|
* to the host. Patches history methods and listens for popstate /
|