@every-app/sdk 0.1.14 → 0.3.0-rc.1
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 +608 -2
- package/dist/cloudflare/index.d.ts +21 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +21 -1
- package/dist/cloudflare/sentinel.d.ts +69 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -0
- package/dist/cloudflare/sentinel.js +50 -0
- package/dist/cloudflare/worker.d.ts +511 -0
- package/dist/cloudflare/worker.d.ts.map +1 -0
- package/dist/cloudflare/worker.js +738 -0
- package/dist/dev/index.d.ts +8 -0
- package/dist/dev/index.d.ts.map +1 -0
- package/dist/dev/index.js +7 -0
- package/dist/dev/keypair.d.ts +24 -0
- package/dist/dev/keypair.d.ts.map +1 -0
- package/dist/dev/keypair.js +60 -0
- package/dist/internal/aiProviders.d.ts +67 -0
- package/dist/internal/aiProviders.d.ts.map +1 -0
- package/dist/internal/aiProviders.js +220 -0
- package/dist/internal/appSettings.d.ts +237 -0
- package/dist/internal/appSettings.d.ts.map +1 -0
- package/dist/internal/appSettings.js +374 -0
- package/dist/internal/capabilities.d.ts +1344 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +1521 -0
- package/dist/internal/devProviders.d.ts +49 -0
- package/dist/internal/devProviders.d.ts.map +1 -0
- package/dist/internal/devProviders.js +62 -0
- package/dist/internal/email.d.ts +280 -0
- package/dist/internal/email.d.ts.map +1 -0
- package/dist/internal/email.js +613 -0
- package/dist/internal/events.d.ts +182 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +324 -0
- package/dist/internal/gatewaySettings.d.ts +82 -0
- package/dist/internal/gatewaySettings.d.ts.map +1 -0
- package/dist/internal/gatewaySettings.js +209 -0
- package/dist/internal/identity.d.ts +88 -0
- package/dist/internal/identity.d.ts.map +1 -0
- package/dist/internal/identity.js +231 -0
- package/dist/internal/index.d.ts +19 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +18 -0
- package/dist/internal/members.d.ts +35 -0
- package/dist/internal/members.d.ts.map +1 -0
- package/dist/internal/members.js +7 -0
- package/dist/internal/oauthClient.d.ts +63 -0
- package/dist/internal/oauthClient.d.ts.map +1 -0
- package/dist/internal/oauthClient.js +194 -0
- package/dist/internal/oauthScopes.d.ts +117 -0
- package/dist/internal/oauthScopes.d.ts.map +1 -0
- package/dist/internal/oauthScopes.js +416 -0
- package/dist/internal/organizationName.d.ts +18 -0
- package/dist/internal/organizationName.d.ts.map +1 -0
- package/dist/internal/organizationName.js +24 -0
- package/dist/internal/protocol.d.ts +195 -0
- package/dist/internal/protocol.d.ts.map +1 -0
- package/dist/internal/protocol.js +250 -0
- package/dist/internal/providerApps.d.ts +75 -0
- package/dist/internal/providerApps.d.ts.map +1 -0
- package/dist/internal/providerApps.js +59 -0
- package/dist/internal/providerRegistry.d.ts +147 -0
- package/dist/internal/providerRegistry.d.ts.map +1 -0
- package/dist/internal/providerRegistry.js +262 -0
- package/dist/internal/providerSpec.d.ts +55 -0
- package/dist/internal/providerSpec.d.ts.map +1 -0
- package/dist/internal/providerSpec.js +746 -0
- package/dist/internal/remoteMcp.d.ts +188 -0
- package/dist/internal/remoteMcp.d.ts.map +1 -0
- package/dist/internal/remoteMcp.js +543 -0
- package/dist/internal/tools.d.ts +115 -0
- package/dist/internal/tools.d.ts.map +1 -0
- package/dist/internal/tools.js +80 -0
- package/dist/server/attribution.d.ts +39 -0
- package/dist/server/attribution.d.ts.map +1 -0
- package/dist/server/attribution.js +67 -0
- package/dist/server/authorizeUrl.d.ts +43 -0
- package/dist/server/authorizeUrl.d.ts.map +1 -0
- package/dist/server/authorizeUrl.js +110 -0
- package/dist/server/emit.d.ts +63 -0
- package/dist/server/emit.d.ts.map +1 -0
- package/dist/server/emit.js +101 -0
- package/dist/server/everyApp.d.ts +81 -0
- package/dist/server/everyApp.d.ts.map +1 -0
- package/dist/server/everyApp.js +185 -0
- package/dist/server/gatewayFetch.d.ts +37 -0
- package/dist/server/gatewayFetch.d.ts.map +1 -0
- package/dist/server/gatewayFetch.js +115 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +15 -0
- package/dist/server/integrationFetch.d.ts +131 -0
- package/dist/server/integrationFetch.d.ts.map +1 -0
- package/dist/server/integrationFetch.js +526 -0
- package/dist/server/listMembers.d.ts +32 -0
- package/dist/server/listMembers.d.ts.map +1 -0
- package/dist/server/listMembers.js +74 -0
- package/dist/server/nodeServer.d.ts +48 -0
- package/dist/server/nodeServer.d.ts.map +1 -0
- package/dist/server/nodeServer.js +45 -0
- package/dist/server/sendEmail.d.ts +39 -0
- package/dist/server/sendEmail.d.ts.map +1 -0
- package/dist/server/sendEmail.js +114 -0
- package/dist/server/tools.d.ts +184 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/server/tools.js +347 -0
- package/dist/server/toolsEndpoint.d.ts +32 -0
- package/dist/server/toolsEndpoint.d.ts.map +1 -0
- package/dist/server/toolsEndpoint.js +231 -0
- package/package.json +21 -31
- package/dist/cloudflare/getLocalD1Url.d.ts +0 -2
- package/dist/cloudflare/getLocalD1Url.d.ts.map +0 -1
- package/dist/cloudflare/getLocalD1Url.js +0 -40
- package/dist/cloudflare/lazyInit.d.ts +0 -22
- package/dist/cloudflare/lazyInit.d.ts.map +0 -1
- package/dist/cloudflare/lazyInit.js +0 -65
- package/dist/cloudflare/server/gateway.d.ts +0 -29
- package/dist/cloudflare/server/gateway.d.ts.map +0 -1
- package/dist/cloudflare/server/gateway.js +0 -69
- package/dist/cloudflare/server/index.d.ts +0 -3
- package/dist/cloudflare/server/index.d.ts.map +0 -1
- package/dist/cloudflare/server/index.js +0 -2
- package/dist/core/authenticatedFetch.d.ts +0 -9
- package/dist/core/authenticatedFetch.d.ts.map +0 -1
- package/dist/core/authenticatedFetch.js +0 -31
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -2
- package/dist/core/sessionManager.d.ts +0 -58
- package/dist/core/sessionManager.d.ts.map +0 -1
- package/dist/core/sessionManager.js +0 -357
- package/dist/shared/bypassGatewayLocalOnly.d.ts +0 -15
- package/dist/shared/bypassGatewayLocalOnly.d.ts.map +0 -1
- package/dist/shared/bypassGatewayLocalOnly.js +0 -45
- package/dist/shared/parseMessagePayload.d.ts +0 -3
- package/dist/shared/parseMessagePayload.d.ts.map +0 -1
- package/dist/shared/parseMessagePayload.js +0 -18
- package/dist/tanstack/EmbeddedAppProvider.d.ts +0 -30
- package/dist/tanstack/EmbeddedAppProvider.d.ts.map +0 -1
- package/dist/tanstack/EmbeddedAppProvider.js +0 -57
- package/dist/tanstack/GatewayRequiredError.d.ts +0 -20
- package/dist/tanstack/GatewayRequiredError.d.ts.map +0 -1
- package/dist/tanstack/GatewayRequiredError.js +0 -91
- package/dist/tanstack/_internal/useEveryAppSession.d.ts +0 -18
- package/dist/tanstack/_internal/useEveryAppSession.d.ts.map +0 -1
- package/dist/tanstack/_internal/useEveryAppSession.js +0 -47
- package/dist/tanstack/index.d.ts +0 -4
- package/dist/tanstack/index.d.ts.map +0 -1
- package/dist/tanstack/index.js +0 -3
- package/dist/tanstack/server/authConfig.d.ts +0 -3
- package/dist/tanstack/server/authConfig.d.ts.map +0 -1
- package/dist/tanstack/server/authConfig.js +0 -13
- package/dist/tanstack/server/authenticateRequest.d.ts +0 -31
- package/dist/tanstack/server/authenticateRequest.d.ts.map +0 -1
- package/dist/tanstack/server/authenticateRequest.js +0 -154
- package/dist/tanstack/server/index.d.ts +0 -4
- package/dist/tanstack/server/index.d.ts.map +0 -1
- package/dist/tanstack/server/index.js +0 -2
- package/dist/tanstack/server/types.d.ts +0 -5
- package/dist/tanstack/server/types.d.ts.map +0 -1
- package/dist/tanstack/server/types.js +0 -1
- package/dist/tanstack/useEveryAppRouter.d.ts +0 -7
- package/dist/tanstack/useEveryAppRouter.d.ts.map +0 -1
- package/dist/tanstack/useEveryAppRouter.js +0 -66
- package/dist/tanstack/useSessionTokenClientMiddleware.d.ts +0 -2
- package/dist/tanstack/useSessionTokenClientMiddleware.d.ts.map +0 -1
- package/dist/tanstack/useSessionTokenClientMiddleware.js +0 -29
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { BYPASS_GATEWAY_LOCAL_ONLY_EMAIL, BYPASS_GATEWAY_LOCAL_ONLY_TOKEN, BYPASS_GATEWAY_LOCAL_ONLY_USER_ID, isBypassGatewayLocalOnlyClient, } from "../shared/bypassGatewayLocalOnly.js";
|
|
2
|
-
import { parseMessagePayload } from "../shared/parseMessagePayload.js";
|
|
3
|
-
function isTokenUpdateMessage(data) {
|
|
4
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
return data.type === "SESSION_TOKEN_UPDATE";
|
|
8
|
-
}
|
|
9
|
-
function decodeJwtPayload(token) {
|
|
10
|
-
try {
|
|
11
|
-
const parts = token.split(".");
|
|
12
|
-
if (parts.length !== 3) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
16
|
-
const padded = base64 + "=".repeat((4 - (base64.length % 4)) % 4);
|
|
17
|
-
return JSON.parse(atob(padded));
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function tokenAudienceMatchesApp(payload, appId) {
|
|
24
|
-
const aud = payload.aud;
|
|
25
|
-
if (typeof aud === "string") {
|
|
26
|
-
return aud === appId;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(aud)) {
|
|
29
|
-
return aud.some((value) => value === appId);
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
const MESSAGE_TIMEOUT_MS = 5000;
|
|
34
|
-
const TOKEN_EXPIRY_BUFFER_MS = 10000;
|
|
35
|
-
const DEFAULT_TOKEN_LIFETIME_MS = 60000;
|
|
36
|
-
const REACT_NATIVE_TOKEN_WAIT_TIMEOUT_MS = 10000;
|
|
37
|
-
/**
|
|
38
|
-
* Detects whether the current window is running inside an iframe.
|
|
39
|
-
* Returns true if in an iframe, false if running as top-level window.
|
|
40
|
-
*/
|
|
41
|
-
export function isRunningInIframe() {
|
|
42
|
-
if (typeof window === "undefined") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return window.self !== window.top;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// If we can't access window.top due to cross-origin restrictions,
|
|
50
|
-
// we're definitely in an iframe
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Detects whether the current window is running inside a React Native WebView.
|
|
56
|
-
* Returns true if window.ReactNativeWebView is available.
|
|
57
|
-
*/
|
|
58
|
-
export function isRunningInReactNativeWebView() {
|
|
59
|
-
if (typeof window === "undefined") {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
return (typeof window.ReactNativeWebView?.postMessage === "function" ||
|
|
63
|
-
window.isReactNativeWebView === true);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Detects the current embedded environment.
|
|
67
|
-
* Priority: React Native WebView > iframe > standalone
|
|
68
|
-
*/
|
|
69
|
-
export function detectEnvironment() {
|
|
70
|
-
const isRNWebView = isRunningInReactNativeWebView();
|
|
71
|
-
const isIframe = isRunningInIframe();
|
|
72
|
-
if (isRNWebView) {
|
|
73
|
-
return "react-native-webview";
|
|
74
|
-
}
|
|
75
|
-
if (isIframe) {
|
|
76
|
-
return "iframe";
|
|
77
|
-
}
|
|
78
|
-
return "standalone";
|
|
79
|
-
}
|
|
80
|
-
export class SessionManager {
|
|
81
|
-
parentOrigin;
|
|
82
|
-
appId;
|
|
83
|
-
isInIframe;
|
|
84
|
-
environment;
|
|
85
|
-
isBypassGatewayLocalOnly;
|
|
86
|
-
token = null;
|
|
87
|
-
refreshPromise = null;
|
|
88
|
-
tokenWaiters = [];
|
|
89
|
-
constructor(config) {
|
|
90
|
-
if (!config.appId) {
|
|
91
|
-
throw new Error("[SessionManager] appId is required.");
|
|
92
|
-
}
|
|
93
|
-
this.isBypassGatewayLocalOnly = isBypassGatewayLocalOnlyClient();
|
|
94
|
-
const gatewayUrl = import.meta.env.VITE_GATEWAY_URL;
|
|
95
|
-
if (!this.isBypassGatewayLocalOnly) {
|
|
96
|
-
if (!gatewayUrl) {
|
|
97
|
-
throw new Error("[SessionManager] VITE_GATEWAY_URL env var is required.");
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
new URL(gatewayUrl);
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
throw new Error(`[SessionManager] Invalid gateway URL: ${gatewayUrl}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
this.appId = config.appId;
|
|
107
|
-
this.parentOrigin = this.isBypassGatewayLocalOnly
|
|
108
|
-
? window.location.origin
|
|
109
|
-
: gatewayUrl;
|
|
110
|
-
this.environment = detectEnvironment();
|
|
111
|
-
this.isInIframe = isRunningInIframe();
|
|
112
|
-
if (this.environment === "react-native-webview") {
|
|
113
|
-
this.setupReactNativeTokenListener();
|
|
114
|
-
}
|
|
115
|
-
if (this.isBypassGatewayLocalOnly) {
|
|
116
|
-
this.token = {
|
|
117
|
-
token: BYPASS_GATEWAY_LOCAL_ONLY_TOKEN,
|
|
118
|
-
expiresAt: Date.now() + DEFAULT_TOKEN_LIFETIME_MS,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Check if running in an embedded environment (iframe or React Native WebView)
|
|
124
|
-
*/
|
|
125
|
-
isEmbedded() {
|
|
126
|
-
return this.environment !== "standalone";
|
|
127
|
-
}
|
|
128
|
-
isTrustedHostMessage(event) {
|
|
129
|
-
if (this.environment === "react-native-webview") {
|
|
130
|
-
const origin = event
|
|
131
|
-
.origin;
|
|
132
|
-
return (origin === "react-native" ||
|
|
133
|
-
origin === "null" ||
|
|
134
|
-
origin === "" ||
|
|
135
|
-
origin == null);
|
|
136
|
-
}
|
|
137
|
-
return event.origin === this.parentOrigin;
|
|
138
|
-
}
|
|
139
|
-
postToHost(message) {
|
|
140
|
-
if (this.environment === "react-native-webview") {
|
|
141
|
-
const postMessage = window.ReactNativeWebView?.postMessage;
|
|
142
|
-
if (typeof postMessage !== "function") {
|
|
143
|
-
throw new Error("React Native WebView bridge is unavailable");
|
|
144
|
-
}
|
|
145
|
-
postMessage.call(window.ReactNativeWebView, JSON.stringify(message));
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
window.parent.postMessage(message, this.parentOrigin);
|
|
149
|
-
}
|
|
150
|
-
isTokenExpiringSoon(bufferMs = TOKEN_EXPIRY_BUFFER_MS) {
|
|
151
|
-
if (!this.token)
|
|
152
|
-
return true;
|
|
153
|
-
return Date.now() >= this.token.expiresAt - bufferMs;
|
|
154
|
-
}
|
|
155
|
-
postMessageWithResponse(request, responseType, requestId) {
|
|
156
|
-
return new Promise((resolve, reject) => {
|
|
157
|
-
const cleanup = () => {
|
|
158
|
-
clearTimeout(timeout);
|
|
159
|
-
window.removeEventListener("message", handler);
|
|
160
|
-
};
|
|
161
|
-
const handler = (event) => {
|
|
162
|
-
// Security: validate message origin based on environment
|
|
163
|
-
if (!this.isTrustedHostMessage(event))
|
|
164
|
-
return;
|
|
165
|
-
const data = parseMessagePayload(event.data);
|
|
166
|
-
if (!data)
|
|
167
|
-
return;
|
|
168
|
-
if (data.type === responseType && data.requestId === requestId) {
|
|
169
|
-
cleanup();
|
|
170
|
-
if (typeof data.error === "string" && data.error) {
|
|
171
|
-
reject(new Error(data.error));
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
resolve(data);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const timeout = setTimeout(() => {
|
|
179
|
-
cleanup();
|
|
180
|
-
reject(new Error("Token request timeout - parent did not respond"));
|
|
181
|
-
}, MESSAGE_TIMEOUT_MS);
|
|
182
|
-
window.addEventListener("message", handler);
|
|
183
|
-
try {
|
|
184
|
-
this.postToHost(request);
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
cleanup();
|
|
188
|
-
reject(error instanceof Error
|
|
189
|
-
? error
|
|
190
|
-
: new Error("Failed to post message to host"));
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
setupReactNativeTokenListener() {
|
|
195
|
-
window.addEventListener("message", (event) => {
|
|
196
|
-
if (!this.isTrustedHostMessage(event)) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const data = parseMessagePayload(event.data);
|
|
200
|
-
if (!data) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (!isTokenUpdateMessage(data)) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const message = data;
|
|
207
|
-
if (!message.token || typeof message.token !== "string") {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (typeof message.appId !== "string" || message.appId !== this.appId) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (message.expiresAt !== undefined &&
|
|
214
|
-
typeof message.expiresAt !== "string") {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const payload = decodeJwtPayload(message.token);
|
|
218
|
-
if (!payload || !tokenAudienceMatchesApp(payload, this.appId)) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
// Native controls token minting and pushes updates into the embedded app.
|
|
222
|
-
// We only consume pushed tokens in React Native WebView mode.
|
|
223
|
-
let expiresAt = Date.now() + DEFAULT_TOKEN_LIFETIME_MS;
|
|
224
|
-
if (message.expiresAt) {
|
|
225
|
-
const parsed = new Date(message.expiresAt).getTime();
|
|
226
|
-
if (!Number.isNaN(parsed)) {
|
|
227
|
-
expiresAt = parsed;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
this.token = {
|
|
231
|
-
token: message.token,
|
|
232
|
-
expiresAt,
|
|
233
|
-
};
|
|
234
|
-
if (this.tokenWaiters.length > 0) {
|
|
235
|
-
const waiters = this.tokenWaiters;
|
|
236
|
-
this.tokenWaiters = [];
|
|
237
|
-
for (const waiter of waiters) {
|
|
238
|
-
clearTimeout(waiter.timeout);
|
|
239
|
-
waiter.resolve(message.token);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
waitForReactNativeTokenPush() {
|
|
245
|
-
if (this.token && !this.isTokenExpiringSoon()) {
|
|
246
|
-
return Promise.resolve(this.token.token);
|
|
247
|
-
}
|
|
248
|
-
return new Promise((resolve, reject) => {
|
|
249
|
-
const timeout = setTimeout(() => {
|
|
250
|
-
this.tokenWaiters = this.tokenWaiters.filter((w) => w.timeout !== timeout);
|
|
251
|
-
reject(new Error("Timed out waiting for token from React Native bridge"));
|
|
252
|
-
}, REACT_NATIVE_TOKEN_WAIT_TIMEOUT_MS);
|
|
253
|
-
this.tokenWaiters.push({ resolve, reject, timeout });
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
async requestNewToken() {
|
|
257
|
-
if (this.isBypassGatewayLocalOnly) {
|
|
258
|
-
this.token = {
|
|
259
|
-
token: BYPASS_GATEWAY_LOCAL_ONLY_TOKEN,
|
|
260
|
-
expiresAt: Date.now() + DEFAULT_TOKEN_LIFETIME_MS,
|
|
261
|
-
};
|
|
262
|
-
return this.token.token;
|
|
263
|
-
}
|
|
264
|
-
if (this.refreshPromise) {
|
|
265
|
-
return this.refreshPromise;
|
|
266
|
-
}
|
|
267
|
-
if (this.environment === "react-native-webview") {
|
|
268
|
-
this.refreshPromise = this.waitForReactNativeTokenPush();
|
|
269
|
-
try {
|
|
270
|
-
return await this.refreshPromise;
|
|
271
|
-
}
|
|
272
|
-
finally {
|
|
273
|
-
this.refreshPromise = null;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
this.refreshPromise = (async () => {
|
|
277
|
-
const requestId = crypto.randomUUID();
|
|
278
|
-
const response = await this.postMessageWithResponse({
|
|
279
|
-
type: "SESSION_TOKEN_REQUEST",
|
|
280
|
-
requestId,
|
|
281
|
-
appId: this.appId,
|
|
282
|
-
}, "SESSION_TOKEN_RESPONSE", requestId);
|
|
283
|
-
if (!response.token) {
|
|
284
|
-
throw new Error("No token in response");
|
|
285
|
-
}
|
|
286
|
-
// Parse expiresAt, falling back to default lifetime if invalid
|
|
287
|
-
let expiresAt = Date.now() + DEFAULT_TOKEN_LIFETIME_MS;
|
|
288
|
-
if (response.expiresAt) {
|
|
289
|
-
const parsed = new Date(response.expiresAt).getTime();
|
|
290
|
-
if (!Number.isNaN(parsed)) {
|
|
291
|
-
expiresAt = parsed;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
this.token = {
|
|
295
|
-
token: response.token,
|
|
296
|
-
expiresAt,
|
|
297
|
-
};
|
|
298
|
-
return this.token.token;
|
|
299
|
-
})();
|
|
300
|
-
try {
|
|
301
|
-
return await this.refreshPromise;
|
|
302
|
-
}
|
|
303
|
-
finally {
|
|
304
|
-
this.refreshPromise = null;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
async getToken() {
|
|
308
|
-
if (this.isBypassGatewayLocalOnly) {
|
|
309
|
-
if (!this.token || this.isTokenExpiringSoon()) {
|
|
310
|
-
return this.requestNewToken();
|
|
311
|
-
}
|
|
312
|
-
return this.token.token;
|
|
313
|
-
}
|
|
314
|
-
if (this.isTokenExpiringSoon()) {
|
|
315
|
-
return this.requestNewToken();
|
|
316
|
-
}
|
|
317
|
-
return this.token.token;
|
|
318
|
-
}
|
|
319
|
-
getTokenState() {
|
|
320
|
-
if (this.refreshPromise) {
|
|
321
|
-
return { status: "REFRESHING", token: null };
|
|
322
|
-
}
|
|
323
|
-
if (!this.token) {
|
|
324
|
-
return { status: "NO_TOKEN", token: null };
|
|
325
|
-
}
|
|
326
|
-
if (this.isTokenExpiringSoon(0)) {
|
|
327
|
-
return { status: "EXPIRED", token: this.token.token };
|
|
328
|
-
}
|
|
329
|
-
return { status: "VALID", token: this.token.token };
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Extracts user information from the current JWT token.
|
|
333
|
-
* Returns null if no valid token is available.
|
|
334
|
-
*/
|
|
335
|
-
getUser() {
|
|
336
|
-
if (this.isBypassGatewayLocalOnly) {
|
|
337
|
-
return {
|
|
338
|
-
userId: BYPASS_GATEWAY_LOCAL_ONLY_USER_ID,
|
|
339
|
-
email: BYPASS_GATEWAY_LOCAL_ONLY_EMAIL,
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
if (!this.token) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
const payload = decodeJwtPayload(this.token.token);
|
|
346
|
-
if (!payload) {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
if (typeof payload.sub !== "string") {
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
return {
|
|
353
|
-
userId: payload.sub,
|
|
354
|
-
email: typeof payload.email === "string" ? payload.email : "",
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const BYPASS_GATEWAY_LOCAL_ONLY_TOKEN = "BYPASS_GATEWAY_LOCAL_ONLY";
|
|
2
|
-
export declare const BYPASS_GATEWAY_LOCAL_ONLY_USER_ID = "demo-local-user";
|
|
3
|
-
export declare const BYPASS_GATEWAY_LOCAL_ONLY_EMAIL = "demo-local-user@local";
|
|
4
|
-
export declare function isBypassGatewayLocalOnlyClient(): boolean;
|
|
5
|
-
export declare function isBypassGatewayLocalOnlyServer(): boolean;
|
|
6
|
-
export declare function createBypassGatewayLocalOnlySessionPayload(audience: string, orgId: string): {
|
|
7
|
-
orgId: string;
|
|
8
|
-
sub: string;
|
|
9
|
-
email: string;
|
|
10
|
-
iss: string;
|
|
11
|
-
aud: string;
|
|
12
|
-
iat: number;
|
|
13
|
-
exp: number;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=bypassGatewayLocalOnly.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bypassGatewayLocalOnly.d.ts","sourceRoot":"","sources":["../../src/shared/bypassGatewayLocalOnly.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,8BAA8B,CAAC;AAC3E,eAAO,MAAM,iCAAiC,oBAAoB,CAAC;AACnE,eAAO,MAAM,+BAA+B,0BAA0B,CAAC;AAEvE,wBAAgB,8BAA8B,IAAI,OAAO,CAYxD;AAED,wBAAgB,8BAA8B,IAAI,OAAO,CAsBxD;AAED,wBAAgB,0CAA0C,CACxD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM;;;;;;;;EAkBd"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const BYPASS_GATEWAY_LOCAL_ONLY_TOKEN = "BYPASS_GATEWAY_LOCAL_ONLY";
|
|
2
|
-
export const BYPASS_GATEWAY_LOCAL_ONLY_USER_ID = "demo-local-user";
|
|
3
|
-
export const BYPASS_GATEWAY_LOCAL_ONLY_EMAIL = "demo-local-user@local";
|
|
4
|
-
export function isBypassGatewayLocalOnlyClient() {
|
|
5
|
-
if (import.meta.env.PROD) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
const metaEnv = import.meta
|
|
9
|
-
.env;
|
|
10
|
-
return (metaEnv?.VITE_BYPASS_GATEWAY_LOCAL_ONLY === "true" ||
|
|
11
|
-
metaEnv?.BYPASS_GATEWAY_LOCAL_ONLY === "true");
|
|
12
|
-
}
|
|
13
|
-
export function isBypassGatewayLocalOnlyServer() {
|
|
14
|
-
if (import.meta.env.PROD) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
const metaEnv = import.meta
|
|
18
|
-
.env;
|
|
19
|
-
const metaValue = metaEnv?.BYPASS_GATEWAY_LOCAL_ONLY ??
|
|
20
|
-
metaEnv?.VITE_BYPASS_GATEWAY_LOCAL_ONLY;
|
|
21
|
-
if (metaValue === "true") {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
if (typeof process !== "undefined" &&
|
|
25
|
-
process.env?.BYPASS_GATEWAY_LOCAL_ONLY === "true") {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
export function createBypassGatewayLocalOnlySessionPayload(audience, orgId) {
|
|
31
|
-
const issuedAt = Math.floor(Date.now() / 1000);
|
|
32
|
-
const expiresAt = issuedAt + 60 * 60;
|
|
33
|
-
const payload = {
|
|
34
|
-
sub: BYPASS_GATEWAY_LOCAL_ONLY_USER_ID,
|
|
35
|
-
email: BYPASS_GATEWAY_LOCAL_ONLY_EMAIL,
|
|
36
|
-
iss: "local",
|
|
37
|
-
aud: audience,
|
|
38
|
-
iat: issuedAt,
|
|
39
|
-
exp: expiresAt,
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
...payload,
|
|
43
|
-
orgId,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseMessagePayload.d.ts","sourceRoot":"","sources":["../../src/shared/parseMessagePayload.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAmBxE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function parseMessagePayload(data) {
|
|
2
|
-
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
3
|
-
return data;
|
|
4
|
-
}
|
|
5
|
-
if (typeof data !== "string") {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const parsed = JSON.parse(data);
|
|
10
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
11
|
-
return parsed;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SessionManagerConfig } from "../core/sessionManager.js";
|
|
3
|
-
interface EmbeddedProviderConfig extends SessionManagerConfig {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare function EmbeddedAppProvider({ children, ...config }: EmbeddedProviderConfig): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
-
/**
|
|
8
|
-
* Hook to get the current authenticated user.
|
|
9
|
-
* Returns the user's ID and email extracted from the JWT token,
|
|
10
|
-
* or null if not authenticated.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* function MyComponent() {
|
|
15
|
-
* const user = useCurrentUser();
|
|
16
|
-
*
|
|
17
|
-
* if (!user) {
|
|
18
|
-
* return <div>Not authenticated</div>;
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* return <div>Welcome, {user.email}</div>;
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare function useCurrentUser(): {
|
|
26
|
-
userId: string;
|
|
27
|
-
email: string;
|
|
28
|
-
} | null;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=EmbeddedAppProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedAppProvider.d.ts","sourceRoot":"","sources":["../../src/tanstack/EmbeddedAppProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAEL,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAKnC,UAAU,sBAAuB,SAAQ,oBAAoB;IAC3D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAUD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,sBAAsB,kDAgCxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmBzE"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
import { useEveryAppSession } from "./_internal/useEveryAppSession.js";
|
|
4
|
-
import { useEveryAppRouter } from "./useEveryAppRouter.js";
|
|
5
|
-
import { GatewayRequiredError } from "./GatewayRequiredError.js";
|
|
6
|
-
const EmbeddedAppContext = createContext(null);
|
|
7
|
-
export function EmbeddedAppProvider({ children, ...config }) {
|
|
8
|
-
const { sessionManager, sessionTokenState } = useEveryAppSession({
|
|
9
|
-
sessionManagerConfig: config,
|
|
10
|
-
});
|
|
11
|
-
useEveryAppRouter({ sessionManager });
|
|
12
|
-
if (!sessionManager)
|
|
13
|
-
return null;
|
|
14
|
-
// Check if the app is running outside of the Gateway (iframe or React Native WebView)
|
|
15
|
-
if (!sessionManager.isEmbedded() &&
|
|
16
|
-
!sessionManager.isBypassGatewayLocalOnly) {
|
|
17
|
-
return (_jsx(GatewayRequiredError, { gatewayOrigin: sessionManager.parentOrigin, appId: config.appId }));
|
|
18
|
-
}
|
|
19
|
-
const value = {
|
|
20
|
-
sessionManager,
|
|
21
|
-
isAuthenticated: sessionTokenState.status === "VALID",
|
|
22
|
-
sessionTokenState,
|
|
23
|
-
};
|
|
24
|
-
return (_jsx(EmbeddedAppContext.Provider, { value: value, children: children }));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Hook to get the current authenticated user.
|
|
28
|
-
* Returns the user's ID and email extracted from the JWT token,
|
|
29
|
-
* or null if not authenticated.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* function MyComponent() {
|
|
34
|
-
* const user = useCurrentUser();
|
|
35
|
-
*
|
|
36
|
-
* if (!user) {
|
|
37
|
-
* return <div>Not authenticated</div>;
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* return <div>Welcome, {user.email}</div>;
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function useCurrentUser() {
|
|
45
|
-
const context = useContext(EmbeddedAppContext);
|
|
46
|
-
if (!context) {
|
|
47
|
-
throw new Error("useCurrentUser must be used within an EmbeddedAppProvider");
|
|
48
|
-
}
|
|
49
|
-
const { sessionManager, sessionTokenState } = context;
|
|
50
|
-
return useMemo(() => {
|
|
51
|
-
// Only return user if we have a valid token
|
|
52
|
-
if (sessionTokenState.status !== "VALID") {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return sessionManager.getUser();
|
|
56
|
-
}, [sessionManager, sessionTokenState]);
|
|
57
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface GatewayRequiredErrorProps {
|
|
2
|
-
/**
|
|
3
|
-
* The origin of the Gateway (e.g., "https://gateway.example.com").
|
|
4
|
-
*/
|
|
5
|
-
gatewayOrigin: string;
|
|
6
|
-
/**
|
|
7
|
-
* The app ID used in the Gateway URL path.
|
|
8
|
-
*/
|
|
9
|
-
appId: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Error component displayed when an embedded app is accessed directly
|
|
13
|
-
* instead of through the Every App Gateway.
|
|
14
|
-
*
|
|
15
|
-
* This component informs users that authentication requires accessing
|
|
16
|
-
* the app through the Gateway and provides a link to do so.
|
|
17
|
-
*/
|
|
18
|
-
export declare function GatewayRequiredError({ gatewayOrigin, appId, }: GatewayRequiredErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=GatewayRequiredError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayRequiredError.d.ts","sourceRoot":"","sources":["../../src/tanstack/GatewayRequiredError.tsx"],"names":[],"mappings":"AAEA,UAAU,yBAAyB;IACjC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAmFD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,aAAa,EACb,KAAK,GACN,EAAE,yBAAyB,2CA6C3B"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// CSS custom properties for theming
|
|
3
|
-
const CSS_VARIABLES = `
|
|
4
|
-
@media (prefers-color-scheme: light) {
|
|
5
|
-
:root {
|
|
6
|
-
--gateway-bg: oklch(100% 0 0);
|
|
7
|
-
--gateway-text: oklch(0% 0 0);
|
|
8
|
-
--gateway-text-muted: oklch(40% 0 0);
|
|
9
|
-
--gateway-icon-bg: oklch(94% 0 0);
|
|
10
|
-
--gateway-icon-stroke: oklch(80% 0.18 90);
|
|
11
|
-
--gateway-border: oklch(94% 0 0);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
@media (prefers-color-scheme: dark) {
|
|
15
|
-
:root {
|
|
16
|
-
--gateway-bg: #0a0f0d;
|
|
17
|
-
--gateway-text: oklch(92% 0 0);
|
|
18
|
-
--gateway-text-muted: oklch(60% 0 0);
|
|
19
|
-
--gateway-icon-bg: oklch(22% 0 0);
|
|
20
|
-
--gateway-icon-stroke: oklch(85% 0.18 90);
|
|
21
|
-
--gateway-border: oklch(30% 0 0);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
const styles = {
|
|
26
|
-
container: {
|
|
27
|
-
display: "flex",
|
|
28
|
-
flexDirection: "column",
|
|
29
|
-
alignItems: "center",
|
|
30
|
-
justifyContent: "center",
|
|
31
|
-
minHeight: "100vh",
|
|
32
|
-
padding: "24px",
|
|
33
|
-
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
|
|
34
|
-
backgroundColor: "var(--gateway-bg, oklch(100% 0 0))",
|
|
35
|
-
color: "var(--gateway-text, oklch(0% 0 0))",
|
|
36
|
-
colorScheme: "light dark",
|
|
37
|
-
},
|
|
38
|
-
content: {
|
|
39
|
-
maxWidth: "520px",
|
|
40
|
-
width: "100%",
|
|
41
|
-
textAlign: "left",
|
|
42
|
-
},
|
|
43
|
-
iconContainer: {
|
|
44
|
-
width: "44px",
|
|
45
|
-
height: "44px",
|
|
46
|
-
marginBottom: "16px",
|
|
47
|
-
borderRadius: "0.25rem",
|
|
48
|
-
backgroundColor: "var(--gateway-icon-bg, oklch(94% 0 0))",
|
|
49
|
-
display: "flex",
|
|
50
|
-
alignItems: "center",
|
|
51
|
-
justifyContent: "center",
|
|
52
|
-
border: "1px solid var(--gateway-border, oklch(94% 0 0))",
|
|
53
|
-
},
|
|
54
|
-
title: {
|
|
55
|
-
fontSize: "18px",
|
|
56
|
-
fontWeight: 600,
|
|
57
|
-
marginBottom: "8px",
|
|
58
|
-
color: "var(--gateway-text, oklch(0% 0 0))",
|
|
59
|
-
letterSpacing: "-0.01em",
|
|
60
|
-
},
|
|
61
|
-
description: {
|
|
62
|
-
fontSize: "14px",
|
|
63
|
-
lineHeight: 1.5,
|
|
64
|
-
color: "var(--gateway-text-muted, oklch(40% 0 0))",
|
|
65
|
-
marginBottom: "20px",
|
|
66
|
-
},
|
|
67
|
-
urlText: {
|
|
68
|
-
fontSize: "14px",
|
|
69
|
-
lineHeight: 1.5,
|
|
70
|
-
color: "var(--gateway-text-muted, oklch(40% 0 0))",
|
|
71
|
-
wordBreak: "break-all",
|
|
72
|
-
},
|
|
73
|
-
urlLink: {
|
|
74
|
-
color: "rgb(168, 162, 158)",
|
|
75
|
-
textDecoration: "underline",
|
|
76
|
-
textDecorationColor: "rgb(87, 83, 78)",
|
|
77
|
-
textUnderlineOffset: "2px",
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Error component displayed when an embedded app is accessed directly
|
|
82
|
-
* instead of through the Every App Gateway.
|
|
83
|
-
*
|
|
84
|
-
* This component informs users that authentication requires accessing
|
|
85
|
-
* the app through the Gateway and provides a link to do so.
|
|
86
|
-
*/
|
|
87
|
-
export function GatewayRequiredError({ gatewayOrigin, appId, }) {
|
|
88
|
-
const isLocalhost = window.location.hostname === "localhost";
|
|
89
|
-
const gatewayUrl = `${gatewayOrigin}/apps/${appId}${window.location.pathname}${isLocalhost ? "dev" : ""}`;
|
|
90
|
-
return (_jsxs("div", { style: styles.container, children: [_jsx("style", { children: CSS_VARIABLES }), _jsxs("div", { style: styles.content, children: [_jsx("div", { style: styles.iconContainer, children: _jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "var(--gateway-icon-stroke, oklch(55% 0.22 25))", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }), _jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13" }), _jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })] }) }), _jsx("h1", { style: styles.title, children: "Open in Gateway" }), _jsx("p", { style: styles.description, children: "The Gateway handles sign in and user auth. Access your app from there so this works properly." }), _jsxs("p", { style: styles.urlText, children: ["Go to", " ", _jsx("a", { href: gatewayUrl, style: styles.urlLink, children: gatewayUrl })] })] })] }));
|
|
91
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SessionManager } from "../../core/sessionManager.js";
|
|
2
|
-
interface SessionManagerConfig {
|
|
3
|
-
appId: string;
|
|
4
|
-
}
|
|
5
|
-
interface UseEveryAppSessionParams {
|
|
6
|
-
sessionManagerConfig: SessionManagerConfig;
|
|
7
|
-
}
|
|
8
|
-
type SessionBootstrapGate = Pick<SessionManager, "isEmbedded" | "isBypassGatewayLocalOnly">;
|
|
9
|
-
export declare function shouldBootstrapSession(sessionManager: SessionBootstrapGate): boolean;
|
|
10
|
-
export declare function useEveryAppSession({ sessionManagerConfig, }: UseEveryAppSessionParams): {
|
|
11
|
-
sessionManager: SessionManager | null;
|
|
12
|
-
sessionTokenState: {
|
|
13
|
-
status: "NO_TOKEN" | "VALID" | "EXPIRED" | "REFRESHING";
|
|
14
|
-
token: string | null;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=useEveryAppSession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEveryAppSession.d.ts","sourceRoot":"","sources":["../../../src/tanstack/_internal/useEveryAppSession.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,wBAAwB;IAChC,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C;AAED,KAAK,oBAAoB,GAAG,IAAI,CAC9B,cAAc,EACd,YAAY,GAAG,0BAA0B,CAC1C,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,oBAAoB,GACnC,OAAO,CAKT;AAED,wBAAgB,kBAAkB,CAAC,EACjC,oBAAoB,GACrB,EAAE,wBAAwB;;;;;;EA8C1B"}
|