@base44-preview/cli 0.3.2-pr.698.ea0a371 → 0.3.3-pr.700.881d5e4
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/cli/index.js +205 -39
- package/dist/cli/index.js.map +7 -7
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -228845,13 +228845,19 @@ function findEnvDir(cwd) {
|
|
|
228845
228845
|
const configDir = dirname3(found.configPath);
|
|
228846
228846
|
return basename(configDir) === PROJECT_SUBDIR ? dirname3(configDir) : configDir;
|
|
228847
228847
|
}
|
|
228848
|
+
var accessTokenFromEnvFile = false;
|
|
228849
|
+
function isAccessTokenFromEnvFile() {
|
|
228850
|
+
return accessTokenFromEnvFile;
|
|
228851
|
+
}
|
|
228848
228852
|
function loadProjectEnvFiles(cwd = process.cwd()) {
|
|
228849
228853
|
const root = findEnvDir(cwd);
|
|
228854
|
+
const ambientAccessToken = process.env.BASE44_ACCESS_TOKEN ?? process.env[`${STRIPE_ENV_PREFIX}BASE44_ACCESS_TOKEN`];
|
|
228850
228855
|
import_dotenv.config({
|
|
228851
228856
|
path: [join(root, ".env.local"), join(root, ".env")],
|
|
228852
228857
|
quiet: true
|
|
228853
228858
|
});
|
|
228854
228859
|
normalizeBase44Env();
|
|
228860
|
+
accessTokenFromEnvFile = ambientAccessToken === undefined && process.env.BASE44_ACCESS_TOKEN !== undefined;
|
|
228855
228861
|
}
|
|
228856
228862
|
function normalizeBase44Env() {
|
|
228857
228863
|
for (const bareKey of BASE44_ENV_KEYS) {
|
|
@@ -230864,6 +230870,7 @@ function getTestOverrides() {
|
|
|
230864
230870
|
var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
|
|
230865
230871
|
var WORKSPACE_API_KEY_PREFIX = "b44k_";
|
|
230866
230872
|
var refreshPromise = null;
|
|
230873
|
+
var envAccessTokenAuth = null;
|
|
230867
230874
|
function getWorkspaceApiKeyFromEnv() {
|
|
230868
230875
|
const key = process.env.BASE44_API_KEY?.trim();
|
|
230869
230876
|
return key ? key : null;
|
|
@@ -230885,7 +230892,20 @@ async function seedAuthFromEnv() {
|
|
|
230885
230892
|
const payload = claims !== null && typeof claims === "object" ? claims : null;
|
|
230886
230893
|
const sub = typeof payload?.sub === "string" ? payload.sub : undefined;
|
|
230887
230894
|
const exp = typeof payload?.exp === "number" ? payload.exp : undefined;
|
|
230888
|
-
if (!
|
|
230895
|
+
if (!sub || !exp) {
|
|
230896
|
+
return;
|
|
230897
|
+
}
|
|
230898
|
+
if (!refreshToken) {
|
|
230899
|
+
if (isAccessTokenFromEnvFile()) {
|
|
230900
|
+
return;
|
|
230901
|
+
}
|
|
230902
|
+
envAccessTokenAuth = {
|
|
230903
|
+
accessToken,
|
|
230904
|
+
refreshToken: "",
|
|
230905
|
+
expiresAt: exp * 1000,
|
|
230906
|
+
email: sub,
|
|
230907
|
+
name: sub
|
|
230908
|
+
};
|
|
230889
230909
|
return;
|
|
230890
230910
|
}
|
|
230891
230911
|
await writeAuth({
|
|
@@ -230897,6 +230917,9 @@ async function seedAuthFromEnv() {
|
|
|
230897
230917
|
});
|
|
230898
230918
|
}
|
|
230899
230919
|
async function readAuth() {
|
|
230920
|
+
if (envAccessTokenAuth) {
|
|
230921
|
+
return envAccessTokenAuth;
|
|
230922
|
+
}
|
|
230900
230923
|
try {
|
|
230901
230924
|
const authData = await readJsonFile(getAuthFilePath());
|
|
230902
230925
|
const result = AuthDataSchema.safeParse(authData);
|
|
@@ -230933,6 +230956,9 @@ function isTokenExpired(auth) {
|
|
|
230933
230956
|
return Date.now() >= auth.expiresAt - TOKEN_REFRESH_BUFFER_MS;
|
|
230934
230957
|
}
|
|
230935
230958
|
async function refreshAndSaveTokens() {
|
|
230959
|
+
if (envAccessTokenAuth) {
|
|
230960
|
+
return null;
|
|
230961
|
+
}
|
|
230936
230962
|
if (refreshPromise) {
|
|
230937
230963
|
return refreshPromise;
|
|
230938
230964
|
}
|
|
@@ -239420,7 +239446,7 @@ import { join as join13 } from "node:path";
|
|
|
239420
239446
|
// package.json
|
|
239421
239447
|
var package_default = {
|
|
239422
239448
|
name: "base44",
|
|
239423
|
-
version: "0.3.
|
|
239449
|
+
version: "0.3.3",
|
|
239424
239450
|
description: "Base44 CLI - Unified interface for managing Base44 applications",
|
|
239425
239451
|
type: "module",
|
|
239426
239452
|
bin: {
|
|
@@ -256406,7 +256432,7 @@ Did you try connecting directly to this Durable Object? Try using getServerByNam
|
|
|
256406
256432
|
};
|
|
256407
256433
|
|
|
256408
256434
|
// src/shim/actor.ts
|
|
256409
|
-
import { createClient } from "npm:@base44/sdk@0.8.
|
|
256435
|
+
import { createClient } from "npm:@base44/sdk@0.8.54";
|
|
256410
256436
|
|
|
256411
256437
|
// src/shim/tick-loop.ts
|
|
256412
256438
|
var TickLoop = class {
|
|
@@ -256816,6 +256842,42 @@ var Actor = class _Actor extends Server {
|
|
|
256816
256842
|
}
|
|
256817
256843
|
handleWake(_key) {
|
|
256818
256844
|
}
|
|
256845
|
+
static parseRequestIdentity(value) {
|
|
256846
|
+
if (value === '{"type":"service"}') return Object.freeze({ type: "service" });
|
|
256847
|
+
return _Actor.parseIdentity(value);
|
|
256848
|
+
}
|
|
256849
|
+
// Called by the generated wrapper for a verified POST .../requests; never user-facing.
|
|
256850
|
+
async _b44ActorRequest(request) {
|
|
256851
|
+
const room = request.headers.get("x-partykit-room");
|
|
256852
|
+
if (room) await this.setName(room);
|
|
256853
|
+
if (typeof this.handleRequest !== "function") {
|
|
256854
|
+
return new Response("This actor does not accept requests", { status: 404 });
|
|
256855
|
+
}
|
|
256856
|
+
const identity = _Actor.parseRequestIdentity(request.headers.get(_Actor.IDENTITY_HEADER));
|
|
256857
|
+
if (!identity) return new Response("Unauthorized", { status: 401 });
|
|
256858
|
+
const forHandler = new Request(
|
|
256859
|
+
\`https://actor.base44/rooms/\${encodeURIComponent(this.name)}/requests\`,
|
|
256860
|
+
{
|
|
256861
|
+
method: "POST",
|
|
256862
|
+
headers: { "Content-Type": request.headers.get("Content-Type") ?? "application/json" },
|
|
256863
|
+
body: await request.arrayBuffer()
|
|
256864
|
+
}
|
|
256865
|
+
);
|
|
256866
|
+
let response;
|
|
256867
|
+
try {
|
|
256868
|
+
response = await this.handleRequest(forHandler, { identity });
|
|
256869
|
+
} catch (err) {
|
|
256870
|
+
console.error("Actor.handleRequest threw:", err);
|
|
256871
|
+
response = new Response("Actor request failed", { status: 500 });
|
|
256872
|
+
}
|
|
256873
|
+
await this.maintainTicker();
|
|
256874
|
+
if (response === void 0) return new Response(null, { status: 204 });
|
|
256875
|
+
if (!(response instanceof Response)) {
|
|
256876
|
+
console.error("Actor.handleRequest must return a Response or nothing");
|
|
256877
|
+
return new Response("Actor request failed", { status: 500 });
|
|
256878
|
+
}
|
|
256879
|
+
return response;
|
|
256880
|
+
}
|
|
256819
256881
|
async schedule(key, at) {
|
|
256820
256882
|
const when = typeof at === "number" ? at : at.getTime();
|
|
256821
256883
|
await this.mutateSchedules((m) => {
|
|
@@ -258556,7 +258618,7 @@ var TELEMETRY_PATCH = [
|
|
|
258556
258618
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
258557
258619
|
|
|
258558
258620
|
// ../functions-compiler/src/version.ts
|
|
258559
|
-
var COMPILER_VERSION = "0.
|
|
258621
|
+
var COMPILER_VERSION = "0.3.0";
|
|
258560
258622
|
|
|
258561
258623
|
// ../functions-compiler/src/worker-entry.ts
|
|
258562
258624
|
function denoShimSource() {
|
|
@@ -259055,8 +259117,11 @@ function buildActorAuth() {
|
|
|
259055
259117
|
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
259056
259118
|
const TOKEN_HEADER = "X-Base44-Actor-Token";
|
|
259057
259119
|
const IDENTITY_HEADER = "X-Base44-Actor-Identity";
|
|
259120
|
+
const REQUEST_TOKEN_HEADER = "X-Base44-Actor-Request-Token";
|
|
259058
259121
|
const CLOCK_SKEW_SECONDS = 30;
|
|
259059
259122
|
const TOKEN_TTL_SECONDS = 300;
|
|
259123
|
+
const REQUEST_TOKEN_TTL_SECONDS = 60;
|
|
259124
|
+
const REQUEST_MAX_BYTES = 64 * 1024;
|
|
259060
259125
|
|
|
259061
259126
|
const decodeSegment = (segment) => {
|
|
259062
259127
|
const normalized = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -259072,6 +259137,37 @@ const unauthorized = () => ({
|
|
|
259072
259137
|
ok: false,
|
|
259073
259138
|
response: new Response("Unauthorized", { status: 401 }),
|
|
259074
259139
|
});
|
|
259140
|
+
const refused = (status, text) => ({ ok: false, response: new Response(text, { status }) });
|
|
259141
|
+
|
|
259142
|
+
// The claims of an EdDSA JWT whose signature the actor's public key verifies, else null.
|
|
259143
|
+
const verifiedClaims = async (token, publicKey) => {
|
|
259144
|
+
if (typeof token !== "string" || token.length > 4096) return null;
|
|
259145
|
+
const parts = token.split(".");
|
|
259146
|
+
if (parts.length !== 3) return null;
|
|
259147
|
+
const header = decodeJsonSegment(parts[0]);
|
|
259148
|
+
if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) return null;
|
|
259149
|
+
const key = await crypto.subtle.importKey(
|
|
259150
|
+
"raw",
|
|
259151
|
+
decodeSegment(publicKey),
|
|
259152
|
+
{ name: "Ed25519" },
|
|
259153
|
+
false,
|
|
259154
|
+
["verify"],
|
|
259155
|
+
);
|
|
259156
|
+
const validSignature = await crypto.subtle.verify(
|
|
259157
|
+
{ name: "Ed25519" },
|
|
259158
|
+
key,
|
|
259159
|
+
decodeSegment(parts[2]),
|
|
259160
|
+
new TextEncoder().encode(parts[0] + "." + parts[1]),
|
|
259161
|
+
);
|
|
259162
|
+
return validSignature ? decodeJsonSegment(parts[1]) : null;
|
|
259163
|
+
};
|
|
259164
|
+
|
|
259165
|
+
const validTimes = (claims, now, ttlSeconds) =>
|
|
259166
|
+
[claims.iat, claims.nbf, claims.exp].every(Number.isInteger) &&
|
|
259167
|
+
claims.iat <= now + CLOCK_SKEW_SECONDS &&
|
|
259168
|
+
claims.nbf <= now + CLOCK_SKEW_SECONDS &&
|
|
259169
|
+
claims.exp >= now - CLOCK_SKEW_SECONDS &&
|
|
259170
|
+
claims.exp > claims.iat && claims.exp - claims.iat <= ttlSeconds;
|
|
259075
259171
|
|
|
259076
259172
|
const validPrincipal = (principal) => {
|
|
259077
259173
|
if (principal === null || typeof principal !== "object" || Array.isArray(principal)) return false;
|
|
@@ -259090,46 +259186,21 @@ export async function verifyActorConnection(request, env, actorName, room) {
|
|
|
259090
259186
|
const token = request.headers.get(TOKEN_HEADER) ?? new URL(request.url).searchParams.get("token");
|
|
259091
259187
|
if (
|
|
259092
259188
|
typeof publicKey !== "string" || !publicKey ||
|
|
259093
|
-
typeof scriptId !== "string" || !scriptId
|
|
259094
|
-
typeof token !== "string" || token.length > 4096
|
|
259189
|
+
typeof scriptId !== "string" || !scriptId
|
|
259095
259190
|
) return unauthorized();
|
|
259096
259191
|
|
|
259097
|
-
const parts = token.split(".");
|
|
259098
|
-
if (parts.length !== 3) return unauthorized();
|
|
259099
259192
|
try {
|
|
259100
|
-
const
|
|
259101
|
-
|
|
259102
|
-
if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) {
|
|
259103
|
-
return unauthorized();
|
|
259104
|
-
}
|
|
259105
|
-
const key = await crypto.subtle.importKey(
|
|
259106
|
-
"raw",
|
|
259107
|
-
decodeSegment(publicKey),
|
|
259108
|
-
{ name: "Ed25519" },
|
|
259109
|
-
false,
|
|
259110
|
-
["verify"],
|
|
259111
|
-
);
|
|
259112
|
-
const validSignature = await crypto.subtle.verify(
|
|
259113
|
-
{ name: "Ed25519" },
|
|
259114
|
-
key,
|
|
259115
|
-
decodeSegment(parts[2]),
|
|
259116
|
-
new TextEncoder().encode(parts[0] + "." + parts[1]),
|
|
259117
|
-
);
|
|
259118
|
-
if (!validSignature) return unauthorized();
|
|
259193
|
+
const claims = await verifiedClaims(token, publicKey);
|
|
259194
|
+
if (!claims) return unauthorized();
|
|
259119
259195
|
|
|
259120
259196
|
const now = Math.floor(Date.now() / 1000);
|
|
259121
|
-
const times = [claims.iat, claims.nbf, claims.exp];
|
|
259122
|
-
if (!times.every(Number.isInteger)) return unauthorized();
|
|
259123
259197
|
if (
|
|
259124
259198
|
claims.iss !== "base44" ||
|
|
259125
259199
|
claims.aud !== "base44-actor-connect" ||
|
|
259126
259200
|
claims.purpose !== "actor-connect" ||
|
|
259127
259201
|
claims.v !== 1 ||
|
|
259128
259202
|
typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
|
|
259129
|
-
claims
|
|
259130
|
-
claims.nbf > now + CLOCK_SKEW_SECONDS ||
|
|
259131
|
-
claims.exp < now - CLOCK_SKEW_SECONDS ||
|
|
259132
|
-
claims.exp <= claims.iat || claims.exp - claims.iat > TOKEN_TTL_SECONDS ||
|
|
259203
|
+
!validTimes(claims, now, TOKEN_TTL_SECONDS) ||
|
|
259133
259204
|
claims.app_id !== env.BASE44_APP_ID ||
|
|
259134
259205
|
claims.actor_name !== actorName ||
|
|
259135
259206
|
claims.actor_script_id !== scriptId ||
|
|
@@ -259159,6 +259230,81 @@ export function authorizedActorRequest(request, identity, actorName, room, runti
|
|
|
259159
259230
|
headers.set("base44-functions-version", runtimeMode === "prod" ? "prod" : "preview");
|
|
259160
259231
|
return new Request(new Request(url.toString(), request), { headers });
|
|
259161
259232
|
}
|
|
259233
|
+
|
|
259234
|
+
const validRequestPrincipal = (principal) =>
|
|
259235
|
+
validPrincipal(principal) ||
|
|
259236
|
+
(principal !== null && typeof principal === "object" && principal.type === "service" && Object.keys(principal).length === 1);
|
|
259237
|
+
|
|
259238
|
+
const sha256 = async (bytes) => {
|
|
259239
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
259240
|
+
return btoa(String.fromCharCode(...digest)).replace(/\\+/g, "-").replace(/\\//g, "_").replace(/=+$/, "");
|
|
259241
|
+
};
|
|
259242
|
+
|
|
259243
|
+
// A request the backend relays into one room for a caller it authenticated. Same
|
|
259244
|
+
// key as connection tokens, its own audience and purpose: neither is accepted as
|
|
259245
|
+
// the other. The token is bound to the body, so a leaked token can't carry another.
|
|
259246
|
+
// 401 is a token this key did not mint or that has lapsed; 403 is a good token for
|
|
259247
|
+
// another app, actor, script, room or runtime.
|
|
259248
|
+
export async function verifyActorRequest(request, env, actorName, room) {
|
|
259249
|
+
const publicKey = env.BASE44_ACTOR_PUBLIC_KEY;
|
|
259250
|
+
const scriptId = env.BASE44_ACTOR_SCRIPT_ID;
|
|
259251
|
+
if (
|
|
259252
|
+
typeof publicKey !== "string" || !publicKey ||
|
|
259253
|
+
typeof scriptId !== "string" || !scriptId
|
|
259254
|
+
) return unauthorized();
|
|
259255
|
+
try {
|
|
259256
|
+
const claims = await verifiedClaims(request.headers.get(REQUEST_TOKEN_HEADER), publicKey);
|
|
259257
|
+
if (!claims) return unauthorized();
|
|
259258
|
+
const now = Math.floor(Date.now() / 1000);
|
|
259259
|
+
if (
|
|
259260
|
+
claims.iss !== "base44" ||
|
|
259261
|
+
claims.aud !== "base44-actor-request" ||
|
|
259262
|
+
claims.purpose !== "actor-request" ||
|
|
259263
|
+
claims.v !== 1 ||
|
|
259264
|
+
typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
|
|
259265
|
+
!validTimes(claims, now, REQUEST_TOKEN_TTL_SECONDS) ||
|
|
259266
|
+
typeof claims.body_sha256 !== "string" ||
|
|
259267
|
+
!validRequestPrincipal(claims.principal)
|
|
259268
|
+
) return unauthorized();
|
|
259269
|
+
if (
|
|
259270
|
+
claims.app_id !== env.BASE44_APP_ID ||
|
|
259271
|
+
claims.actor_name !== actorName ||
|
|
259272
|
+
claims.actor_script_id !== scriptId ||
|
|
259273
|
+
claims.room !== room ||
|
|
259274
|
+
claims.runtime_mode !== (env.BASE44_FUNCTIONS_VERSION === "prod" ? "prod" : "preview")
|
|
259275
|
+
) return refused(403, "Forbidden");
|
|
259276
|
+
|
|
259277
|
+
const body = new Uint8Array(await request.arrayBuffer());
|
|
259278
|
+
if (body.length > REQUEST_MAX_BYTES) return refused(413, "Request too large");
|
|
259279
|
+
if (await sha256(body) !== claims.body_sha256) return unauthorized();
|
|
259280
|
+
return {
|
|
259281
|
+
ok: true,
|
|
259282
|
+
identity: Object.freeze({ ...claims.principal }),
|
|
259283
|
+
runtimeMode: claims.runtime_mode,
|
|
259284
|
+
body,
|
|
259285
|
+
};
|
|
259286
|
+
} catch {
|
|
259287
|
+
return unauthorized();
|
|
259288
|
+
}
|
|
259289
|
+
}
|
|
259290
|
+
|
|
259291
|
+
// Into the room as POST /parties/<actor>/<room>/requests: a path no client route
|
|
259292
|
+
// forwards (the legacy route is exactly four segments, the direct route rewrites
|
|
259293
|
+
// the path), so the Durable Object can trust the shape and its identity header.
|
|
259294
|
+
export function actorRequestToRoom(request, actorName, room, verified) {
|
|
259295
|
+
const url = new URL(request.url);
|
|
259296
|
+
url.search = "";
|
|
259297
|
+
url.pathname = "/parties/" + encodeURIComponent(actorName) + "/" + encodeURIComponent(room) + "/requests";
|
|
259298
|
+
return new Request(url.toString(), {
|
|
259299
|
+
method: "POST",
|
|
259300
|
+
headers: {
|
|
259301
|
+
"Content-Type": request.headers.get("Content-Type") ?? "application/json",
|
|
259302
|
+
[IDENTITY_HEADER]: JSON.stringify(verified.identity),
|
|
259303
|
+
"base44-functions-version": verified.runtimeMode,
|
|
259304
|
+
},
|
|
259305
|
+
body: verified.body,
|
|
259306
|
+
});
|
|
259307
|
+
}
|
|
259162
259308
|
`;
|
|
259163
259309
|
}
|
|
259164
259310
|
function buildPrelude() {
|
|
@@ -259179,7 +259325,12 @@ function buildEntryWrapper(doClassName, userEntry) {
|
|
|
259179
259325
|
import "./${ACTOR_PRELUDE_FILENAME}";
|
|
259180
259326
|
import Base44UserActor from ${JSON.stringify(userImport)};
|
|
259181
259327
|
import { runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
259182
|
-
import {
|
|
259328
|
+
import {
|
|
259329
|
+
actorRequestToRoom as _b44ActorRequestToRoom,
|
|
259330
|
+
authorizedActorRequest as _b44AuthorizedActorRequest,
|
|
259331
|
+
verifyActorConnection as _b44VerifyActorConnection,
|
|
259332
|
+
verifyActorRequest as _b44VerifyActorRequest,
|
|
259333
|
+
} from "./${ACTOR_AUTH_FILENAME}";
|
|
259183
259334
|
|
|
259184
259335
|
const _b44ActorState = new WeakMap();
|
|
259185
259336
|
const _b44RunWithActorEnvironment = (ctx, env, runtimeEnv, callback) => _b44Run({
|
|
@@ -259209,6 +259360,11 @@ const _b44RunActor = (actor, request, callback) => {
|
|
|
259209
259360
|
state.runtimeEnv = runtimeEnv;
|
|
259210
259361
|
return _b44RunWithActorEnvironment(state.ctx, state.env, runtimeEnv, callback);
|
|
259211
259362
|
};
|
|
259363
|
+
const _b44IsActorRequest = (request) => {
|
|
259364
|
+
if (request.method !== "POST") return false;
|
|
259365
|
+
const parts = new URL(request.url).pathname.split("/");
|
|
259366
|
+
return parts.length === 5 && parts[1] === "parties" && parts[4] === "requests";
|
|
259367
|
+
};
|
|
259212
259368
|
|
|
259213
259369
|
export class ${doClassName} extends Base44UserActor {
|
|
259214
259370
|
// Read by the shim's service-token exchange: the assertion's actor_name claim
|
|
@@ -259221,6 +259377,11 @@ export class ${doClassName} extends Base44UserActor {
|
|
|
259221
259377
|
}
|
|
259222
259378
|
|
|
259223
259379
|
fetch(request) {
|
|
259380
|
+
// Ahead of the user's own fetch override: a relayed request reaches the room
|
|
259381
|
+
// only through the shim, which hands handleRequest the verified identity.
|
|
259382
|
+
if (_b44IsActorRequest(request)) {
|
|
259383
|
+
return _b44RunActor(this, request, () => this._b44ActorRequest(request));
|
|
259384
|
+
}
|
|
259224
259385
|
return _b44RunActor(this, request, () => super.fetch(request));
|
|
259225
259386
|
}
|
|
259226
259387
|
|
|
@@ -259254,15 +259415,20 @@ export default {
|
|
|
259254
259415
|
const parts = url.pathname.split("/");
|
|
259255
259416
|
const direct = parts[1] === "rooms" && parts.length === 3;
|
|
259256
259417
|
const legacy = parts[1] === "parties" && parts.length === 4;
|
|
259257
|
-
|
|
259418
|
+
const relayed = request.method === "POST" && parts[1] === "rooms" && parts.length === 4 && parts[3] === "requests";
|
|
259419
|
+
if (direct || legacy || relayed) {
|
|
259258
259420
|
// Decode the room: the token was verified against the decoded instance id,
|
|
259259
259421
|
// so an escaped room must map to the same Durable Object.
|
|
259260
|
-
const namespace =
|
|
259261
|
-
const encodedRoom =
|
|
259422
|
+
const namespace = legacy ? parts[2] : "${doClassName}";
|
|
259423
|
+
const encodedRoom = legacy ? parts[3] : parts[2];
|
|
259262
259424
|
let room;
|
|
259263
259425
|
try { room = decodeURIComponent(encodedRoom); } catch { return new Response("Invalid room", { status: 400 }); }
|
|
259264
259426
|
let actorRequest = request;
|
|
259265
|
-
if (
|
|
259427
|
+
if (relayed) {
|
|
259428
|
+
const verification = await _b44VerifyActorRequest(request, env, "${doClassName}", room);
|
|
259429
|
+
if (!verification.ok) return verification.response;
|
|
259430
|
+
actorRequest = _b44ActorRequestToRoom(request, "${doClassName}", room, verification);
|
|
259431
|
+
} else if (direct || typeof env.BASE44_ACTOR_PUBLIC_KEY === "string") {
|
|
259266
259432
|
const verification = await _b44VerifyActorConnection(request, env, "${doClassName}", room);
|
|
259267
259433
|
if (!verification.ok) return verification.response;
|
|
259268
259434
|
actorRequest = _b44AuthorizedActorRequest(
|
|
@@ -275100,4 +275266,4 @@ export {
|
|
|
275100
275266
|
runCLI
|
|
275101
275267
|
};
|
|
275102
275268
|
|
|
275103
|
-
//# debugId=
|
|
275269
|
+
//# debugId=B98A0F7103A0C01B64756E2164756E21
|