appflare 0.2.1 → 0.2.3
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.
|
@@ -172,11 +172,6 @@ function renderRouteFactory(operation: HttpOperation): string {
|
|
|
172
172
|
(args ?? {}) as ${inputType},
|
|
173
173
|
) as ${inputType};
|
|
174
174
|
const requestAuthToken = resolveRealtimeAuthToken(authToken, mergedOptions?.headers);
|
|
175
|
-
if (!requestAuthToken && !runtime.getAuthToken) {
|
|
176
|
-
throw new Error(
|
|
177
|
-
"authToken is required for realtime subscribe (pass options.authToken or Authorization Bearer header)",
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
175
|
|
|
181
176
|
let removed = false;
|
|
182
177
|
let socket: WebSocket | null = null;
|
|
@@ -229,17 +224,6 @@ function renderRouteFactory(operation: HttpOperation): string {
|
|
|
229
224
|
}
|
|
230
225
|
}
|
|
231
226
|
|
|
232
|
-
if (!resolvedAuthToken) {
|
|
233
|
-
const authError = new Error(
|
|
234
|
-
"authToken is required for realtime subscribe (pass options.authToken or Authorization Bearer header)",
|
|
235
|
-
);
|
|
236
|
-
if (onError) {
|
|
237
|
-
onError(authError);
|
|
238
|
-
} else {
|
|
239
|
-
console.warn("[appflare:subscribe]", authError.message);
|
|
240
|
-
}
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
227
|
|
|
244
228
|
const subscription = (await requestRoute<RealtimeSubscriptionResponse>(runtime.endpoint, {
|
|
245
229
|
route: "/realtime/subscribe",
|
|
@@ -43,9 +43,9 @@ export class AppflareRealtimeDurableObject {
|
|
|
43
43
|
const authToken =
|
|
44
44
|
typeof payload?.authToken === "string" ? payload.authToken : "";
|
|
45
45
|
|
|
46
|
-
if (!token
|
|
46
|
+
if (!token ) {
|
|
47
47
|
return new Response(
|
|
48
|
-
JSON.stringify({ message: "token
|
|
48
|
+
JSON.stringify({ message: "token is required" }),
|
|
49
49
|
{
|
|
50
50
|
status: 400,
|
|
51
51
|
headers: { "content-type": "application/json" },
|
|
@@ -104,7 +104,7 @@ export class AppflareRealtimeDurableObject {
|
|
|
104
104
|
const token = url.searchParams.get("token") ?? "";
|
|
105
105
|
const authToken = url.searchParams.get("authToken") ?? "";
|
|
106
106
|
const subscription = this.subscriptions.get(token);
|
|
107
|
-
if (!subscription
|
|
107
|
+
if (!subscription) {
|
|
108
108
|
return new Response("Unauthorized", { status: 401 });
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -14,8 +14,8 @@ function registerRealtimeRoutes(
|
|
|
14
14
|
const authToken = typeof body.authToken === "string" ? body.authToken : "";
|
|
15
15
|
const rawArgs = isRecord(body.args) ? body.args : {};
|
|
16
16
|
|
|
17
|
-
if (!queryName
|
|
18
|
-
return c.json({ message: "queryName
|
|
17
|
+
if (!queryName) {
|
|
18
|
+
return c.json({ message: "queryName is required" }, 400);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const operation = (realtimeQueryHandlers as Record<
|
|
@@ -95,8 +95,8 @@ function registerRealtimeRoutes(
|
|
|
95
95
|
const token = typeof body.token === "string" ? body.token : "";
|
|
96
96
|
const authToken = typeof body.authToken === "string" ? body.authToken : "";
|
|
97
97
|
|
|
98
|
-
if (!token
|
|
99
|
-
return c.json({ message: "token
|
|
98
|
+
if (!token ) {
|
|
99
|
+
return c.json({ message: "token is required" }, 400);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
const authSession = await validateAuthToken(
|
package/index.ts
CHANGED
|
@@ -18,10 +18,3 @@ export {
|
|
|
18
18
|
type SchemaDefinition,
|
|
19
19
|
type TableDefinition,
|
|
20
20
|
} from "./schema";
|
|
21
|
-
export { useQuery } from "./react";
|
|
22
|
-
export { useInfiniteQuery } from "./react";
|
|
23
|
-
export { useMutation } from "./react";
|
|
24
|
-
export type {
|
|
25
|
-
UseAppflareQueryOptions,
|
|
26
|
-
UseAppflareInfiniteQueryOptions,
|
|
27
|
-
} from "./react";
|