@domino-sdk/relay-runtime 0.2.0 → 0.3.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/dist/index.js +423 -91
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14833,7 +14833,40 @@ var init_chunk_C2KOMNLG = __esm({
|
|
|
14833
14833
|
}
|
|
14834
14834
|
});
|
|
14835
14835
|
|
|
14836
|
-
// packages/sdk/dist/chunk-
|
|
14836
|
+
// packages/sdk/dist/chunk-6IXQRMGW.js
|
|
14837
|
+
var authScopeSchema, principalSchema, sessionSchema, exchangeSchema, exchangeResultSchema;
|
|
14838
|
+
var init_chunk_6IXQRMGW = __esm({
|
|
14839
|
+
"packages/sdk/dist/chunk-6IXQRMGW.js"() {
|
|
14840
|
+
"use strict";
|
|
14841
|
+
init_chunk_C2KOMNLG();
|
|
14842
|
+
init_zod();
|
|
14843
|
+
authScopeSchema = external_exports.object({
|
|
14844
|
+
organization: identifier,
|
|
14845
|
+
project: identifier,
|
|
14846
|
+
environment: external_exports.enum(["test", "live"])
|
|
14847
|
+
}).strict();
|
|
14848
|
+
principalSchema = external_exports.discriminatedUnion("kind", [
|
|
14849
|
+
external_exports.object({ kind: external_exports.literal("member"), member: identifier }).strict(),
|
|
14850
|
+
external_exports.object({ kind: external_exports.literal("staff"), subject: identifier }).strict(),
|
|
14851
|
+
external_exports.object({ kind: external_exports.literal("operator"), subject: identifier }).strict()
|
|
14852
|
+
]);
|
|
14853
|
+
sessionSchema = authScopeSchema.extend({
|
|
14854
|
+
id: identifier,
|
|
14855
|
+
principal: principalSchema,
|
|
14856
|
+
expiresAt: external_exports.number()
|
|
14857
|
+
});
|
|
14858
|
+
exchangeSchema = authScopeSchema.extend({
|
|
14859
|
+
identity: external_exports.object({ issuer: identifier, subject: external_exports.string().min(1).max(200) }).strict(),
|
|
14860
|
+
role: external_exports.enum(["member", "staff", "operator"])
|
|
14861
|
+
}).strict();
|
|
14862
|
+
exchangeResultSchema = external_exports.object({
|
|
14863
|
+
token: external_exports.string(),
|
|
14864
|
+
session: sessionSchema
|
|
14865
|
+
});
|
|
14866
|
+
}
|
|
14867
|
+
});
|
|
14868
|
+
|
|
14869
|
+
// packages/sdk/dist/chunk-L757OYXZ.js
|
|
14837
14870
|
function questInteraction(trigger) {
|
|
14838
14871
|
return trigger.kind === "automatic" ? "automatic" : trigger.actor === "staff" ? "staff" : trigger.input === "none" ? "claim" : trigger.input;
|
|
14839
14872
|
}
|
|
@@ -15283,7 +15316,7 @@ function createRelayClient(options) {
|
|
|
15283
15316
|
}
|
|
15284
15317
|
const submission = submissions(
|
|
15285
15318
|
{
|
|
15286
|
-
session: () => request("/v1/auth/session",
|
|
15319
|
+
session: () => request("/v1/auth/session", sessionSchema.nullable()),
|
|
15287
15320
|
upload: (file2, action, session) => request("/v1/me/evidence", evidenceSchema, {
|
|
15288
15321
|
method: "POST",
|
|
15289
15322
|
headers: {
|
|
@@ -15334,7 +15367,7 @@ function createRelayClient(options) {
|
|
|
15334
15367
|
throw new Error("There is no failed attempt to retry.");
|
|
15335
15368
|
const session = await request(
|
|
15336
15369
|
"/v1/auth/session",
|
|
15337
|
-
|
|
15370
|
+
sessionSchema.nullable()
|
|
15338
15371
|
);
|
|
15339
15372
|
if (session?.principal.kind !== "member")
|
|
15340
15373
|
throw new Error("Sign in to retry verification.");
|
|
@@ -15358,7 +15391,7 @@ function createRelayClient(options) {
|
|
|
15358
15391
|
observe: (listener, options2) => {
|
|
15359
15392
|
const observer = observeProgress(
|
|
15360
15393
|
{
|
|
15361
|
-
session: (signal2) => request("/v1/auth/session",
|
|
15394
|
+
session: (signal2) => request("/v1/auth/session", sessionSchema.nullable(), { signal: signal2 }),
|
|
15362
15395
|
progress: (session, signal2) => request("/v1/me/experience", questExperienceSchema, {
|
|
15363
15396
|
signal: signal2,
|
|
15364
15397
|
headers: { "X-Relay-Session": session }
|
|
@@ -15418,7 +15451,7 @@ function createRelayClient(options) {
|
|
|
15418
15451
|
emailVerify: (challenge, code) => changeSession(
|
|
15419
15452
|
() => request(
|
|
15420
15453
|
"/v1/auth/email/verify",
|
|
15421
|
-
|
|
15454
|
+
sessionSchema,
|
|
15422
15455
|
json3({ challenge, code })
|
|
15423
15456
|
)
|
|
15424
15457
|
),
|
|
@@ -15432,20 +15465,21 @@ function createRelayClient(options) {
|
|
|
15432
15465
|
})
|
|
15433
15466
|
)
|
|
15434
15467
|
),
|
|
15435
|
-
session: () => request("/v1/auth/session",
|
|
15468
|
+
session: () => request("/v1/auth/session", sessionSchema.nullable()),
|
|
15436
15469
|
demoSignIn: (code) => changeSession(
|
|
15437
|
-
() => request("/v1/auth/demo",
|
|
15470
|
+
() => request("/v1/auth/demo", sessionSchema, json3({ code }))
|
|
15438
15471
|
),
|
|
15439
15472
|
signOut: () => changeSession(
|
|
15440
15473
|
() => request("/v1/auth/logout", external_exports.object({ ok: external_exports.boolean() }), json3({}))
|
|
15441
15474
|
),
|
|
15475
|
+
/** Local development only. Existing hosted apps use createParticipantBackend from /portal-proxy. */
|
|
15442
15476
|
exchange: (input) => request("/v1/auth/exchange", exchangeResultSchema, json3(input))
|
|
15443
15477
|
},
|
|
15444
15478
|
me: {
|
|
15445
15479
|
observeProgress: (listener, options2) => {
|
|
15446
15480
|
const observer = observeProgress(
|
|
15447
15481
|
{
|
|
15448
|
-
session: (signal2) => request("/v1/auth/session",
|
|
15482
|
+
session: (signal2) => request("/v1/auth/session", sessionSchema.nullable(), { signal: signal2 }),
|
|
15449
15483
|
progress: (session, signal2) => request("/v1/me/progress", memberProgressSchema, {
|
|
15450
15484
|
signal: signal2,
|
|
15451
15485
|
headers: { "X-Relay-Session": session }
|
|
@@ -15543,10 +15577,11 @@ function createRelayClient(options) {
|
|
|
15543
15577
|
decide: (id2, input) => request(`/v1/attempts/${id2}/review`, attemptSchema, json3(input))
|
|
15544
15578
|
};
|
|
15545
15579
|
}
|
|
15546
|
-
var interactionSchema, questTypeVersionSchema, collectionSlotSchema, questCollectionSchema, questInstanceSchema, questDraftChangesSchema, draftBase, questDraftSchema, questCatalogSchema, catalogDeploymentSchema, catalogDeploymentPreviewSchema, saveQuestDraftSchema, publishQuestDraftSchema, questViewSchema, collectionViewSchema, questExperienceSchema, questPublicationPreviewSchema, RelayError, common, claimInputSchema, draftSchema, recordSchema, QuestUpdatedError,
|
|
15547
|
-
var
|
|
15548
|
-
"packages/sdk/dist/chunk-
|
|
15580
|
+
var interactionSchema, questTypeVersionSchema, collectionSlotSchema, questCollectionSchema, questInstanceSchema, questDraftChangesSchema, draftBase, questDraftSchema, questCatalogSchema, catalogDeploymentSchema, catalogDeploymentPreviewSchema, saveQuestDraftSchema, publishQuestDraftSchema, questViewSchema, collectionViewSchema, questExperienceSchema, questPublicationPreviewSchema, RelayError, common, claimInputSchema, draftSchema, recordSchema, QuestUpdatedError, solanaAddressSchema, walletConnectionSchema, walletChallengeInputSchema, walletChallengeSchema, walletProofSchema, solanaBalanceSchema, collectionCodeSchema, collectionPassSchema, collectionResolveSchema, collectionBeginSchema, collectionPreviewSchema, projectDeploymentSchema, deploymentPreviewSchema, publishDeploymentSchema, deploymentResultSchema, identityIntegrationInputSchema, identityIntegrationSchema, identityIntegrationSecretSchema, participantExchangeSchema;
|
|
15581
|
+
var init_chunk_L757OYXZ = __esm({
|
|
15582
|
+
"packages/sdk/dist/chunk-L757OYXZ.js"() {
|
|
15549
15583
|
"use strict";
|
|
15584
|
+
init_chunk_6IXQRMGW();
|
|
15550
15585
|
init_chunk_C2KOMNLG();
|
|
15551
15586
|
init_zod();
|
|
15552
15587
|
init_zod();
|
|
@@ -15718,29 +15753,6 @@ var init_chunk_NC3UAP6T = __esm({
|
|
|
15718
15753
|
}
|
|
15719
15754
|
draft;
|
|
15720
15755
|
};
|
|
15721
|
-
authScopeSchema = external_exports.object({
|
|
15722
|
-
organization: identifier,
|
|
15723
|
-
project: identifier,
|
|
15724
|
-
environment: external_exports.enum(["test", "live"])
|
|
15725
|
-
}).strict();
|
|
15726
|
-
principalSchema = external_exports.discriminatedUnion("kind", [
|
|
15727
|
-
external_exports.object({ kind: external_exports.literal("member"), member: identifier }).strict(),
|
|
15728
|
-
external_exports.object({ kind: external_exports.literal("staff"), subject: identifier }).strict(),
|
|
15729
|
-
external_exports.object({ kind: external_exports.literal("operator"), subject: identifier }).strict()
|
|
15730
|
-
]);
|
|
15731
|
-
sessionSchema2 = authScopeSchema.extend({
|
|
15732
|
-
id: identifier,
|
|
15733
|
-
principal: principalSchema,
|
|
15734
|
-
expiresAt: external_exports.number()
|
|
15735
|
-
});
|
|
15736
|
-
exchangeSchema = authScopeSchema.extend({
|
|
15737
|
-
identity: external_exports.object({ issuer: identifier, subject: external_exports.string().min(1).max(200) }).strict(),
|
|
15738
|
-
role: external_exports.enum(["member", "staff", "operator"])
|
|
15739
|
-
}).strict();
|
|
15740
|
-
exchangeResultSchema = external_exports.object({
|
|
15741
|
-
token: external_exports.string(),
|
|
15742
|
-
session: sessionSchema2
|
|
15743
|
-
});
|
|
15744
15756
|
solanaAddressSchema = external_exports.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
|
|
15745
15757
|
walletConnectionSchema = external_exports.object({
|
|
15746
15758
|
chain: external_exports.literal("solana"),
|
|
@@ -15803,6 +15815,28 @@ var init_chunk_NC3UAP6T = __esm({
|
|
|
15803
15815
|
deploymentResultSchema = deploymentPreviewSchema.extend({
|
|
15804
15816
|
revision: external_exports.number().int().positive()
|
|
15805
15817
|
});
|
|
15818
|
+
identityIntegrationInputSchema = external_exports.object({
|
|
15819
|
+
name: external_exports.string().trim().min(1).max(80),
|
|
15820
|
+
origin: external_exports.string().url().refine((value) => {
|
|
15821
|
+
const url2 = new URL(value);
|
|
15822
|
+
return url2.protocol === "https:" && url2.origin === value;
|
|
15823
|
+
}, "Use an exact HTTPS application origin")
|
|
15824
|
+
}).strict();
|
|
15825
|
+
identityIntegrationSchema = authScopeSchema.extend({
|
|
15826
|
+
id: external_exports.string().uuid(),
|
|
15827
|
+
name: external_exports.string(),
|
|
15828
|
+
origin: external_exports.string(),
|
|
15829
|
+
expiresAt: external_exports.number()
|
|
15830
|
+
});
|
|
15831
|
+
identityIntegrationSecretSchema = identityIntegrationSchema.extend(
|
|
15832
|
+
{
|
|
15833
|
+
token: external_exports.string()
|
|
15834
|
+
}
|
|
15835
|
+
);
|
|
15836
|
+
participantExchangeSchema = external_exports.object({
|
|
15837
|
+
subject: external_exports.string().min(1).max(200),
|
|
15838
|
+
previousToken: external_exports.string().max(200).optional()
|
|
15839
|
+
}).strict();
|
|
15806
15840
|
}
|
|
15807
15841
|
});
|
|
15808
15842
|
|
|
@@ -15839,12 +15873,16 @@ __export(dist_exports, {
|
|
|
15839
15873
|
exchangeResultSchema: () => exchangeResultSchema,
|
|
15840
15874
|
exchangeSchema: () => exchangeSchema,
|
|
15841
15875
|
identifier: () => identifier,
|
|
15876
|
+
identityIntegrationInputSchema: () => identityIntegrationInputSchema,
|
|
15877
|
+
identityIntegrationSchema: () => identityIntegrationSchema,
|
|
15878
|
+
identityIntegrationSecretSchema: () => identityIntegrationSecretSchema,
|
|
15842
15879
|
interactionSchema: () => interactionSchema,
|
|
15843
15880
|
mediaUrlSchema: () => mediaUrlSchema,
|
|
15844
15881
|
memberListSchema: () => memberListSchema,
|
|
15845
15882
|
memberPageSchema: () => memberPageSchema,
|
|
15846
15883
|
memberProgressSchema: () => memberProgressSchema,
|
|
15847
15884
|
parseSettings: () => parseSettings,
|
|
15885
|
+
participantExchangeSchema: () => participantExchangeSchema,
|
|
15848
15886
|
photoResultSchema: () => photoResultSchema,
|
|
15849
15887
|
pickupAllocationSchema: () => pickupAllocationSchema,
|
|
15850
15888
|
pickupAvailabilitySchema: () => pickupAvailabilitySchema,
|
|
@@ -15891,7 +15929,7 @@ __export(dist_exports, {
|
|
|
15891
15929
|
rewardKey: () => rewardKey,
|
|
15892
15930
|
rewardSchema: () => rewardSchema,
|
|
15893
15931
|
saveQuestDraftSchema: () => saveQuestDraftSchema,
|
|
15894
|
-
sessionSchema: () =>
|
|
15932
|
+
sessionSchema: () => sessionSchema,
|
|
15895
15933
|
settingFieldSchema: () => settingFieldSchema,
|
|
15896
15934
|
settings: () => settings,
|
|
15897
15935
|
settingsFieldsSchema: () => settingsFieldsSchema,
|
|
@@ -15914,12 +15952,152 @@ __export(dist_exports, {
|
|
|
15914
15952
|
var init_dist = __esm({
|
|
15915
15953
|
"packages/sdk/dist/index.js"() {
|
|
15916
15954
|
"use strict";
|
|
15917
|
-
|
|
15955
|
+
init_chunk_L757OYXZ();
|
|
15956
|
+
init_chunk_6IXQRMGW();
|
|
15918
15957
|
init_chunk_C2KOMNLG();
|
|
15919
15958
|
}
|
|
15920
15959
|
});
|
|
15921
15960
|
|
|
15961
|
+
// apps/api/src/identity-integration.ts
|
|
15962
|
+
init_zod();
|
|
15963
|
+
init_dist();
|
|
15964
|
+
|
|
15965
|
+
// apps/api/src/access-error.ts
|
|
15966
|
+
var AccessError = class extends Error {
|
|
15967
|
+
constructor(message2, status = 403) {
|
|
15968
|
+
super(message2);
|
|
15969
|
+
this.status = status;
|
|
15970
|
+
}
|
|
15971
|
+
};
|
|
15972
|
+
|
|
15973
|
+
// apps/api/src/auth-utils.ts
|
|
15974
|
+
function cookie(request, name) {
|
|
15975
|
+
return request.headers.get("Cookie")?.split(";").map((value) => value.trim()).find((value) => value.startsWith(name + "="))?.slice(name.length + 1) ?? "";
|
|
15976
|
+
}
|
|
15977
|
+
function bindingCookie(value, secure, name = "relay_auth_flow") {
|
|
15978
|
+
return `${name}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${value ? 600 : 0}${secure ? "; Secure" : ""}`;
|
|
15979
|
+
}
|
|
15980
|
+
async function hash2(value) {
|
|
15981
|
+
const bytes = await crypto.subtle.digest(
|
|
15982
|
+
"SHA-256",
|
|
15983
|
+
new TextEncoder().encode(value)
|
|
15984
|
+
);
|
|
15985
|
+
return Array.from(
|
|
15986
|
+
new Uint8Array(bytes),
|
|
15987
|
+
(b) => b.toString(16).padStart(2, "0")
|
|
15988
|
+
).join("");
|
|
15989
|
+
}
|
|
15990
|
+
function sessionToken(request) {
|
|
15991
|
+
const bearer = request.headers.get("Authorization");
|
|
15992
|
+
if (bearer) return bearer.startsWith("Bearer ") ? bearer.slice(7) : "";
|
|
15993
|
+
return request.headers.get("Cookie")?.split(";").map((x) => x.trim()).find((x) => x.startsWith("relay_session="))?.slice("relay_session=".length) ?? "";
|
|
15994
|
+
}
|
|
15995
|
+
function sessionCookie(token, secure) {
|
|
15996
|
+
return `relay_session=${token}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${token ? 28800 : 0}${secure ? "; Secure" : ""}`;
|
|
15997
|
+
}
|
|
15998
|
+
function browserMutationAllowed(request, env) {
|
|
15999
|
+
const origin = request.headers.get("Origin");
|
|
16000
|
+
return request.headers.get("X-Relay-CSRF") === "1" && !!origin && (env.AUTH_ORIGINS ?? "").split(",").map((value) => value.trim()).includes(origin);
|
|
16001
|
+
}
|
|
16002
|
+
|
|
16003
|
+
// apps/api/src/identity-integration.ts
|
|
16004
|
+
async function identityIntegrationRequest(request, env, participant) {
|
|
16005
|
+
const path = new URL(request.url).pathname;
|
|
16006
|
+
const key = request.headers.get("X-Relay-Integration-Key");
|
|
16007
|
+
const exchange = path === "/v1/auth/exchange" && !(env.LOCAL_DEVELOPMENT === "true" && ["localhost", "127.0.0.1", "[::1]"].includes(
|
|
16008
|
+
new URL(request.url).hostname
|
|
16009
|
+
) && !request.headers.get("Authorization")?.startsWith("Bearer di_"));
|
|
16010
|
+
if (!exchange && !key) return null;
|
|
16011
|
+
try {
|
|
16012
|
+
const auth = env.AUTH.getByName("auth-v1");
|
|
16013
|
+
if (exchange) {
|
|
16014
|
+
if (request.method !== "POST")
|
|
16015
|
+
return Response.json(
|
|
16016
|
+
{ error: "Use POST for identity exchange" },
|
|
16017
|
+
{ status: 405 }
|
|
16018
|
+
);
|
|
16019
|
+
const result = await auth.exchangeParticipant(
|
|
16020
|
+
request.headers.get("Authorization")?.replace(/^Bearer /, "") ?? "",
|
|
16021
|
+
participantExchangeSchema.parse(await request.json())
|
|
16022
|
+
);
|
|
16023
|
+
if (result.kind === "denied")
|
|
16024
|
+
throw new AccessError(
|
|
16025
|
+
"Use a valid identity integration server key from Console Settings. CLI and management credentials cannot issue participant sessions.",
|
|
16026
|
+
401
|
|
16027
|
+
);
|
|
16028
|
+
if (result.kind === "limited")
|
|
16029
|
+
throw new AccessError(
|
|
16030
|
+
"Too many identity exchange requests. Retry shortly.",
|
|
16031
|
+
429
|
|
16032
|
+
);
|
|
16033
|
+
return Response.json(result.result);
|
|
16034
|
+
}
|
|
16035
|
+
const integration = await auth.verifyIntegration(key ?? "");
|
|
16036
|
+
if (!integration)
|
|
16037
|
+
throw new AccessError(
|
|
16038
|
+
"Identity integration key is invalid, expired, or revoked",
|
|
16039
|
+
401
|
|
16040
|
+
);
|
|
16041
|
+
if (!/^\/v1\/(?:auth\/(?:session|logout|connections)|me\/(?:progress|experience|attempts|evidence|pass|collection-pass|wallet(?:\/challenge|\/verify)?)|attempts\/[\w-]+(?:\/retry)?)$/.test(
|
|
16042
|
+
path
|
|
16043
|
+
))
|
|
16044
|
+
return Response.json(
|
|
16045
|
+
{ error: "Route is not available through an identity integration" },
|
|
16046
|
+
{ status: 404 }
|
|
16047
|
+
);
|
|
16048
|
+
if (request.headers.get("Origin") !== integration.origin)
|
|
16049
|
+
throw new AccessError(
|
|
16050
|
+
"Application origin does not match the identity integration",
|
|
16051
|
+
403
|
|
16052
|
+
);
|
|
16053
|
+
const session = await auth.integrationSession(
|
|
16054
|
+
sessionToken(request),
|
|
16055
|
+
integration.id
|
|
16056
|
+
);
|
|
16057
|
+
if (!session)
|
|
16058
|
+
throw new AccessError(
|
|
16059
|
+
"Participant session does not belong to this identity integration",
|
|
16060
|
+
401
|
|
16061
|
+
);
|
|
16062
|
+
const headers = new Headers(request.headers);
|
|
16063
|
+
headers.delete("X-Relay-Integration-Key");
|
|
16064
|
+
return participant(
|
|
16065
|
+
new Request(request, { headers }),
|
|
16066
|
+
{
|
|
16067
|
+
...env,
|
|
16068
|
+
LOCAL_DEVELOPMENT: "false",
|
|
16069
|
+
TEST_HOOKS: "false",
|
|
16070
|
+
DEMO_AUTH: "false",
|
|
16071
|
+
AUTH_EMULATORS: void 0,
|
|
16072
|
+
API_TOKEN: void 0,
|
|
16073
|
+
AUTH_ORGANIZATION: integration.organization,
|
|
16074
|
+
AUTH_PROJECT: integration.project,
|
|
16075
|
+
AUTH_ENVIRONMENT: integration.environment,
|
|
16076
|
+
AUTH_ORIGINS: integration.origin
|
|
16077
|
+
},
|
|
16078
|
+
integration.id
|
|
16079
|
+
);
|
|
16080
|
+
} catch (error48) {
|
|
16081
|
+
if (error48 instanceof external_exports.ZodError || error48 instanceof SyntaxError)
|
|
16082
|
+
return Response.json(
|
|
16083
|
+
{
|
|
16084
|
+
code: "INVALID_IDENTITY_EXCHANGE",
|
|
16085
|
+
error: "Supply only a verified subject and optional previousToken"
|
|
16086
|
+
},
|
|
16087
|
+
{ status: 400 }
|
|
16088
|
+
);
|
|
16089
|
+
if (error48 instanceof AccessError)
|
|
16090
|
+
return Response.json(
|
|
16091
|
+
{ code: "IDENTITY_INTEGRATION_ACCESS_DENIED", error: error48.message },
|
|
16092
|
+
{ status: error48.status }
|
|
16093
|
+
);
|
|
16094
|
+
throw error48;
|
|
16095
|
+
}
|
|
16096
|
+
}
|
|
16097
|
+
|
|
15922
16098
|
// packages/sdk/dist/portal-proxy.js
|
|
16099
|
+
init_chunk_6IXQRMGW();
|
|
16100
|
+
init_chunk_C2KOMNLG();
|
|
15923
16101
|
async function proxyParticipant(request, upstream) {
|
|
15924
16102
|
const incoming = new URL(request.url);
|
|
15925
16103
|
const path = incoming.pathname.slice("/relay".length);
|
|
@@ -16178,7 +16356,7 @@ function previewConfigurationIssues(env) {
|
|
|
16178
16356
|
}
|
|
16179
16357
|
|
|
16180
16358
|
// apps/api/src/preview-session.ts
|
|
16181
|
-
var
|
|
16359
|
+
var sessionSchema2 = external_exports.object({
|
|
16182
16360
|
organization: external_exports.string(),
|
|
16183
16361
|
project: external_exports.string(),
|
|
16184
16362
|
actor: external_exports.string(),
|
|
@@ -16192,7 +16370,7 @@ var leaseMs = 9e4;
|
|
|
16192
16370
|
var PreviewSession = class extends DurableObject {
|
|
16193
16371
|
async read() {
|
|
16194
16372
|
const value = await this.ctx.storage.get("session");
|
|
16195
|
-
return value ?
|
|
16373
|
+
return value ? sessionSchema2.parse(value) : null;
|
|
16196
16374
|
}
|
|
16197
16375
|
async resolve() {
|
|
16198
16376
|
const session = await this.read();
|
|
@@ -16378,6 +16556,10 @@ var developmentPreflightSchema = external_exports.object({
|
|
|
16378
16556
|
organization: external_exports.string(),
|
|
16379
16557
|
project: external_exports.string(),
|
|
16380
16558
|
environment: external_exports.enum(["test", "live"]),
|
|
16559
|
+
identity: external_exports.object({
|
|
16560
|
+
exchange: external_exports.literal("supported"),
|
|
16561
|
+
activeIntegrations: external_exports.number().int().nonnegative()
|
|
16562
|
+
}).optional(),
|
|
16381
16563
|
staging: external_exports.enum(["configured", "blocked"]),
|
|
16382
16564
|
development: external_exports.object({
|
|
16383
16565
|
status: external_exports.enum(["configured", "blocked"]),
|
|
@@ -17568,36 +17750,6 @@ function pageQuery(params) {
|
|
|
17568
17750
|
return entries;
|
|
17569
17751
|
}
|
|
17570
17752
|
|
|
17571
|
-
// apps/api/src/auth-utils.ts
|
|
17572
|
-
function cookie(request, name) {
|
|
17573
|
-
return request.headers.get("Cookie")?.split(";").map((value) => value.trim()).find((value) => value.startsWith(name + "="))?.slice(name.length + 1) ?? "";
|
|
17574
|
-
}
|
|
17575
|
-
function bindingCookie(value, secure, name = "relay_auth_flow") {
|
|
17576
|
-
return `${name}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${value ? 600 : 0}${secure ? "; Secure" : ""}`;
|
|
17577
|
-
}
|
|
17578
|
-
async function hash2(value) {
|
|
17579
|
-
const bytes = await crypto.subtle.digest(
|
|
17580
|
-
"SHA-256",
|
|
17581
|
-
new TextEncoder().encode(value)
|
|
17582
|
-
);
|
|
17583
|
-
return Array.from(
|
|
17584
|
-
new Uint8Array(bytes),
|
|
17585
|
-
(b) => b.toString(16).padStart(2, "0")
|
|
17586
|
-
).join("");
|
|
17587
|
-
}
|
|
17588
|
-
function sessionToken(request) {
|
|
17589
|
-
const bearer = request.headers.get("Authorization");
|
|
17590
|
-
if (bearer) return bearer.startsWith("Bearer ") ? bearer.slice(7) : "";
|
|
17591
|
-
return request.headers.get("Cookie")?.split(";").map((x) => x.trim()).find((x) => x.startsWith("relay_session="))?.slice("relay_session=".length) ?? "";
|
|
17592
|
-
}
|
|
17593
|
-
function sessionCookie(token, secure) {
|
|
17594
|
-
return `relay_session=${token}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${token ? 28800 : 0}${secure ? "; Secure" : ""}`;
|
|
17595
|
-
}
|
|
17596
|
-
function browserMutationAllowed(request, env) {
|
|
17597
|
-
const origin = request.headers.get("Origin");
|
|
17598
|
-
return request.headers.get("X-Relay-CSRF") === "1" && !!origin && (env.AUTH_ORIGINS ?? "").split(",").map((value) => value.trim()).includes(origin);
|
|
17599
|
-
}
|
|
17600
|
-
|
|
17601
17753
|
// node_modules/.pnpm/base-x@5.0.1/node_modules/base-x/src/esm/index.js
|
|
17602
17754
|
function base2(ALPHABET2) {
|
|
17603
17755
|
if (ALPHABET2.length >= 255) {
|
|
@@ -17737,7 +17889,7 @@ var esm_default2 = esm_default(ALPHABET);
|
|
|
17737
17889
|
init_zod();
|
|
17738
17890
|
init_dist();
|
|
17739
17891
|
var storedWalletChallenge = walletChallengeSchema.extend({
|
|
17740
|
-
session:
|
|
17892
|
+
session: sessionSchema,
|
|
17741
17893
|
origin: external_exports.string().url()
|
|
17742
17894
|
});
|
|
17743
17895
|
function solanaPublicKey(address) {
|
|
@@ -19757,6 +19909,9 @@ var OrganizationLedger = class extends DurableObject2 {
|
|
|
19757
19909
|
}
|
|
19758
19910
|
};
|
|
19759
19911
|
|
|
19912
|
+
// apps/api/src/auth.ts
|
|
19913
|
+
init_dist();
|
|
19914
|
+
|
|
19760
19915
|
// apps/api/src/account-profile.ts
|
|
19761
19916
|
init_zod();
|
|
19762
19917
|
|
|
@@ -20892,6 +21047,9 @@ var AuthStore = class extends DurableObject3 {
|
|
|
20892
21047
|
constructor(ctx, env) {
|
|
20893
21048
|
super(ctx, env);
|
|
20894
21049
|
ctx.storage.sql.exec(`CREATE TABLE IF NOT EXISTS identities (scope TEXT NOT NULL, issuer TEXT NOT NULL, subject TEXT NOT NULL, member TEXT NOT NULL, PRIMARY KEY(scope,issuer,subject));
|
|
21050
|
+
CREATE TABLE IF NOT EXISTS identity_integrations (id TEXT PRIMARY KEY, secret TEXT NOT NULL, data TEXT NOT NULL);
|
|
21051
|
+
CREATE TABLE IF NOT EXISTS integration_sessions (hash TEXT PRIMARY KEY, integration TEXT NOT NULL, subject TEXT NOT NULL);
|
|
21052
|
+
CREATE TABLE IF NOT EXISTS integration_audit (actor TEXT NOT NULL, action TEXT NOT NULL, integration TEXT NOT NULL, at INTEGER NOT NULL);
|
|
20895
21053
|
CREATE TABLE IF NOT EXISTS sessions (hash TEXT PRIMARY KEY, expires INTEGER NOT NULL, data TEXT NOT NULL);
|
|
20896
21054
|
CREATE TABLE IF NOT EXISTS auth_flows (id TEXT PRIMARY KEY, expires INTEGER NOT NULL, data TEXT NOT NULL);
|
|
20897
21055
|
CREATE TABLE IF NOT EXISTS connections (scope TEXT NOT NULL, issuer TEXT NOT NULL, subject TEXT NOT NULL, member TEXT NOT NULL, login INTEGER NOT NULL, provider TEXT NOT NULL, sealed TEXT NOT NULL, PRIMARY KEY(scope,issuer,subject));
|
|
@@ -20900,6 +21058,134 @@ var AuthStore = class extends DurableObject3 {
|
|
|
20900
21058
|
CREATE TABLE IF NOT EXISTS wallet_challenges (id TEXT PRIMARY KEY, expires INTEGER NOT NULL, data TEXT NOT NULL, result TEXT);
|
|
20901
21059
|
CREATE TABLE IF NOT EXISTS wallet_connections (scope TEXT NOT NULL, project TEXT NOT NULL, member TEXT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(scope,project,member));`);
|
|
20902
21060
|
}
|
|
21061
|
+
integrations(scope) {
|
|
21062
|
+
return this.ctx.storage.sql.exec("SELECT data FROM identity_integrations").toArray().map((row) => identityIntegrationSchema.parse(JSON.parse(row.data))).filter(
|
|
21063
|
+
(item) => item.organization === scope.organization && item.project === scope.project && item.environment === scope.environment
|
|
21064
|
+
);
|
|
21065
|
+
}
|
|
21066
|
+
async createIntegration(scope, input, actor) {
|
|
21067
|
+
const record2 = identityIntegrationSchema.parse({
|
|
21068
|
+
...authScopeSchema.parse(scope),
|
|
21069
|
+
...identityIntegrationInputSchema.parse(input),
|
|
21070
|
+
id: crypto.randomUUID(),
|
|
21071
|
+
expiresAt: Date.now() + 90 * 864e5
|
|
21072
|
+
});
|
|
21073
|
+
const token = "di_" + crypto.randomUUID() + crypto.randomUUID();
|
|
21074
|
+
const digest = await hash2(token);
|
|
21075
|
+
this.ctx.storage.transactionSync(() => {
|
|
21076
|
+
this.ctx.storage.sql.exec(
|
|
21077
|
+
"INSERT INTO identity_integrations VALUES(?,?,?)",
|
|
21078
|
+
record2.id,
|
|
21079
|
+
digest,
|
|
21080
|
+
JSON.stringify(record2)
|
|
21081
|
+
);
|
|
21082
|
+
this.ctx.storage.sql.exec(
|
|
21083
|
+
"INSERT INTO integration_audit VALUES(?,?,?,?)",
|
|
21084
|
+
actor,
|
|
21085
|
+
"created",
|
|
21086
|
+
record2.id,
|
|
21087
|
+
Date.now()
|
|
21088
|
+
);
|
|
21089
|
+
});
|
|
21090
|
+
return { ...record2, token };
|
|
21091
|
+
}
|
|
21092
|
+
async changeIntegration(scope, id2, actor, rotate) {
|
|
21093
|
+
const token = "di_" + crypto.randomUUID() + crypto.randomUUID();
|
|
21094
|
+
const digest = await hash2(token);
|
|
21095
|
+
return this.ctx.storage.transactionSync(() => {
|
|
21096
|
+
const record2 = this.integrations(scope).find((item) => item.id === id2);
|
|
21097
|
+
if (!record2) return null;
|
|
21098
|
+
this.ctx.storage.sql.exec(
|
|
21099
|
+
"INSERT INTO integration_audit VALUES(?,?,?,?)",
|
|
21100
|
+
actor,
|
|
21101
|
+
rotate ? "rotated" : "revoked",
|
|
21102
|
+
id2,
|
|
21103
|
+
Date.now()
|
|
21104
|
+
);
|
|
21105
|
+
if (rotate) {
|
|
21106
|
+
const next = { ...record2, expiresAt: Date.now() + 90 * 864e5 };
|
|
21107
|
+
this.ctx.storage.sql.exec(
|
|
21108
|
+
"UPDATE identity_integrations SET secret=?,data=? WHERE id=?",
|
|
21109
|
+
digest,
|
|
21110
|
+
JSON.stringify(next),
|
|
21111
|
+
id2
|
|
21112
|
+
);
|
|
21113
|
+
return { ...next, token };
|
|
21114
|
+
}
|
|
21115
|
+
this.ctx.storage.sql.exec(
|
|
21116
|
+
"DELETE FROM sessions WHERE hash IN (SELECT hash FROM integration_sessions WHERE integration=?)",
|
|
21117
|
+
id2
|
|
21118
|
+
);
|
|
21119
|
+
this.ctx.storage.sql.exec(
|
|
21120
|
+
"DELETE FROM integration_sessions WHERE integration=?",
|
|
21121
|
+
id2
|
|
21122
|
+
);
|
|
21123
|
+
this.ctx.storage.sql.exec(
|
|
21124
|
+
"DELETE FROM identity_integrations WHERE id=?",
|
|
21125
|
+
id2
|
|
21126
|
+
);
|
|
21127
|
+
return null;
|
|
21128
|
+
});
|
|
21129
|
+
}
|
|
21130
|
+
async verifyIntegration(token) {
|
|
21131
|
+
const row = this.ctx.storage.sql.exec(
|
|
21132
|
+
"SELECT data FROM identity_integrations WHERE secret=?",
|
|
21133
|
+
await hash2(token)
|
|
21134
|
+
).toArray()[0];
|
|
21135
|
+
const record2 = row ? identityIntegrationSchema.parse(JSON.parse(row.data)) : null;
|
|
21136
|
+
return record2 && record2.expiresAt > Date.now() ? record2 : null;
|
|
21137
|
+
}
|
|
21138
|
+
async integrationSession(token, id2, subject) {
|
|
21139
|
+
const digest = await hash2(token);
|
|
21140
|
+
const row = this.ctx.storage.sql.exec(
|
|
21141
|
+
"SELECT integration,subject FROM integration_sessions WHERE hash=?",
|
|
21142
|
+
digest
|
|
21143
|
+
).toArray()[0];
|
|
21144
|
+
if (!row || row.integration !== id2 || subject !== void 0 && row.subject !== subject)
|
|
21145
|
+
return null;
|
|
21146
|
+
return this.resolve(token, id2);
|
|
21147
|
+
}
|
|
21148
|
+
async exchangeParticipant(secret, value) {
|
|
21149
|
+
const input = participantExchangeSchema.parse(value);
|
|
21150
|
+
const record2 = await this.verifyIntegration(secret);
|
|
21151
|
+
if (!record2) return { kind: "denied" };
|
|
21152
|
+
if (input.previousToken) {
|
|
21153
|
+
const session = await this.integrationSession(
|
|
21154
|
+
input.previousToken,
|
|
21155
|
+
record2.id,
|
|
21156
|
+
input.subject
|
|
21157
|
+
);
|
|
21158
|
+
if (session)
|
|
21159
|
+
return {
|
|
21160
|
+
kind: "issued",
|
|
21161
|
+
result: { token: input.previousToken, session }
|
|
21162
|
+
};
|
|
21163
|
+
}
|
|
21164
|
+
if (!this.rateLimit("integration:" + record2.id, 600, 6e4))
|
|
21165
|
+
return { kind: "limited" };
|
|
21166
|
+
const result = await this.issue({
|
|
21167
|
+
organization: record2.organization,
|
|
21168
|
+
project: record2.project,
|
|
21169
|
+
environment: record2.environment,
|
|
21170
|
+
identity: { issuer: "app_" + record2.id, subject: input.subject },
|
|
21171
|
+
role: "member"
|
|
21172
|
+
});
|
|
21173
|
+
if (!await this.verifyIntegration(secret)) {
|
|
21174
|
+
await this.revoke(result.token);
|
|
21175
|
+
return { kind: "denied" };
|
|
21176
|
+
}
|
|
21177
|
+
const digest = await hash2(result.token);
|
|
21178
|
+
this.ctx.storage.sql.exec(
|
|
21179
|
+
"DELETE FROM integration_sessions WHERE hash NOT IN (SELECT hash FROM sessions)"
|
|
21180
|
+
);
|
|
21181
|
+
this.ctx.storage.sql.exec(
|
|
21182
|
+
"INSERT INTO integration_sessions VALUES(?,?,?)",
|
|
21183
|
+
digest,
|
|
21184
|
+
record2.id,
|
|
21185
|
+
input.subject
|
|
21186
|
+
);
|
|
21187
|
+
return { kind: "issued", result };
|
|
21188
|
+
}
|
|
20903
21189
|
walletConnection(session) {
|
|
20904
21190
|
if (session.principal.kind !== "member") return null;
|
|
20905
21191
|
const row = this.ctx.storage.sql.exec(
|
|
@@ -21198,7 +21484,7 @@ var AuthStore = class extends DurableObject3 {
|
|
|
21198
21484
|
id2,
|
|
21199
21485
|
Date.now()
|
|
21200
21486
|
).toArray()[0];
|
|
21201
|
-
return row ?
|
|
21487
|
+
return row ? sessionSchema.parse(JSON.parse(row.data)) : null;
|
|
21202
21488
|
}
|
|
21203
21489
|
linkAccount(session, issuer, subject, provider, sealed, login, profile) {
|
|
21204
21490
|
if (session.principal.kind !== "member")
|
|
@@ -21263,13 +21549,21 @@ var AuthStore = class extends DurableObject3 {
|
|
|
21263
21549
|
signInEnabled: !!row.login
|
|
21264
21550
|
}));
|
|
21265
21551
|
}
|
|
21266
|
-
async resolve(token) {
|
|
21552
|
+
async resolve(token, integrationId) {
|
|
21553
|
+
const digest = await hash2(token);
|
|
21267
21554
|
const row = this.ctx.storage.sql.exec(
|
|
21268
21555
|
"SELECT data FROM sessions WHERE hash=? AND expires>?",
|
|
21269
|
-
|
|
21556
|
+
digest,
|
|
21270
21557
|
Date.now()
|
|
21271
21558
|
).toArray()[0];
|
|
21272
|
-
|
|
21559
|
+
if (!row) return null;
|
|
21560
|
+
const binding = this.ctx.storage.sql.exec(
|
|
21561
|
+
"SELECT i.data,s.integration FROM integration_sessions s LEFT JOIN identity_integrations i ON i.id=s.integration WHERE s.hash=?",
|
|
21562
|
+
digest
|
|
21563
|
+
).toArray()[0];
|
|
21564
|
+
if (binding && (binding.integration !== integrationId || !binding.data || identityIntegrationSchema.parse(JSON.parse(binding.data)).expiresAt <= Date.now()))
|
|
21565
|
+
return null;
|
|
21566
|
+
return sessionSchema.parse(JSON.parse(row.data));
|
|
21273
21567
|
}
|
|
21274
21568
|
async revoke(token) {
|
|
21275
21569
|
this.ctx.storage.sql.exec(
|
|
@@ -21281,16 +21575,6 @@ var AuthStore = class extends DurableObject3 {
|
|
|
21281
21575
|
|
|
21282
21576
|
// apps/api/src/github-repositories.ts
|
|
21283
21577
|
init_zod();
|
|
21284
|
-
|
|
21285
|
-
// apps/api/src/access-error.ts
|
|
21286
|
-
var AccessError = class extends Error {
|
|
21287
|
-
constructor(message2, status = 403) {
|
|
21288
|
-
super(message2);
|
|
21289
|
-
this.status = status;
|
|
21290
|
-
}
|
|
21291
|
-
};
|
|
21292
|
-
|
|
21293
|
-
// apps/api/src/github-repositories.ts
|
|
21294
21578
|
var githubRepositorySchema = external_exports.object({
|
|
21295
21579
|
kind: external_exports.literal("github"),
|
|
21296
21580
|
owner: external_exports.string().regex(/^[A-Za-z0-9-]+$/),
|
|
@@ -22948,6 +23232,9 @@ function localParticipantRequest(request, env) {
|
|
|
22948
23232
|
return env.LOCAL_DEVELOPMENT === "true" && ["localhost", "127.0.0.1", "[::1]"].includes(new URL(request.url).hostname);
|
|
22949
23233
|
}
|
|
22950
23234
|
|
|
23235
|
+
// apps/api/src/management.ts
|
|
23236
|
+
init_dist();
|
|
23237
|
+
|
|
22951
23238
|
// apps/api/src/development-preflight.ts
|
|
22952
23239
|
function stagingConfigurationIssues(env) {
|
|
22953
23240
|
const required2 = {
|
|
@@ -32724,6 +33011,39 @@ async function managementRoutes(request, env) {
|
|
|
32724
33011
|
}
|
|
32725
33012
|
if (!organization || !(await store.projects(organization)).some((p) => p.project === project))
|
|
32726
33013
|
throw new AccessError("Project not found", 404);
|
|
33014
|
+
if (path === "/identity-integrations" || path.startsWith("/identity-integrations/")) {
|
|
33015
|
+
if (personal || cliSession || !admin)
|
|
33016
|
+
throw new AccessError(
|
|
33017
|
+
"An organization administrator must manage identity integrations in Console"
|
|
33018
|
+
);
|
|
33019
|
+
const auth = env.AUTH.getByName("auth-v1");
|
|
33020
|
+
const scope = { organization, project, environment };
|
|
33021
|
+
if (path === "/identity-integrations" && request.method === "GET")
|
|
33022
|
+
return respond(await auth.integrations(scope));
|
|
33023
|
+
if (path === "/identity-integrations" && request.method === "POST")
|
|
33024
|
+
return respond(
|
|
33025
|
+
await auth.createIntegration(
|
|
33026
|
+
scope,
|
|
33027
|
+
identityIntegrationInputSchema.parse(await request.json()),
|
|
33028
|
+
actor
|
|
33029
|
+
),
|
|
33030
|
+
201
|
|
33031
|
+
);
|
|
33032
|
+
const match2 = path.match(
|
|
33033
|
+
/^\/identity-integrations\/([\w-]+)(\/rotate)?$/
|
|
33034
|
+
);
|
|
33035
|
+
if (match2 && (match2[2] && request.method === "POST" || !match2[2] && request.method === "DELETE")) {
|
|
33036
|
+
return respond(
|
|
33037
|
+
await auth.changeIntegration(
|
|
33038
|
+
scope,
|
|
33039
|
+
external_exports.string().uuid().parse(match2[1]),
|
|
33040
|
+
actor,
|
|
33041
|
+
!!match2[2]
|
|
33042
|
+
)
|
|
33043
|
+
);
|
|
33044
|
+
}
|
|
33045
|
+
throw new AccessError("Identity integration route not found", 404);
|
|
33046
|
+
}
|
|
32727
33047
|
if (path === "/development/session" && ["POST", "PUT", "DELETE"].includes(request.method)) {
|
|
32728
33048
|
requirePermission("publish");
|
|
32729
33049
|
if (environment !== "test")
|
|
@@ -32832,11 +33152,22 @@ async function managementRoutes(request, env) {
|
|
|
32832
33152
|
message: repository?.status === "ready" ? "Hosted repository is ready." : "Create a hosted repository before staging."
|
|
32833
33153
|
}
|
|
32834
33154
|
];
|
|
33155
|
+
const integrations = await env.AUTH.getByName("auth-v1").integrations({
|
|
33156
|
+
organization,
|
|
33157
|
+
project,
|
|
33158
|
+
environment
|
|
33159
|
+
});
|
|
32835
33160
|
const developmentMissing = previewConfigurationIssues(env);
|
|
32836
33161
|
return respond({
|
|
32837
33162
|
organization,
|
|
32838
33163
|
project,
|
|
32839
33164
|
environment,
|
|
33165
|
+
identity: {
|
|
33166
|
+
exchange: "supported",
|
|
33167
|
+
activeIntegrations: integrations.filter(
|
|
33168
|
+
(item) => item.expiresAt > Date.now()
|
|
33169
|
+
).length
|
|
33170
|
+
},
|
|
32840
33171
|
development: {
|
|
32841
33172
|
status: developmentMissing.length || authIssues.length ? "blocked" : "configured",
|
|
32842
33173
|
missing: developmentMissing,
|
|
@@ -33831,7 +34162,7 @@ function authScope(env) {
|
|
|
33831
34162
|
// apps/api/src/oauth-routes.ts
|
|
33832
34163
|
var intentSchema = external_exports.discriminatedUnion("mode", [
|
|
33833
34164
|
external_exports.object({ mode: external_exports.literal("sign-in"), scope: authScopeSchema }),
|
|
33834
|
-
external_exports.object({ mode: external_exports.literal("connect"), session:
|
|
34165
|
+
external_exports.object({ mode: external_exports.literal("connect"), session: sessionSchema })
|
|
33835
34166
|
]);
|
|
33836
34167
|
var returnSchema = external_exports.object({
|
|
33837
34168
|
origin: external_exports.string().url(),
|
|
@@ -34221,7 +34552,7 @@ async function authRoutes(request, env, session) {
|
|
|
34221
34552
|
|
|
34222
34553
|
// apps/api/src/index.ts
|
|
34223
34554
|
var gateway = {
|
|
34224
|
-
async fetch(request, env) {
|
|
34555
|
+
async fetch(request, env, identityIntegration) {
|
|
34225
34556
|
const git = await gitGateway(request, env);
|
|
34226
34557
|
if (git) return git;
|
|
34227
34558
|
const device = await deviceRoutes(request, env);
|
|
@@ -34238,7 +34569,7 @@ var gateway = {
|
|
|
34238
34569
|
const url2 = new URL(request.url);
|
|
34239
34570
|
const local = localParticipantRequest(request, env);
|
|
34240
34571
|
if (!local) {
|
|
34241
|
-
const issues = productionParticipantIssues(env);
|
|
34572
|
+
const issues = identityIntegration ? [] : productionParticipantIssues(env);
|
|
34242
34573
|
if (issues.length)
|
|
34243
34574
|
return Response.json(
|
|
34244
34575
|
{ error: "Participant access is not configured for this deployment" },
|
|
@@ -34252,13 +34583,13 @@ var gateway = {
|
|
|
34252
34583
|
{ error: "Participant project has not been provisioned" },
|
|
34253
34584
|
{ status: 503 }
|
|
34254
34585
|
);
|
|
34255
|
-
if (url2.pathname === "/v1/auth/
|
|
34586
|
+
if (url2.pathname === "/v1/auth/demo")
|
|
34256
34587
|
return Response.json({ error: "Route not found" }, { status: 404 });
|
|
34257
34588
|
}
|
|
34258
34589
|
const auth = env.AUTH.getByName("auth-v1");
|
|
34259
34590
|
const token = sessionToken(request);
|
|
34260
34591
|
const management = local && !!env.API_TOKEN && request.headers.get("Authorization") === "Bearer " + env.API_TOKEN;
|
|
34261
|
-
const resolvedSession = management ? null : token ? await auth.resolve(token) : null;
|
|
34592
|
+
const resolvedSession = management ? null : token ? await auth.resolve(token, identityIntegration) : null;
|
|
34262
34593
|
const portalScope = authScope(env);
|
|
34263
34594
|
const session = resolvedSession && (!local || !request.headers.has("Authorization")) && (resolvedSession.organization !== portalScope.organization || resolvedSession.project !== portalScope.project || resolvedSession.environment !== portalScope.environment) ? null : resolvedSession;
|
|
34264
34595
|
if (!local && session && session.principal.kind !== "member")
|
|
@@ -34640,10 +34971,11 @@ var StagingGateway = class extends WorkerEntrypoint3 {
|
|
|
34640
34971
|
};
|
|
34641
34972
|
var index_default = {
|
|
34642
34973
|
async fetch(request, env) {
|
|
34643
|
-
const response = await
|
|
34974
|
+
const response = await identityIntegrationRequest(
|
|
34644
34975
|
request,
|
|
34645
|
-
|
|
34646
|
-
|
|
34976
|
+
env,
|
|
34977
|
+
(incoming, scoped, id2) => gateway.fetch(incoming, scoped, id2)
|
|
34978
|
+
) ?? await gateway.fetch(request, await callbackEnvironment(request, env));
|
|
34647
34979
|
const headers = new Headers(response.headers);
|
|
34648
34980
|
headers.set("Cache-Control", "no-store");
|
|
34649
34981
|
return new Response(response.body, { status: response.status, headers });
|