@docyrus/signin 0.14.1 → 0.15.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 +57 -0
- package/dist/{constants-DDOgvbL5.d.ts → constants-BoAqIz2O.d.ts} +7 -1
- package/dist/core-index.d.ts +11 -4
- package/dist/core-index.js +21 -0
- package/dist/core-index.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -4
- package/dist/react-native/index.js +28 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/{types-D4ZAVj-B.d.ts → types-DzwC4Dk7.d.ts} +32 -2
- package/dist/{use-docyrus-client-o9nPwayd.d.ts → use-docyrus-client-pU5z5ZHe.d.ts} +1 -1
- package/dist/vue/index.d.ts +3 -2
- package/dist/vue/index.js +26 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -350,6 +350,7 @@ const {
|
|
|
350
350
|
onHostNotification, // (handler) => () => void — subscribe to host notification messages (iframe mode)
|
|
351
351
|
enableHostRouteSync, // () => void — patch history + fire `route-change` on every change (iframe mode)
|
|
352
352
|
notifyRouteChange, // (payload?) => void — post a single `route-change` to the host (iframe mode)
|
|
353
|
+
requestHostNavigation, // (url, options?) => void — ask the host shell to navigate (iframe mode)
|
|
353
354
|
error // Error | null
|
|
354
355
|
} = useDocyrusAuth();
|
|
355
356
|
```
|
|
@@ -626,6 +627,62 @@ function RouteReporter() {
|
|
|
626
627
|
|
|
627
628
|
All three are no-ops outside iframe/WebView mode.
|
|
628
629
|
|
|
630
|
+
#### App → Host navigation request
|
|
631
|
+
|
|
632
|
+
The host can ask the app to navigate (`{ type: 'navigation' }`, above). The
|
|
633
|
+
reverse direction lets the embedded app ask the **host shell** to navigate —
|
|
634
|
+
for example, a button inside the app that should deep-link the host, switch the
|
|
635
|
+
host view, or open a sibling app. The app posts:
|
|
636
|
+
|
|
637
|
+
```
|
|
638
|
+
App → Host: { type: 'navigation-request', url, replace?, newTab? }
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
The host decides how to honour the request (push/replace its own router, open a
|
|
642
|
+
new tab, etc.). Unlike `route-change` — which passively reports where the app
|
|
643
|
+
already is — this is an explicit request to move the host.
|
|
644
|
+
|
|
645
|
+
**React** — call `requestHostNavigation` from `useDocyrusAuth()`, or use the
|
|
646
|
+
`useDocyrusRequestHostNavigation` convenience hook:
|
|
647
|
+
|
|
648
|
+
```tsx
|
|
649
|
+
import { useDocyrusRequestHostNavigation } from '@docyrus/signin';
|
|
650
|
+
|
|
651
|
+
function OpenSettingsButton() {
|
|
652
|
+
const requestHostNavigation = useDocyrusRequestHostNavigation();
|
|
653
|
+
|
|
654
|
+
return (
|
|
655
|
+
<button onClick={() => requestHostNavigation('/settings/billing')}>
|
|
656
|
+
Go to billing
|
|
657
|
+
</button>
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
```tsx
|
|
663
|
+
// With options
|
|
664
|
+
const { requestHostNavigation } = useDocyrusAuth();
|
|
665
|
+
|
|
666
|
+
requestHostNavigation('/reports/q3', { replace: true });
|
|
667
|
+
requestHostNavigation('https://docs.docyrus.com', { newTab: true });
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
**Vue** — call `requestHostNavigation` from the composable:
|
|
671
|
+
|
|
672
|
+
```vue
|
|
673
|
+
<script setup lang="ts">
|
|
674
|
+
import { getDocyrusAuth } from '@docyrus/signin/vue';
|
|
675
|
+
|
|
676
|
+
const auth = getDocyrusAuth();
|
|
677
|
+
|
|
678
|
+
function goToBilling() {
|
|
679
|
+
auth.requestHostNavigation('/settings/billing');
|
|
680
|
+
}
|
|
681
|
+
</script>
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
No-op outside iframe/WebView mode.
|
|
685
|
+
|
|
629
686
|
## SSR Support (Next.js)
|
|
630
687
|
|
|
631
688
|
Enable `ssr` on the client-side provider to sync the access token to a cookie. The cookie is written with `max-age` (matching the token lifetime) and `Secure` flag (on HTTPS origins) automatically.
|
|
@@ -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, G as GuidyRoute, 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, i as HostNavigationRequestOptions, H as HostNavigationHandler, h as HostNotificationHandler, f as DocyrusRole, P as PermissionConfig } from './types-DzwC4Dk7.js';
|
|
3
3
|
|
|
4
4
|
type AuthStateListener = (state: {
|
|
5
5
|
status: AuthStatus;
|
|
@@ -82,6 +82,12 @@ declare class AuthManager {
|
|
|
82
82
|
* iframe mode.
|
|
83
83
|
*/
|
|
84
84
|
notifyHostRouteChange(payload?: RouteChangePayload): void;
|
|
85
|
+
/**
|
|
86
|
+
* Iframe/WebView mode: ask the host shell to navigate to a path/URL.
|
|
87
|
+
* Posts a `navigation-request` message; the host decides how to honour it.
|
|
88
|
+
* No-op outside iframe mode.
|
|
89
|
+
*/
|
|
90
|
+
requestHostNavigation(url: string, options?: HostNavigationRequestOptions): void;
|
|
85
91
|
/**
|
|
86
92
|
* Subscribe to host `navigation` messages. Returns an unsubscribe function.
|
|
87
93
|
* Handlers registered before iframe mode is initialized are retained and
|
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-BoAqIz2O.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,
|
|
3
|
+
import { D as DocyrusAuthConfig, R as RouteChangePayload, i as HostNavigationRequestOptions, H as HostNavigationHandler, h as HostNotificationHandler, m as GuidyCommandHandler, x as AppToHostMessage, p as GuidyElementsMessage, s as GuidyRoutesMessage, q as GuidyPointAckMessage, G as GuidyRoute, n as GuidyCommandMessage, a as AuthMode } from './types-DzwC4Dk7.js';
|
|
4
|
+
export { A as AclOperation, j as AppNavigationRequestMessage, k as AppRouteChangeMessage, c as AuthStatus, d as DocyrusAclRule, e as DocyrusAuthContextValue, l as DocyrusNotification, f as DocyrusRole, g as DocyrusUser, o as GuidyElement, r as GuidyPointMessage, t as GuidyScanMessage, u as HostNavigationMessage, v as HostNotificationMessage, w as HostSignInMessage, P as PermissionConfig, T as TokenRefreshRequestMessage } from './types-DzwC4Dk7.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Standalone OAuth2 authorization code flow with PKCE via page redirect.
|
|
@@ -68,6 +68,7 @@ type IframeAuthCallback = (tokens: OAuth2Tokens) => void;
|
|
|
68
68
|
* - Host → App: { type: "navigation", url }
|
|
69
69
|
* - Host → App: { type: "notification", notification }
|
|
70
70
|
* - App → Host: { type: "route-change", path, search, hash, url }
|
|
71
|
+
* - App → Host: { type: "navigation-request", url, replace?, newTab? }
|
|
71
72
|
*
|
|
72
73
|
* Every incoming message's event.origin is validated against
|
|
73
74
|
* the allowed host pattern before processing.
|
|
@@ -108,6 +109,12 @@ declare class IframeAuth {
|
|
|
108
109
|
* report a known route instead.
|
|
109
110
|
*/
|
|
110
111
|
notifyRouteChange(payload?: RouteChangePayload): void;
|
|
112
|
+
/**
|
|
113
|
+
* Ask the host shell to navigate to a path/URL. The reverse of the
|
|
114
|
+
* host → app `navigation` message: posts a `navigation-request` over the
|
|
115
|
+
* same validated channel. The host decides how to honour it.
|
|
116
|
+
*/
|
|
117
|
+
requestHostNavigation(url: string, options?: HostNavigationRequestOptions): void;
|
|
111
118
|
private teardownRouteSync;
|
|
112
119
|
/**
|
|
113
120
|
* Subscribe to host navigation messages.
|
|
@@ -212,4 +219,4 @@ declare class GuidyBridge {
|
|
|
212
219
|
*/
|
|
213
220
|
declare function detectAuthMode(allowedOrigins?: string[], allowedPattern?: RegExp): AuthMode;
|
|
214
221
|
|
|
215
|
-
export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandHandler, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, GuidyRoute, GuidyRoutesMessage, HostNavigationHandler, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
|
222
|
+
export { AuthMode, DocyrusAuthConfig, GuidyBridge, GuidyCommandHandler, GuidyCommandMessage, GuidyElementsMessage, GuidyPointAckMessage, GuidyRoute, GuidyRoutesMessage, HostNavigationHandler, HostNavigationRequestOptions, HostNotificationHandler, IframeAuth, RouteChangePayload, StandaloneOAuth2Auth, detectAuthMode };
|
package/dist/core-index.js
CHANGED
|
@@ -270,6 +270,19 @@ var IframeAuth = class {
|
|
|
270
270
|
url: `${path}${search}${hash}`
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Ask the host shell to navigate to a path/URL. The reverse of the
|
|
275
|
+
* host → app `navigation` message: posts a `navigation-request` over the
|
|
276
|
+
* same validated channel. The host decides how to honour it.
|
|
277
|
+
*/
|
|
278
|
+
requestHostNavigation(url, options) {
|
|
279
|
+
if (this.stopped) return;
|
|
280
|
+
if (typeof url !== "string" || url.length === 0) return;
|
|
281
|
+
const message = { type: "navigation-request", url };
|
|
282
|
+
if (options?.replace) message.replace = true;
|
|
283
|
+
if (options?.newTab) message.newTab = true;
|
|
284
|
+
this.sendToHost(message);
|
|
285
|
+
}
|
|
273
286
|
teardownRouteSync() {
|
|
274
287
|
if (!this.routeSyncEnabled) return;
|
|
275
288
|
if (typeof window !== "undefined") {
|
|
@@ -1054,6 +1067,14 @@ var AuthManager = class {
|
|
|
1054
1067
|
notifyHostRouteChange(payload) {
|
|
1055
1068
|
this.iframeAuth?.notifyRouteChange(payload);
|
|
1056
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Iframe/WebView mode: ask the host shell to navigate to a path/URL.
|
|
1072
|
+
* Posts a `navigation-request` message; the host decides how to honour it.
|
|
1073
|
+
* No-op outside iframe mode.
|
|
1074
|
+
*/
|
|
1075
|
+
requestHostNavigation(url, options) {
|
|
1076
|
+
this.iframeAuth?.requestHostNavigation(url, options);
|
|
1077
|
+
}
|
|
1057
1078
|
/**
|
|
1058
1079
|
* Subscribe to host `navigation` messages. Returns an unsubscribe function.
|
|
1059
1080
|
* Handlers registered before iframe mode is initialized are retained and
|