@domino-sdk/relay 0.3.0 → 0.5.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 CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  identityIntegrationSecretSchema,
19
19
  interactionSchema,
20
20
  participantExchangeSchema,
21
+ projectCatalogArtifactSchema,
21
22
  projectDeploymentSchema,
22
23
  publishDeploymentSchema,
23
24
  publishQuestDraftSchema,
@@ -34,6 +35,7 @@ import {
34
35
  questTypeVersionSchema,
35
36
  questViewSchema,
36
37
  reconcileQuestDraft,
38
+ resourceId,
37
39
  saveQuestDraftSchema,
38
40
  solanaAddressSchema,
39
41
  solanaBalanceSchema,
@@ -41,28 +43,62 @@ import {
41
43
  walletChallengeSchema,
42
44
  walletConnectionSchema,
43
45
  walletProofSchema
44
- } from "./chunk-L757OYXZ.js";
46
+ } from "./chunk-LUCL63DS.js";
47
+ import {
48
+ defineLeaderboard,
49
+ defineReferral,
50
+ leaderboardArtifactSchema,
51
+ leaderboardDefinitionSchema,
52
+ leaderboardExclusionSchema,
53
+ leaderboardGroupSchema,
54
+ leaderboardPageSchema,
55
+ leaderboardPreviewSchema,
56
+ leaderboardQuerySchema,
57
+ leaderboardRowSchema,
58
+ leaderboardWindowSchema,
59
+ pointsAccountSchema,
60
+ pointsEntrySchema,
61
+ pointsMutationSchema,
62
+ pointsResultSchema,
63
+ publishedLeaderboardSchema,
64
+ publishedReferralSchema,
65
+ referralAcceptSchema,
66
+ referralAccountSchema,
67
+ referralArtifactSchema,
68
+ referralControlSchema,
69
+ referralDefinitionSchema,
70
+ referralHistorySchema,
71
+ referralManagementSchema,
72
+ referralRelationshipSchema,
73
+ referralSummarySchema
74
+ } from "./chunk-TXL43HL3.js";
45
75
  import {
46
76
  authScopeSchema,
47
77
  exchangeResultSchema,
48
78
  exchangeSchema,
49
79
  principalSchema,
50
80
  sessionSchema
51
- } from "./chunk-6IXQRMGW.js";
81
+ } from "./chunk-QWRSUSNB.js";
52
82
  import {
83
+ accountConnectionSchema,
53
84
  artifactSchema,
54
85
  attemptSchema,
86
+ authProviderSchema,
55
87
  batchReleaseSchema,
56
88
  beginHandoverSchema,
57
89
  completionRecordSchema,
58
90
  configurePickupSchema,
59
91
  confirmHandoverSchema,
60
92
  decisionSchema,
93
+ discordMemberInputSchema,
94
+ discordMemberSchema,
95
+ discordServerSchema,
61
96
  entitlementSchema,
62
97
  errorSchema,
63
98
  eventSchema,
64
99
  evidenceSchema,
65
100
  identifier,
101
+ integrationProviderSchema,
66
102
  mediaUrlSchema,
67
103
  memberListSchema,
68
104
  memberPageSchema,
@@ -76,6 +112,7 @@ import {
76
112
  pickupSelectionSchema,
77
113
  pointsRewardSchema,
78
114
  prerequisiteSchema,
115
+ projectIntegrationSchema,
79
116
  publishedReleaseSchema,
80
117
  questAvailabilitySchema,
81
118
  questDescriptionSchema,
@@ -108,12 +145,14 @@ import {
108
145
  tierRewardSchema,
109
146
  tieredRewardDefinitionSchema,
110
147
  triggerSchema
111
- } from "./chunk-C2KOMNLG.js";
148
+ } from "./chunk-3IQ4KUKF.js";
112
149
  export {
113
150
  QuestUpdatedError,
114
151
  RelayError,
152
+ accountConnectionSchema,
115
153
  artifactSchema,
116
154
  attemptSchema,
155
+ authProviderSchema,
117
156
  authScopeSchema,
118
157
  batchReleaseSchema,
119
158
  beginHandoverSchema,
@@ -131,8 +170,13 @@ export {
131
170
  confirmHandoverSchema,
132
171
  createRelayClient,
133
172
  decisionSchema,
173
+ defineLeaderboard,
174
+ defineReferral,
134
175
  deploymentPreviewSchema,
135
176
  deploymentResultSchema,
177
+ discordMemberInputSchema,
178
+ discordMemberSchema,
179
+ discordServerSchema,
136
180
  entitlementSchema,
137
181
  errorSchema,
138
182
  eventSchema,
@@ -143,7 +187,17 @@ export {
143
187
  identityIntegrationInputSchema,
144
188
  identityIntegrationSchema,
145
189
  identityIntegrationSecretSchema,
190
+ integrationProviderSchema,
146
191
  interactionSchema,
192
+ leaderboardArtifactSchema,
193
+ leaderboardDefinitionSchema,
194
+ leaderboardExclusionSchema,
195
+ leaderboardGroupSchema,
196
+ leaderboardPageSchema,
197
+ leaderboardPreviewSchema,
198
+ leaderboardQuerySchema,
199
+ leaderboardRowSchema,
200
+ leaderboardWindowSchema,
147
201
  mediaUrlSchema,
148
202
  memberListSchema,
149
203
  memberPageSchema,
@@ -156,12 +210,20 @@ export {
156
210
  pickupCatalogSchema,
157
211
  pickupPolicySchema,
158
212
  pickupSelectionSchema,
213
+ pointsAccountSchema,
214
+ pointsEntrySchema,
215
+ pointsMutationSchema,
216
+ pointsResultSchema,
159
217
  pointsRewardSchema,
160
218
  prerequisiteSchema,
161
219
  principalSchema,
220
+ projectCatalogArtifactSchema,
162
221
  projectDeploymentSchema,
222
+ projectIntegrationSchema,
163
223
  publishDeploymentSchema,
164
224
  publishQuestDraftSchema,
225
+ publishedLeaderboardSchema,
226
+ publishedReferralSchema,
165
227
  publishedReleaseSchema,
166
228
  questActions,
167
229
  questAvailabilitySchema,
@@ -186,8 +248,18 @@ export {
186
248
  quizQuestionSchema,
187
249
  quizQuestionsSchema,
188
250
  reconcileQuestDraft,
251
+ referralAcceptSchema,
252
+ referralAccountSchema,
253
+ referralArtifactSchema,
254
+ referralControlSchema,
255
+ referralDefinitionSchema,
256
+ referralHistorySchema,
257
+ referralManagementSchema,
258
+ referralRelationshipSchema,
259
+ referralSummarySchema,
189
260
  releaseSchema,
190
261
  reservationSchema,
262
+ resourceId,
191
263
  reviewItemSchema,
192
264
  reviewListSchema,
193
265
  reviewModeSchema,
@@ -2,11 +2,13 @@
2
2
  * Server-only proxy: browser cookies stay on the participant origin.
3
3
  * Point upstream at a participant deployment with trusted server scope configured.
4
4
  * Browser Authorization and organization/project/environment selectors are discarded.
5
- * This does not provide backend identity exchange or configure upstream scope.
5
+ * Set hosted: true for the shared API to resolve a registered preview/staging origin.
6
+ * This does not provide backend identity exchange.
6
7
  */
7
8
  declare function proxyParticipant(request: Request, upstream: {
8
9
  baseUrl: string;
9
10
  fetch: typeof fetch;
11
+ hosted?: boolean;
10
12
  }): Promise<Response>;
11
13
  /** Use only in an app server route. authenticate must verify the app's own session. */
12
14
  declare function createParticipantBackend(options: {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  exchangeResultSchema
3
- } from "./chunk-6IXQRMGW.js";
4
- import "./chunk-C2KOMNLG.js";
3
+ } from "./chunk-QWRSUSNB.js";
4
+ import "./chunk-3IQ4KUKF.js";
5
5
 
6
6
  // src/portal-proxy.ts
7
7
  async function proxyParticipant(request, upstream) {
8
8
  const incoming = new URL(request.url);
9
9
  const path = incoming.pathname.slice("/relay".length);
10
- const allowed = incoming.pathname.startsWith("/relay/") && (/^\/v1\/auth\/(providers|connections|start|authorize|complete|session|logout|email\/start|email\/verify|callback\/(google|apple|x|discord))$/.test(
10
+ const allowed = incoming.pathname.startsWith("/relay/") && (/^\/v1\/auth\/(providers|connections|accounts(?:\/disconnect)?|start|authorize|complete|session|logout|email\/start|email\/verify|callback\/[a-z][a-z0-9-]*)$/.test(
11
11
  path
12
12
  ) || /^\/v1\/me\/(progress|experience|attempts|evidence|pass|collection-pass|wallet(?:\/challenge|\/verify)?)$/.test(
13
13
  path
14
- ) || /^\/v1\/attempts\/[\w-]+(?:\/retry)?$/.test(path));
14
+ ) || /^\/v1\/attempts\/[\w-]+(?:\/retry)?$/.test(path) || /^\/v1\/referrals(?:\/(me|history))?$/.test(path) && request.method === "GET" || path === "/v1/referrals/accept" && request.method === "POST" || request.method === "GET" && /^\/v1\/leaderboards(?:\/[\w-]+)?$/.test(path));
15
15
  if (!allowed || !["GET", "POST"].includes(request.method))
16
16
  return Response.json({ error: "Route not found" }, { status: 404 });
17
17
  const target = new URL(upstream.baseUrl);
@@ -35,7 +35,9 @@ async function proxyParticipant(request, upstream) {
35
35
  const value = request.headers.get(name);
36
36
  if (value) headers.set(name, value);
37
37
  }
38
- const response = await upstream.fetch(target, {
38
+ if (upstream.hosted) headers.set("X-Relay-App-Origin", incoming.origin);
39
+ const send = upstream.fetch;
40
+ const response = await send(target, {
39
41
  method: request.method,
40
42
  headers,
41
43
  body: request.method === "GET" ? void 0 : await request.arrayBuffer(),
@@ -60,7 +62,7 @@ function createParticipantBackend(options) {
60
62
  "Use an identity integration server key from Console Settings"
61
63
  );
62
64
  const send = options.fetch ?? fetch;
63
- const cookie = (token) => `domino_app_session=${token}; Path=/relay; HttpOnly; Secure; SameSite=Strict; Max-Age=${token ? 28800 : 0}`;
65
+ const cookie = (token) => `domino_app_session=${token}; Path=/relay; HttpOnly; Secure; SameSite=Lax; Max-Age=${token ? 28800 : 0}`;
64
66
  return async (request) => {
65
67
  const url = new URL(request.url);
66
68
  const reject = (error, status) => Response.json(
@@ -83,7 +85,7 @@ function createParticipantBackend(options) {
83
85
  const previousToken = request.headers.get("Cookie")?.split(";").map((value) => value.trim()).find((value) => value.startsWith("domino_app_session="))?.slice("domino_app_session=".length);
84
86
  const exchanged = await send(options.baseUrl + "/v1/auth/exchange", {
85
87
  method: "POST",
86
- redirect: "error",
88
+ redirect: "manual",
87
89
  headers: {
88
90
  Authorization: "Bearer " + options.integrationKey,
89
91
  "Content-Type": "application/json"
@@ -101,14 +103,16 @@ function createParticipantBackend(options) {
101
103
  fetch: async (target, init) => {
102
104
  const headers2 = new Headers(init?.headers);
103
105
  headers2.delete("Cookie");
106
+ const returnBinding = request.headers.get("Cookie")?.split(";").map((value) => value.trim()).find((value) => value.startsWith("relay_auth_return="));
107
+ if (returnBinding) headers2.set("Cookie", returnBinding);
104
108
  headers2.set("Authorization", "Bearer " + token);
105
109
  headers2.set("X-Relay-Integration-Key", options.integrationKey);
106
110
  headers2.set("Origin", options.origin);
107
- return send(target, { ...init, headers: headers2, redirect: "error" });
111
+ return send(target, { ...init, headers: headers2, redirect: "manual" });
108
112
  }
109
113
  });
110
114
  const headers = new Headers(response.headers);
111
- headers.set(
115
+ headers.append(
112
116
  "Set-Cookie",
113
117
  cookie(url.pathname === "/relay/v1/auth/logout" ? "" : token)
114
118
  );
package/dist/schema.d.ts CHANGED
@@ -219,6 +219,9 @@ declare const questDescriptionSchema: z.ZodObject<{
219
219
  }, z.core.$strict>>;
220
220
  }, z.core.$strict>>;
221
221
  }, z.core.$strict>>;
222
+ integrations: z.ZodDefault<z.ZodArray<z.ZodEnum<{
223
+ discord: "discord";
224
+ }>>>;
222
225
  fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
223
226
  kind: z.ZodLiteral<"quiz">;
224
227
  default: z.ZodArray<z.ZodObject<{
@@ -401,6 +404,9 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
401
404
  }, z.core.$strict>>;
402
405
  }, z.core.$strict>>;
403
406
  }, z.core.$strict>>;
407
+ integrations: z.ZodDefault<z.ZodArray<z.ZodEnum<{
408
+ discord: "discord";
409
+ }>>>;
404
410
  fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
405
411
  kind: z.ZodLiteral<"quiz">;
406
412
  default: z.ZodArray<z.ZodObject<{
@@ -595,6 +601,7 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
595
601
  } | undefined;
596
602
  } | undefined;
597
603
  };
604
+ integrations: "discord"[];
598
605
  fields: Record<string, {
599
606
  kind: "quiz";
600
607
  default: {
@@ -770,6 +777,9 @@ declare const templateSchema: z.ZodObject<{
770
777
  }, z.core.$strict>>;
771
778
  }, z.core.$strict>>;
772
779
  }, z.core.$strict>>;
780
+ integrations: z.ZodDefault<z.ZodArray<z.ZodEnum<{
781
+ discord: "discord";
782
+ }>>>;
773
783
  fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
774
784
  kind: z.ZodLiteral<"quiz">;
775
785
  default: z.ZodArray<z.ZodObject<{
@@ -1179,6 +1189,12 @@ declare const memberProgressSchema: z.ZodObject<{
1179
1189
  }, z.core.$strict>>;
1180
1190
  }, z.core.$strict>>;
1181
1191
  }, z.core.$strict>>;
1192
+ connections: z.ZodDefault<z.ZodArray<z.ZodEnum<{
1193
+ discord: "discord";
1194
+ google: "google";
1195
+ apple: "apple";
1196
+ x: "x";
1197
+ }>>>;
1182
1198
  trigger: z.ZodUnion<readonly [z.ZodObject<{
1183
1199
  kind: z.ZodLiteral<"manual">;
1184
1200
  input: z.ZodEnum<{
@@ -1380,6 +1396,9 @@ declare const snapshotSchema: z.ZodObject<{
1380
1396
  }, z.core.$strict>>;
1381
1397
  }, z.core.$strict>>;
1382
1398
  }, z.core.$strict>>;
1399
+ integrations: z.ZodDefault<z.ZodArray<z.ZodEnum<{
1400
+ discord: "discord";
1401
+ }>>>;
1383
1402
  fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
1384
1403
  kind: z.ZodLiteral<"quiz">;
1385
1404
  default: z.ZodArray<z.ZodObject<{
@@ -1574,6 +1593,7 @@ declare const snapshotSchema: z.ZodObject<{
1574
1593
  } | undefined;
1575
1594
  } | undefined;
1576
1595
  };
1596
+ integrations: "discord"[];
1577
1597
  fields: Record<string, {
1578
1598
  kind: "quiz";
1579
1599
  default: {
package/dist/schema.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  tierRewardSchema,
49
49
  tieredRewardDefinitionSchema,
50
50
  triggerSchema
51
- } from "./chunk-C2KOMNLG.js";
51
+ } from "./chunk-3IQ4KUKF.js";
52
52
  export {
53
53
  artifactSchema,
54
54
  attemptSchema,