@domino-sdk/relay 1.24.1 → 1.30.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.
Files changed (58) hide show
  1. package/dist/{accounts-B31dWEYD.d.ts → accounts-DRPENuZe.d.ts} +1 -1
  2. package/dist/{attempt-captures-JDIgz2lY.d.ts → attempt-captures-nMDnKGdI.d.ts} +2 -2
  3. package/dist/authoring.d.ts +59 -60
  4. package/dist/authoring.js +7 -7
  5. package/dist/{automatic-outcomes-T9lEIvTj.d.ts → automatic-outcomes-CHiFP_U-.d.ts} +2 -2
  6. package/dist/avatar.d.ts +2 -2
  7. package/dist/browser.d.ts +10 -10
  8. package/dist/browser.js +10 -10
  9. package/dist/capability-error-FQGGb5xS.d.ts +71 -0
  10. package/dist/{chunk-UCZGXYCN.js → chunk-24BMKPCY.js} +10 -10
  11. package/dist/{chunk-MC6V6VMG.js → chunk-4OC7REYX.js} +1 -1
  12. package/dist/{chunk-JKFSDBQX.js → chunk-AOB3N4QO.js} +1 -1
  13. package/dist/{chunk-6UFXPKLA.js → chunk-BVEWY2ZL.js} +99 -39
  14. package/dist/{chunk-MRU7GX2V.js → chunk-C3KL5SGM.js} +21 -8
  15. package/dist/{chunk-WOGCRDFT.js → chunk-CCTZIHWN.js} +1 -1
  16. package/dist/{chunk-FE6SQTXF.js → chunk-CMGGWWH3.js} +2 -2
  17. package/dist/{chunk-G75JVB4D.js → chunk-DDA7G23P.js} +3 -3
  18. package/dist/{chunk-USVER53M.js → chunk-DP4YWFMY.js} +7 -0
  19. package/dist/{chunk-LR2HLHIF.js → chunk-FHOEVR3S.js} +595 -147
  20. package/dist/{chunk-B4EZ76WX.js → chunk-FPKBRUIC.js} +20 -3
  21. package/dist/{chunk-W33PYWYQ.js → chunk-JNBNL7FE.js} +2 -2
  22. package/dist/{chunk-AXQYGVOP.js → chunk-LPURBE7D.js} +1 -1
  23. package/dist/{chunk-GB26FIZT.js → chunk-MNL5NSC4.js} +8 -8
  24. package/dist/{chunk-FMQDD2MT.js → chunk-NFLNEKZ5.js} +47 -16
  25. package/dist/{chunk-ENBQ6UEE.js → chunk-P23AWV76.js} +3 -3
  26. package/dist/{chunk-JUQ2GNMD.js → chunk-PNCLJOUD.js} +2 -2
  27. package/dist/{chunk-E7MVYASS.js → chunk-W7PDXGYB.js} +1 -1
  28. package/dist/{client-HG0uMG0Q.d.ts → client-Ciy0g8Hx.d.ts} +123 -58
  29. package/dist/{deployments-DQY0PNUk.d.ts → deployments-V_BQ1PdE.d.ts} +184 -184
  30. package/dist/{groups-CfyRewkJ.d.ts → groups-sgKusEzF.d.ts} +26 -3
  31. package/dist/index.d.ts +13 -13
  32. package/dist/index.js +12 -10
  33. package/dist/{integrations-BMNtARU_.d.ts → integrations-CllF-kWg.d.ts} +1 -1
  34. package/dist/internal.d.ts +10 -10
  35. package/dist/internal.js +9 -9
  36. package/dist/{offers-CEwkAGsB.d.ts → offers-DzdzB2ZI.d.ts} +3 -3
  37. package/dist/{pages-D1xrbGJl.d.ts → pages-DFZThUH7.d.ts} +17 -3
  38. package/dist/{participant-activity-DYdUUhw2.d.ts → participant-activity-BPZiW7m7.d.ts} +1 -1
  39. package/dist/{participant-rewards-3duLb8YJ.d.ts → participant-rewards-BcWkBRn_.d.ts} +1 -1
  40. package/dist/portal-proxy.js +4 -4
  41. package/dist/{profiles-D29SS12z.d.ts → profiles-BHuQdzsW.d.ts} +1 -1
  42. package/dist/react/index.d.ts +13 -13
  43. package/dist/react/index.js +16 -15
  44. package/dist/{schema-D57mhL2q.d.ts → schema-DquhoBae.d.ts} +164 -2
  45. package/dist/schema.d.ts +441 -442
  46. package/dist/schema.js +30 -10
  47. package/dist/server/index.d.ts +10 -10
  48. package/dist/server/index.js +1001 -725
  49. package/dist/{streaks-CWyq8Px5.d.ts → streaks-0YuipsUQ.d.ts} +1 -1
  50. package/dist/{submission-input-DjXg0o-r.d.ts → submission-input-Dr0v6J9N.d.ts} +3 -3
  51. package/dist/{telegram-browser-DaP0Rawg.d.ts → telegram-browser-DJiawHY-.d.ts} +13 -5
  52. package/dist/testing.d.ts +8 -8
  53. package/dist/testing.js +15 -15
  54. package/dist/{transport-BNOvDy_4.d.ts → transport-BSGalAsT.d.ts} +6799 -3923
  55. package/dist/{wallet-CDyo-U4n.d.ts → wallet-t7uNDg9p.d.ts} +1 -1
  56. package/dist/{images-DwNmzqWv.d.ts → x-58jkoblN.d.ts} +100 -3
  57. package/package.json +1 -1
  58. package/dist/capability-error-oTd3eYFH.d.ts +0 -151
@@ -2,10 +2,10 @@ import {
2
2
  identifier,
3
3
  responseShape,
4
4
  xTweetSchema
5
- } from "./chunk-6UFXPKLA.js";
5
+ } from "./chunk-BVEWY2ZL.js";
6
6
 
7
7
  // src/x.ts
8
- import { z } from "zod";
8
+ import * as z from "zod";
9
9
  var xIdSchema = z.string().regex(/^[0-9]{1,20}$/);
10
10
  var xConnectionSchema = z.object({ userId: xIdSchema });
11
11
  var xProfileSchema = z.object({
@@ -17,6 +17,20 @@ var xProfileSchema = z.object({
17
17
  followersCount: z.number().int().nonnegative().nullable(),
18
18
  verified: z.boolean().nullable()
19
19
  });
20
+ var xUsernameSchema = z.string().trim().transform((value) => value.replace(/^@/, "")).pipe(
21
+ z.string().regex(
22
+ /^[A-Za-z0-9_]{1,15}$/,
23
+ "Use an X handle: 1 to 15 letters, digits or underscores"
24
+ )
25
+ );
26
+ var xUserLookupInputSchema = z.object({ username: xUsernameSchema }).strict();
27
+ var xUserSchema = z.object({
28
+ id: xIdSchema,
29
+ /** The handle as X shows it, without `@`. */
30
+ username: z.string(),
31
+ /** The display name. */
32
+ name: z.string()
33
+ });
20
34
  var xPostSchema = xTweetSchema.extend({
21
35
  quotedTweetId: xIdSchema.nullish().transform((v) => v ?? null),
22
36
  inReplyToUserId: xIdSchema.nullish().transform((v) => v ?? null),
@@ -40,7 +54,7 @@ var xRequestSchema = z.discriminatedUnion("operation", [
40
54
  ]);
41
55
 
42
56
  // src/images.ts
43
- import { z as z2 } from "zod";
57
+ import * as z2 from "zod";
44
58
  var imageReferenceSchema = z2.union([
45
59
  z2.strictObject({ evidence: z2.string().min(1).max(256) }),
46
60
  z2.strictObject({ x: z2.literal("profile") }),
@@ -167,6 +181,9 @@ export {
167
181
  xIdSchema,
168
182
  xConnectionSchema,
169
183
  xProfileSchema,
184
+ xUsernameSchema,
185
+ xUserLookupInputSchema,
186
+ xUserSchema,
170
187
  xPostSchema,
171
188
  xRequestSchema,
172
189
  imageReferenceSchema,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  accountConnectionSchema
3
- } from "./chunk-6UFXPKLA.js";
3
+ } from "./chunk-BVEWY2ZL.js";
4
4
 
5
5
  // src/telegram.ts
6
- import { z } from "zod";
6
+ import * as z from "zod";
7
7
  var telegramSignInMethodsSchema = z.object({
8
8
  /** Telegram Login, the OpenID Connect sign-in Domino configures for the platform. */
9
9
  login: z.boolean(),
@@ -5,7 +5,7 @@ import {
5
5
  isKnownTrackerSource,
6
6
  trackerDataSchema,
7
7
  xAccountRoles
8
- } from "./chunk-6UFXPKLA.js";
8
+ } from "./chunk-BVEWY2ZL.js";
9
9
 
10
10
  // src/quest-shape.ts
11
11
  function validateQuestShape(description, options = {}) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  badgeSchema,
3
3
  pointLedgerReferenceSchema
4
- } from "./chunk-MRU7GX2V.js";
4
+ } from "./chunk-C3KL5SGM.js";
5
5
  import {
6
6
  authoringIdentityShape,
7
7
  entitlementSchema,
@@ -20,10 +20,10 @@ import {
20
20
  storedQuestDescriptionSchema,
21
21
  storedReviewModeSchema,
22
22
  tieredRewardReferenceSchema
23
- } from "./chunk-6UFXPKLA.js";
23
+ } from "./chunk-BVEWY2ZL.js";
24
24
 
25
25
  // src/participant-activity.ts
26
- import { z } from "zod";
26
+ import * as z from "zod";
27
27
  var base = { id: z.string(), at: z.number() };
28
28
  var attempt = {
29
29
  ...base,
@@ -106,7 +106,7 @@ var participantActivitySchema = z.object({
106
106
  });
107
107
 
108
108
  // src/catalog.ts
109
- import { z as z2 } from "zod";
109
+ import * as z2 from "zod";
110
110
  var interactionSchema = z2.enum([
111
111
  "photo",
112
112
  "text",
@@ -271,7 +271,7 @@ var allocateQuestSchema = z2.object({ actionId: identifier }).strict();
271
271
  var allocatedQuestSchema = z2.object({ id: identifier });
272
272
 
273
273
  // src/collection.ts
274
- import { z as z3 } from "zod";
274
+ import * as z3 from "zod";
275
275
  var collectionCodeSchema = z3.string().regex(/^relay:collect:[a-f0-9]{64}$/);
276
276
  var collectionPassSchema = z3.object({
277
277
  code: collectionCodeSchema,
@@ -291,7 +291,7 @@ var collectionPreviewSchema = z3.object({
291
291
  });
292
292
 
293
293
  // src/outcomes.ts
294
- import { z as z4 } from "zod";
294
+ import * as z4 from "zod";
295
295
  var timestamp = z4.number().int().safe().nonnegative();
296
296
  var questEnrollmentInputSchema = z4.strictObject({
297
297
  actionId: identifier,
@@ -362,7 +362,7 @@ var questOutcomePageSchema = z4.object({
362
362
  });
363
363
 
364
364
  // src/participant-rewards.ts
365
- import { z as z5 } from "zod";
365
+ import * as z5 from "zod";
366
366
  var participantEntitlementsSchema = z5.object({
367
367
  items: z5.array(entitlementSchema)
368
368
  });
@@ -413,7 +413,7 @@ var participantDeliveriesSchema = z5.object({
413
413
  });
414
414
 
415
415
  // src/reward-deliveries.ts
416
- import { z as z6 } from "zod";
416
+ import * as z6 from "zod";
417
417
  var RewardDeliveryAction = {
418
418
  /** Delivers a quest's Discord role reward. */
419
419
  GrantRole: "grant-role"
@@ -4,20 +4,20 @@ import {
4
4
  retryAfter,
5
5
  retrying,
6
6
  validTimeout
7
- } from "./chunk-WOGCRDFT.js";
7
+ } from "./chunk-CCTZIHWN.js";
8
8
  import {
9
9
  clientIdentity
10
- } from "./chunk-JKFSDBQX.js";
10
+ } from "./chunk-AOB3N4QO.js";
11
11
  import {
12
12
  authScopeSchema
13
- } from "./chunk-JUQ2GNMD.js";
13
+ } from "./chunk-PNCLJOUD.js";
14
14
  import {
15
15
  RequestError,
16
16
  appIdentityKindSchema,
17
17
  isRequestError,
18
18
  knownResponse,
19
19
  openIdentityKindSchema
20
- } from "./chunk-6UFXPKLA.js";
20
+ } from "./chunk-BVEWY2ZL.js";
21
21
 
22
22
  // src/configuration.ts
23
23
  function questConfiguration(release) {
@@ -34,7 +34,7 @@ function questConfiguration(release) {
34
34
  }
35
35
 
36
36
  // src/identity-integration.ts
37
- import { z } from "zod";
37
+ import * as z from "zod";
38
38
  var identityIntegrationInputSchema = z.object({
39
39
  name: z.string().trim().min(1).max(80),
40
40
  origin: z.string().url().refine((value) => {
@@ -102,7 +102,7 @@ var participantExchangeSchema = z.object({
102
102
  }).strict();
103
103
 
104
104
  // src/server/errors.ts
105
- import { z as z2 } from "zod";
105
+ import * as z2 from "zod";
106
106
  var ManagementErrorCode = {
107
107
  /** The input or an option failed validation before anything was sent (kind `client`). */
108
108
  InvalidInput: "invalid-input",
@@ -167,7 +167,7 @@ var ManagementError = class extends RequestError {
167
167
  var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
168
168
 
169
169
  // src/server/transport.ts
170
- import { z as z3 } from "zod";
170
+ import * as z3 from "zod";
171
171
  function failureCause(error) {
172
172
  if (typeof error !== "object" || error === null || !("cause" in error)) {
173
173
  return {};
@@ -199,6 +199,18 @@ function checkedTimeout(timeout) {
199
199
  }
200
200
  function managementTransport(options) {
201
201
  const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
202
+ try {
203
+ const headers = new Headers(options.headers);
204
+ headers.set("X-Relay-Organization", options.organization ?? "");
205
+ headers.set("X-Relay-Project", options.project ?? "");
206
+ } catch (error) {
207
+ throw new ManagementError({
208
+ kind: "client",
209
+ code: ManagementErrorCode.InvalidInput,
210
+ message: "Management headers, organization and project must be valid HTTP header values",
211
+ cause: error
212
+ });
213
+ }
202
214
  function callLifetime(call) {
203
215
  return lifetime(
204
216
  checkedTimeout(call?.timeout) ?? clientTimeout,
@@ -277,11 +289,27 @@ function managementTransport(options) {
277
289
  if (life.signal.aborted) {
278
290
  throw transportFailure(life.reason(), context, life, false);
279
291
  }
280
- const headers = new Headers(fetchInit.headers);
292
+ const headers = new Headers(options.headers);
293
+ new Headers(fetchInit.headers).forEach(
294
+ (value, name) => headers.set(name, value)
295
+ );
281
296
  headers.set("X-Domino-Client", options.client ?? clientIdentity());
282
297
  const token = await credential(context, life);
283
298
  if (token) {
284
- headers.set("Authorization", `Bearer ${token}`);
299
+ try {
300
+ headers.set("Authorization", `Bearer ${token}`);
301
+ } catch (error) {
302
+ throw new ManagementError({
303
+ ...context,
304
+ kind: "client",
305
+ code: ManagementErrorCode.Credential,
306
+ uncertain: false,
307
+ message: "getToken returned a value that is not a token",
308
+ cause: error
309
+ });
310
+ }
311
+ } else if (options.getToken) {
312
+ headers.delete("Authorization");
285
313
  }
286
314
  if (options.organization) {
287
315
  headers.set("X-Relay-Organization", options.organization);
@@ -294,12 +322,15 @@ function managementTransport(options) {
294
322
  }
295
323
  let response;
296
324
  try {
297
- response = await fetch(`${options.baseUrl}/management/v1${path}`, {
298
- ...fetchInit,
299
- headers,
300
- signal: life.signal,
301
- ...options.redirect ? { redirect: options.redirect } : {}
302
- });
325
+ response = await (options.fetch ?? fetch)(
326
+ `${options.baseUrl}/management/v1${path}`,
327
+ {
328
+ ...fetchInit,
329
+ headers,
330
+ signal: life.signal,
331
+ ...options.redirect ? { redirect: options.redirect } : {}
332
+ }
333
+ );
303
334
  } catch (error) {
304
335
  throw transportFailure(error, context, life, !unsent(error));
305
336
  }
@@ -442,7 +473,7 @@ function managementTransport(options) {
442
473
  }
443
474
 
444
475
  // src/sequence-cursor.ts
445
- import { z as z4 } from "zod";
476
+ import * as z4 from "zod";
446
477
  var sequenceCursorSchema = z4.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z4.number().int().positive().safe());
447
478
 
448
479
  // src/referral-reward-kinds.ts
@@ -4,13 +4,13 @@ import {
4
4
  imageFieldsSchema,
5
5
  imageInspectionSchema,
6
6
  imageSightingsSchema
7
- } from "./chunk-B4EZ76WX.js";
7
+ } from "./chunk-FPKBRUIC.js";
8
8
  import {
9
9
  photoResultSchema
10
- } from "./chunk-6UFXPKLA.js";
10
+ } from "./chunk-BVEWY2ZL.js";
11
11
 
12
12
  // src/image-results.ts
13
- import { z } from "zod";
13
+ import * as z from "zod";
14
14
  var invalid = (message, path) => new z.ZodError([{ code: "custom", message, path, input: void 0 }]);
15
15
  function parseImageExtraction(raw, value) {
16
16
  const result = imageExtractionSchema.parse(value);
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  identifier
3
- } from "./chunk-6UFXPKLA.js";
3
+ } from "./chunk-BVEWY2ZL.js";
4
4
 
5
5
  // src/auth.ts
6
- import { z } from "zod";
6
+ import * as z from "zod";
7
7
  var authScopeSchema = z.object({
8
8
  organization: identifier,
9
9
  project: identifier,
@@ -2,7 +2,7 @@ import {
2
2
  RelayErrorCode,
3
3
  clientError,
4
4
  isRequestError
5
- } from "./chunk-6UFXPKLA.js";
5
+ } from "./chunk-BVEWY2ZL.js";
6
6
 
7
7
  // src/action.ts
8
8
  function withActionId(value) {
@@ -1,13 +1,13 @@
1
- import { aZ as referralAcceptSchema, g as LeaderboardQuery, b as CampaignEnrollmentInput, d as CampaignWithdrawalInput, m as PointHistoryQuery, k as PointEntryKind, a6 as engagementPageQuerySchema } from './groups-CfyRewkJ.js';
2
- import { j as QuestView, k as ResponseSchema, a as PageQuery, c as QuestEnrollmentInput, Q as QuestClaimInput, g as QuestOutcomeQuery, _ as questExperienceSchema, l as RewardDeliveryAction, F as contentQualificationQuerySchema } from './pages-D1xrbGJl.js';
3
- import { M as MissingPrerequisite, V as ValueEvidence } from './submission-input-DjXg0o-r.js';
1
+ import { b0 as referralAcceptSchema, g as LeaderboardQuery, b as CampaignEnrollmentInput, d as CampaignWithdrawalInput, m as PointHistoryQuery, k as PointEntryKind, a7 as engagementPageQuerySchema } from './groups-sgKusEzF.js';
2
+ import { j as QuestView, k as ResponseSchema, a as PageQuery, c as QuestEnrollmentInput, Q as QuestClaimInput, g as QuestOutcomeQuery, $ as questExperienceSchema, l as RewardDeliveryAction, G as contentQualificationQuerySchema } from './pages-DFZThUH7.js';
3
+ import { M as MissingPrerequisite, V as ValueEvidence } from './submission-input-Dr0v6J9N.js';
4
4
  import { a as RequestError, b as RequestErrorDetails, c as RequestErrorKind, e as createRelayAction, O as OptionalActionId } from './action-DBzILFx9.js';
5
- import { f as QuizEvidence, A as Attempt, M as MemberProgress, a as AttemptStatus, h as TrackerSkipCode, cg as submitSchema, be as contentPerformanceQuerySchema } from './schema-D57mhL2q.js';
6
- import { b as ParticipantSession, d as exchangeSchema, R as RelayEvent, P as ParticipantActivity } from './participant-activity-DYdUUhw2.js';
7
- import { z } from 'zod';
8
- import { a as AuthProvider } from './accounts-B31dWEYD.js';
9
- import { F as profileUpdateSchema, c as ProfileCompletionQuery } from './profiles-D29SS12z.js';
10
- import { y as walletAddressInputSchema, I as walletSignatureSchema, L as LinkedWallet, f as WalletSigner } from './wallet-CDyo-U4n.js';
5
+ import { f as QuizEvidence, A as Attempt, M as MemberProgress, a as AttemptStatus, h as TrackerSkipCode, co as submitSchema, bj as contentPerformanceQuerySchema } from './schema-DquhoBae.js';
6
+ import { b as ParticipantSession, d as exchangeSchema, R as RelayEvent, P as ParticipantActivity } from './participant-activity-BPZiW7m7.js';
7
+ import * as z from 'zod';
8
+ import { a as AuthProvider } from './accounts-DRPENuZe.js';
9
+ import { F as profileUpdateSchema, c as ProfileCompletionQuery } from './profiles-BHuQdzsW.js';
10
+ import { y as walletAddressInputSchema, I as walletSignatureSchema, L as LinkedWallet, f as WalletSigner } from './wallet-t7uNDg9p.js';
11
11
 
12
12
  /** What happened, as in every Domino client error (see `RequestError`). */
13
13
  type RelayErrorKind = RequestErrorKind;
@@ -45,6 +45,11 @@ declare const RelayErrorCode: {
45
45
  readonly SubmissionStorageQuota: "submission-storage-quota";
46
46
  /** The saved submission is in a state that does not allow this action. */
47
47
  readonly SubmissionConflict: "submission-conflict";
48
+ /**
49
+ * The saved submission's operation belongs to a retired contract and cannot continue. Show the
50
+ * current quest and let the member `discard()` it before submitting again.
51
+ */
52
+ readonly OperationRetired: "operation-retired";
48
53
  /** The quest changed since the member saw it; review it before submitting again. */
49
54
  readonly QuestUpdated: "quest-updated";
50
55
  /** Wait for the deferred attempt before submitting another action. */
@@ -75,6 +80,8 @@ declare const RelayErrorCode: {
75
80
  readonly OfferOutOfStock: "offer-out-of-stock";
76
81
  /** The participant's available point balance is below the offer price. */
77
82
  readonly InsufficientPoints: "insufficient-points";
83
+ /** The client's `getToken` failed before anything was sent; `cause` is its own error. */
84
+ readonly Credential: "credential";
78
85
  /** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
79
86
  readonly WalletSigner: "wallet-signer";
80
87
  /** The member has not met the quest's prerequisites; `missing` lists them. */
@@ -135,27 +142,50 @@ type SubmissionStatus = {
135
142
  kind: "submitted";
136
143
  attempt: string;
137
144
  };
145
+ /**
146
+ * Cancellation and a deadline for one submission call, which may read the session, upload, claim
147
+ * and retry. A cancelled or timed-out call keeps its saved progress: `resume()` continues it, and
148
+ * a write already sent stays `uncertain`, as with any call.
149
+ *
150
+ * @compat input
151
+ */
152
+ type SubmissionCallOptions = {
153
+ /** Cancels the call, which rejects with a `RelayError` of kind `aborted`. */
154
+ signal?: AbortSignal;
155
+ /**
156
+ * The whole call's deadline in milliseconds, covering every request it sends. Without it each
157
+ * request has the client's `timeout`.
158
+ */
159
+ timeout?: number;
160
+ };
138
161
  type Handle = {
139
- status(): Promise<SubmissionStatus>;
140
- resume(): Promise<Attempt>;
141
- discard(): Promise<void>;
162
+ status(options?: SubmissionCallOptions): Promise<SubmissionStatus>;
163
+ resume(options?: SubmissionCallOptions): Promise<Attempt>;
164
+ discard(options?: SubmissionCallOptions): Promise<void>;
142
165
  };
166
+ /** @compat sealed */
143
167
  type PhotoSubmission = Handle & {
144
- submit(file: File): Promise<Attempt>;
168
+ submit(file: File, options?: SubmissionCallOptions): Promise<Attempt>;
145
169
  };
170
+ /** @compat sealed */
146
171
  type QuizSubmission = Handle & {
147
172
  submit(answers: QuizEvidence["answers"], options?: {
148
- release: string;
149
- }): Promise<Attempt>;
173
+ release?: string;
174
+ } & SubmissionCallOptions): Promise<Attempt>;
150
175
  };
176
+ /** @compat sealed */
151
177
  type ValueSubmission = Handle & {
152
- submit(value: string): Promise<Attempt>;
178
+ submit(value: string, options?: SubmissionCallOptions): Promise<Attempt>;
153
179
  };
180
+ /** @compat sealed */
154
181
  type ClaimSubmission = Handle & {
155
- submit(): Promise<Attempt>;
182
+ submit(options?: SubmissionCallOptions): Promise<Attempt>;
156
183
  };
157
- /** Stores structured-clone values. Writes must finish durably before resolving.
158
- * exclusive must serialize all writers to a key, including across browser tabs. */
184
+ /**
185
+ * Stores structured-clone values. Writes must finish durably before resolving. exclusive must
186
+ * serialize all writers to a key, including across browser tabs. Since Relay keeps submissions,
187
+ * the SDK only reads it to finish a submission an older SDK version saved.
188
+ */
159
189
  interface SubmissionStore {
160
190
  read(key: string): Promise<unknown>;
161
191
  write(key: string, value: unknown): Promise<void>;
@@ -190,26 +220,27 @@ type QuestActionResult = {
190
220
  originalDraft: SubmissionDraft | null;
191
221
  draft: SubmissionDraft | null;
192
222
  };
223
+ /** Each method takes `signal` and `timeout` for the whole call, as a submission handle does. */
193
224
  type ActiveController = {
194
225
  view: QuestView;
195
- status(): Promise<SubmissionStatus>;
196
- resume(): Promise<QuestActionResult>;
197
- discard(): Promise<void>;
226
+ status(options?: SubmissionCallOptions): Promise<SubmissionStatus>;
227
+ resume(options?: SubmissionCallOptions): Promise<QuestActionResult>;
228
+ discard(options?: SubmissionCallOptions): Promise<void>;
198
229
  };
199
230
  type QuestController = (ActiveController & {
200
231
  kind: "text" | "url";
201
- submit(value: string): Promise<QuestActionResult>;
232
+ submit(value: string, options?: SubmissionCallOptions): Promise<QuestActionResult>;
202
233
  }) | (ActiveController & {
203
234
  kind: "status";
204
235
  }) | (ActiveController & {
205
236
  kind: "photo";
206
- submit(file: File): Promise<QuestActionResult>;
237
+ submit(file: File, options?: SubmissionCallOptions): Promise<QuestActionResult>;
207
238
  }) | (ActiveController & {
208
239
  kind: "quiz";
209
- submit(answers: Record<string, string>): Promise<QuestActionResult>;
240
+ submit(answers: Record<string, string>, options?: SubmissionCallOptions): Promise<QuestActionResult>;
210
241
  }) | (ActiveController & {
211
242
  kind: "claim";
212
- submit(): Promise<QuestActionResult>;
243
+ submit(options?: SubmissionCallOptions): Promise<QuestActionResult>;
213
244
  });
214
245
 
215
246
  type ProgressObservation<T = MemberProgress> = {
@@ -256,7 +287,24 @@ type RelayRequestOptions = {
256
287
  /** @compat input */
257
288
  type RelayClientOptions = {
258
289
  baseUrl: string;
290
+ /** A bearer token sent with every call. Use `getToken` instead for one that changes. */
259
291
  token?: string;
292
+ /**
293
+ * Reads the bearer token before each attempt, within the call's deadline and signal; `null`
294
+ * sends none. A failure rejects the call with a `client` `RelayError` (kind `network` for a
295
+ * `TypeError`) whose code is `credential`, before anything is sent. Not with `token`.
296
+ */
297
+ getToken?: () => Promise<string | null>;
298
+ /**
299
+ * The `fetch` every call sends with, such as a test double, a proxy's or an edge runtime's own.
300
+ * Defaults to the global `fetch`.
301
+ */
302
+ fetch?: typeof fetch;
303
+ /**
304
+ * Headers sent with every call. The client's own headers (authorization, scope, session, CSRF
305
+ * and content type) replace one of the same name.
306
+ */
307
+ headers?: Record<string, string>;
260
308
  submissionStore?: SubmissionStore;
261
309
  organization?: string;
262
310
  project?: string;
@@ -267,6 +315,25 @@ type RelayClientOptions = {
267
315
  */
268
316
  timeout?: number;
269
317
  };
318
+ /**
319
+ * What `auth.start` takes: the provider, and whether to sign in (or sign up) or link it to the
320
+ * signed-in member.
321
+ *
322
+ * @compat input
323
+ */
324
+ type AuthStartInput = {
325
+ provider: AuthProvider;
326
+ mode: "sign-in" | "connect";
327
+ };
328
+ /**
329
+ * What `auth.emailVerify` takes: `emailStart`'s challenge and the code the member typed.
330
+ *
331
+ * @compat input
332
+ */
333
+ type EmailVerification = {
334
+ challenge: string;
335
+ code: string;
336
+ };
270
337
  /** @compat input */
271
338
  type RelayResponseOptions = RelayRequestOptions & {
272
339
  method?: "GET" | "POST";
@@ -338,7 +405,7 @@ declare function relayClient(options: RelayClientOptions): {
338
405
  key?: string | undefined;
339
406
  }[]>;
340
407
  /** Redeems one offer. Persist `actionId` to retry after an uncertain result. */
341
- redeem: (offer: string, input?: {
408
+ redeem: (offer: string, value?: {
342
409
  actionId?: string;
343
410
  }, requestOptions?: RelayRequestOptions) => Promise<{
344
411
  status: "fulfilled";
@@ -3397,31 +3464,21 @@ declare function relayClient(options: RelayClientOptions): {
3397
3464
  miniApp: boolean;
3398
3465
  } | undefined;
3399
3466
  }>;
3400
- start: (provider: AuthProvider, mode: "sign-in" | "connect", requestOptions?: RelayRequestOptions) => Promise<{
3401
- url: string;
3402
- }>;
3467
+ start: {
3468
+ (start: AuthStartInput, requestOptions?: RelayRequestOptions): Promise<{
3469
+ url: string;
3470
+ }>;
3471
+ (provider: AuthProvider, mode: "sign-in" | "connect", requestOptions?: RelayRequestOptions): Promise<{
3472
+ url: string;
3473
+ }>;
3474
+ };
3403
3475
  emailStart: (email: string, requestOptions?: RelayRequestOptions) => Promise<{
3404
3476
  challenge: string;
3405
3477
  }>;
3406
- emailVerify: (challenge: string, code: string, requestOptions?: RelayRequestOptions) => Promise<{
3407
- id: string;
3408
- principal: {
3409
- kind: "member";
3410
- member: string;
3411
- } | {
3412
- kind: "staff";
3413
- subject: string;
3414
- } | {
3415
- kind: "operator";
3416
- subject: string;
3417
- } | {
3418
- kind: string;
3419
- };
3420
- expiresAt: number;
3421
- organization: string;
3422
- project: string;
3423
- environment: "test" | "live";
3424
- }>;
3478
+ emailVerify: {
3479
+ (verification: EmailVerification, requestOptions?: RelayRequestOptions): Promise<ParticipantSession>;
3480
+ (challenge: string, code: string, requestOptions?: RelayRequestOptions): Promise<ParticipantSession>;
3481
+ };
3425
3482
  /**
3426
3483
  * Sign in, or sign up, with a Solana, EVM or Cosmos wallet where the project enabled it
3427
3484
  * (`providers().wallets`). A wallet the member linked while signed in cannot sign in.
@@ -3703,29 +3760,37 @@ declare function relayClient(options: RelayClientOptions): {
3703
3760
  retryMs?: number;
3704
3761
  }) => ProgressObserver;
3705
3762
  submission: {
3706
- (quest: string, options?: {
3707
- input: "photo";
3763
+ (quest: string, options?: Omit<{
3764
+ input: "photo" | "quiz" | "none" | "text" | "url";
3708
3765
  release?: string;
3709
3766
  recoverPrevious?: boolean;
3710
3767
  repeatable?: boolean;
3768
+ }, "input"> & {
3769
+ input: "photo";
3711
3770
  }): Promise<PhotoSubmission>;
3712
- (quest: string, options: {
3713
- input: "quiz";
3771
+ (quest: string, options: Omit<{
3772
+ input: "photo" | "quiz" | "none" | "text" | "url";
3714
3773
  release?: string;
3715
3774
  recoverPrevious?: boolean;
3716
3775
  repeatable?: boolean;
3776
+ }, "input"> & {
3777
+ input: "quiz";
3717
3778
  }): Promise<QuizSubmission>;
3718
- (quest: string, options: {
3719
- input: "none";
3779
+ (quest: string, options: Omit<{
3780
+ input: "photo" | "quiz" | "none" | "text" | "url";
3720
3781
  release?: string;
3721
3782
  recoverPrevious?: boolean;
3722
3783
  repeatable?: boolean;
3784
+ }, "input"> & {
3785
+ input: "none";
3723
3786
  }): Promise<ClaimSubmission>;
3724
- (quest: string, options: {
3725
- input: "text" | "url";
3787
+ (quest: string, options: Omit<{
3788
+ input: "photo" | "quiz" | "none" | "text" | "url";
3726
3789
  release?: string;
3727
3790
  recoverPrevious?: boolean;
3728
3791
  repeatable?: boolean;
3792
+ }, "input"> & {
3793
+ input: "text" | "url";
3729
3794
  }): Promise<ValueSubmission>;
3730
3795
  };
3731
3796
  collectionPass: (entitlement: string, requestOptions?: RelayRequestOptions) => Promise<{
@@ -4586,4 +4651,4 @@ declare function relayClient(options: RelayClientOptions): {
4586
4651
  interface RelayClient extends ReturnType<typeof relayClient> {
4587
4652
  }
4588
4653
 
4589
- export { type ClaimSubmission as C, type KnownRelayErrorCode as K, type PhotoSubmission as P, type QuestActionResult as Q, type RelayClient as R, type SubmissionDraft as S, type ValueSubmission as V, type ProgressObservation as a, type ProgressObserver as b, type QuestController as c, QuestUpdatedError as d, type QuizSubmission as e, type RelayClientOptions as f, RelayError as g, RelayErrorCode as h, type RelayErrorDetails as i, type RelayErrorKind as j, type RelayRequestOptions as k, type RelayResponseOptions as l, type SubmissionStatus as m, type SubmissionStore as n, createRelayClient as o, isRelayError as p };
4654
+ export { type AuthStartInput as A, type ClaimSubmission as C, type EmailVerification as E, type KnownRelayErrorCode as K, type PhotoSubmission as P, type QuestActionResult as Q, type RelayClient as R, type SubmissionCallOptions as S, type ValueSubmission as V, type ProgressObservation as a, type ProgressObserver as b, type QuestController as c, QuestUpdatedError as d, type QuizSubmission as e, type RelayClientOptions as f, RelayError as g, RelayErrorCode as h, type RelayErrorDetails as i, type RelayErrorKind as j, type RelayRequestOptions as k, type RelayResponseOptions as l, type SubmissionDraft as m, type SubmissionStatus as n, type SubmissionStore as o, createRelayClient as p, isRelayError as q };