@every-app/sdk 0.1.12 → 0.1.14
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/dist/cloudflare/server/gateway.js +5 -0
- package/dist/shared/bypassGatewayLocalOnly.d.ts +2 -1
- package/dist/shared/bypassGatewayLocalOnly.d.ts.map +1 -1
- package/dist/shared/bypassGatewayLocalOnly.js +6 -2
- package/dist/tanstack/server/authenticateRequest.d.ts +2 -0
- package/dist/tanstack/server/authenticateRequest.d.ts.map +1 -1
- package/dist/tanstack/server/authenticateRequest.js +81 -4
- package/package.json +3 -3
- package/src/cloudflare/getLocalD1Url.ts +0 -64
- package/src/cloudflare/index.ts +0 -1
- package/src/cloudflare/lazyInit.ts +0 -67
- package/src/cloudflare/server/gateway.test.ts +0 -215
- package/src/cloudflare/server/gateway.ts +0 -106
- package/src/cloudflare/server/index.ts +0 -2
- package/src/core/authenticatedFetch.ts +0 -54
- package/src/core/index.ts +0 -12
- package/src/core/sessionManager.test.ts +0 -939
- package/src/core/sessionManager.ts +0 -492
- package/src/env.d.ts +0 -13
- package/src/shared/bypassGatewayLocalOnly.ts +0 -55
- package/src/shared/parseMessagePayload.ts +0 -22
- package/src/tanstack/EmbeddedAppProvider.tsx +0 -96
- package/src/tanstack/GatewayRequiredError.tsx +0 -150
- package/src/tanstack/_internal/useEveryAppSession.test.ts +0 -40
- package/src/tanstack/_internal/useEveryAppSession.tsx +0 -74
- package/src/tanstack/index.ts +0 -3
- package/src/tanstack/server/authConfig.ts +0 -19
- package/src/tanstack/server/authenticateRequest.test.ts +0 -447
- package/src/tanstack/server/authenticateRequest.ts +0 -137
- package/src/tanstack/server/index.ts +0 -3
- package/src/tanstack/server/types.ts +0 -4
- package/src/tanstack/useEveryAppRouter.tsx +0 -83
- package/src/tanstack/useSessionTokenClientMiddleware.ts +0 -43
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BYPASS_GATEWAY_LOCAL_ONLY_TOKEN,
|
|
3
|
-
isBypassGatewayLocalOnlyClient,
|
|
4
|
-
} from "../shared/bypassGatewayLocalOnly.js";
|
|
5
|
-
|
|
6
|
-
interface SessionManager {
|
|
7
|
-
getToken(): Promise<string>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface WindowWithSessionManager extends Window {
|
|
11
|
-
__embeddedSessionManager?: SessionManager;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gets the current session token from the embedded session manager
|
|
16
|
-
*/
|
|
17
|
-
export async function getSessionToken(): Promise<string> {
|
|
18
|
-
if (isBypassGatewayLocalOnlyClient()) {
|
|
19
|
-
return BYPASS_GATEWAY_LOCAL_ONLY_TOKEN;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const windowWithSession = window as WindowWithSessionManager;
|
|
23
|
-
const sessionManager = windowWithSession.__embeddedSessionManager;
|
|
24
|
-
|
|
25
|
-
if (!sessionManager) {
|
|
26
|
-
throw new Error("Session manager not available");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const token = await sessionManager.getToken();
|
|
30
|
-
|
|
31
|
-
if (!token) {
|
|
32
|
-
throw new Error("No token available");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return token;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Performs a fetch request with the authorization header automatically added
|
|
40
|
-
*/
|
|
41
|
-
export async function authenticatedFetch(
|
|
42
|
-
input: RequestInfo | URL,
|
|
43
|
-
init?: RequestInit,
|
|
44
|
-
): Promise<Response> {
|
|
45
|
-
const token = await getSessionToken();
|
|
46
|
-
|
|
47
|
-
const headers = new Headers(init?.headers);
|
|
48
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
49
|
-
|
|
50
|
-
return fetch(input, {
|
|
51
|
-
...init,
|
|
52
|
-
headers,
|
|
53
|
-
});
|
|
54
|
-
}
|
package/src/core/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
SessionManager,
|
|
3
|
-
isRunningInIframe,
|
|
4
|
-
isRunningInReactNativeWebView,
|
|
5
|
-
detectEnvironment,
|
|
6
|
-
} from "./sessionManager.js";
|
|
7
|
-
export type {
|
|
8
|
-
SessionManagerConfig,
|
|
9
|
-
EmbeddedEnvironment,
|
|
10
|
-
} from "./sessionManager.js";
|
|
11
|
-
|
|
12
|
-
export { authenticatedFetch, getSessionToken } from "./authenticatedFetch.js";
|