@domino-sdk/relay 0.14.1 → 0.16.1

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
@@ -50,8 +50,13 @@ import {
50
50
  walletChallengeInputSchema,
51
51
  walletChallengeSchema,
52
52
  walletConnectionSchema,
53
- walletProofSchema
54
- } from "./chunk-YZJOZL4V.js";
53
+ walletProofSchema,
54
+ xConnectionSchema,
55
+ xIdSchema,
56
+ xPostSchema,
57
+ xProfileSchema,
58
+ xRequestSchema
59
+ } from "./chunk-TI22MU2X.js";
55
60
  import {
56
61
  customSource,
57
62
  defineLeaderboard,
@@ -101,14 +106,14 @@ import {
101
106
  trackerSummarySchema,
102
107
  x,
103
108
  xTweetSchema
104
- } from "./chunk-CJARNIVP.js";
109
+ } from "./chunk-XNS25KST.js";
105
110
  import {
106
111
  authScopeSchema,
107
112
  exchangeResultSchema,
108
113
  exchangeSchema,
109
114
  principalSchema,
110
115
  sessionSchema
111
- } from "./chunk-I2CCMGN6.js";
116
+ } from "./chunk-GEJK7LMK.js";
112
117
  import {
113
118
  accountConnectionSchema,
114
119
  artifactSchema,
@@ -195,12 +200,22 @@ import {
195
200
  streak,
196
201
  streakPolicySchema,
197
202
  streakProgressSchema,
203
+ submissionEvidenceSchema,
198
204
  submitSchema,
199
205
  templateSchema,
206
+ textEvidenceSchema,
207
+ textOptionsSchema,
208
+ textResultSchema,
209
+ textReviewInputSchema,
200
210
  tierRewardSchema,
201
211
  tieredRewardDefinitionSchema,
202
- triggerSchema
203
- } from "./chunk-FUQYKTOJ.js";
212
+ triggerSchema,
213
+ urlEvidenceSchema,
214
+ urlOptionsSchema,
215
+ validateSubmissionValue,
216
+ valueEvidenceSchema,
217
+ xPostId
218
+ } from "./chunk-YUAE6PFY.js";
204
219
  export {
205
220
  QuestUpdatedError,
206
221
  RelayError,
@@ -371,8 +386,13 @@ export {
371
386
  streak,
372
387
  streakPolicySchema,
373
388
  streakProgressSchema,
389
+ submissionEvidenceSchema,
374
390
  submitSchema,
375
391
  templateSchema,
392
+ textEvidenceSchema,
393
+ textOptionsSchema,
394
+ textResultSchema,
395
+ textReviewInputSchema,
376
396
  tierRewardSchema,
377
397
  tieredRewardDefinitionSchema,
378
398
  trackerArtifactSchema,
@@ -391,10 +411,20 @@ export {
391
411
  trackerStatusSchema,
392
412
  trackerSummarySchema,
393
413
  triggerSchema,
414
+ urlEvidenceSchema,
415
+ urlOptionsSchema,
416
+ validateSubmissionValue,
417
+ valueEvidenceSchema,
394
418
  walletChallengeInputSchema,
395
419
  walletChallengeSchema,
396
420
  walletConnectionSchema,
397
421
  walletProofSchema,
398
422
  x,
423
+ xConnectionSchema,
424
+ xIdSchema,
425
+ xPostId,
426
+ xPostSchema,
427
+ xProfileSchema,
428
+ xRequestSchema,
399
429
  xTweetSchema
400
430
  };
@@ -24,5 +24,30 @@ declare function createParticipantBackend(options: {
24
24
  } | null>;
25
25
  fetch?: typeof fetch;
26
26
  }): (request: Request) => Promise<Response>;
27
+ /**
28
+ * The Worker variables `domino dev` sets for a locally running hosted app.
29
+ * Domino hosting sets none of them, so a deployed app uses `apiUrl` directly.
30
+ */
31
+ type HostedAppEnv = {
32
+ DOMINO_PARTICIPANT_API?: string;
33
+ DOMINO_PREVIEW_ORIGIN?: string;
34
+ DOMINO_LOCAL_API?: string;
35
+ DOMINO_DEV_CONTROL?: string;
36
+ };
37
+ /**
38
+ * The request as the participant sent it. The `domino dev` tunnel terminates
39
+ * HTTPS before the local Worker, so its URL is rebuilt on the preview origin.
40
+ * Call it first, before any routing, so every handler sees the public URL.
41
+ */
42
+ declare function hostedAppRequest(request: Request, env: HostedAppEnv): Request;
43
+ /**
44
+ * Answers the routes Domino owns in a hosted app: the participant proxy under
45
+ * `/relay/*`, and `domino dev` control routes under `/__domino/*`. Returns null
46
+ * for everything else, which belongs to the app.
47
+ */
48
+ declare function handleHostedApp(request: Request, env: HostedAppEnv, options: {
49
+ apiUrl: string;
50
+ fetch?: typeof fetch;
51
+ }): Promise<Response | null>;
27
52
 
28
- export { createParticipantBackend, proxyParticipant };
53
+ export { type HostedAppEnv, createParticipantBackend, handleHostedApp, hostedAppRequest, proxyParticipant };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  exchangeResultSchema
3
- } from "./chunk-I2CCMGN6.js";
4
- import "./chunk-FUQYKTOJ.js";
3
+ } from "./chunk-GEJK7LMK.js";
4
+ import "./chunk-YUAE6PFY.js";
5
5
 
6
6
  // src/portal-proxy.ts
7
7
  async function proxyParticipant(request, upstream) {
@@ -133,7 +133,50 @@ function createParticipantBackend(options) {
133
133
  return new Response(response.body, { status: response.status, headers });
134
134
  };
135
135
  }
136
+ function hostedAppRequest(request, env) {
137
+ if (!env.DOMINO_PREVIEW_ORIGIN) {
138
+ return request;
139
+ }
140
+ const url = new URL(request.url);
141
+ return new Request(
142
+ new URL(url.pathname + url.search, env.DOMINO_PREVIEW_ORIGIN),
143
+ request
144
+ );
145
+ }
146
+ async function handleHostedApp(request, env, options) {
147
+ const url = new URL(request.url);
148
+ const send = options.fetch ?? fetch;
149
+ if (env.DOMINO_DEV_CONTROL && url.pathname.startsWith("/__domino/")) {
150
+ return send(
151
+ new Request(
152
+ new URL(url.pathname + url.search, env.DOMINO_DEV_CONTROL),
153
+ request
154
+ )
155
+ );
156
+ }
157
+ if (!url.pathname.startsWith("/relay/")) {
158
+ return null;
159
+ }
160
+ if (env.DOMINO_LOCAL_API) {
161
+ return send(
162
+ new Request(
163
+ new URL(
164
+ url.pathname.slice("/relay".length) + url.search,
165
+ env.DOMINO_LOCAL_API
166
+ ),
167
+ request
168
+ )
169
+ );
170
+ }
171
+ return proxyParticipant(request, {
172
+ baseUrl: env.DOMINO_PARTICIPANT_API || options.apiUrl,
173
+ fetch: send,
174
+ hosted: true
175
+ });
176
+ }
136
177
  export {
137
178
  createParticipantBackend,
179
+ handleHostedApp,
180
+ hostedAppRequest,
138
181
  proxyParticipant
139
182
  };