@domino-sdk/relay 1.61.0 → 1.63.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 (88) hide show
  1. package/CHANGELOG.md +276 -8
  2. package/README.md +3 -2
  3. package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-nz3mzfRQ.d.ts} +3146 -1765
  4. package/dist/action-9Xl0StBg.d.ts +33 -0
  5. package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
  6. package/dist/authoring.d.ts +171 -49
  7. package/dist/authoring.js +158 -49
  8. package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +15 -1
  9. package/dist/avatar.d.ts +1 -1
  10. package/dist/browser.d.ts +15 -11
  11. package/dist/browser.js +18 -12
  12. package/dist/capability-error-CuI_F7yM.d.ts +296 -0
  13. package/dist/{pages-K7-KjSXw.d.ts → catalog-BaTOKpNw.d.ts} +56 -567
  14. package/dist/{chunk-XBV2CK2H.js → chunk-3RFP6GT5.js} +15 -3
  15. package/dist/{chunk-VURRFVNP.js → chunk-4GQW43UU.js} +239 -361
  16. package/dist/chunk-4NOFSGAL.js +320 -0
  17. package/dist/{chunk-24I4R732.js → chunk-5XLZ34PV.js} +34 -19
  18. package/dist/{chunk-L77O64I4.js → chunk-7X67QLPB.js} +43 -43
  19. package/dist/{chunk-RHBS5FJL.js → chunk-7Z4SZ6YM.js} +3 -3
  20. package/dist/{chunk-QEAS4ZGS.js → chunk-AQOL3SK5.js} +1 -1
  21. package/dist/chunk-EHUSD3O2.js +377 -0
  22. package/dist/chunk-FO2LCZTL.js +19 -0
  23. package/dist/{chunk-DYXDZFKA.js → chunk-FU5CGNTR.js} +166 -178
  24. package/dist/chunk-FWLQ5XCS.js +21 -0
  25. package/dist/chunk-GLH6MEI2.js +193 -0
  26. package/dist/chunk-ICXZZNPS.js +199 -0
  27. package/dist/{chunk-ZDJLPN4L.js → chunk-ID3BZXFZ.js} +2696 -2693
  28. package/dist/chunk-KP2MCX3R.js +587 -0
  29. package/dist/{chunk-SKGTNTLF.js → chunk-LZWXCBUB.js} +213 -297
  30. package/dist/chunk-MTKRIQEU.js +31 -0
  31. package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
  32. package/dist/{chunk-PPB7HALD.js → chunk-N4BDKS6Y.js} +27 -26
  33. package/dist/{chunk-5I54XBK2.js → chunk-N4LNEGQX.js} +2 -2
  34. package/dist/chunk-NQDEWJWE.js +554 -0
  35. package/dist/chunk-QR6HH4DI.js +508 -0
  36. package/dist/chunk-TLSQETTY.js +41 -0
  37. package/dist/{chunk-MHPKEVEW.js → chunk-U66GUVSG.js} +7 -2
  38. package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
  39. package/dist/chunk-UZ765UGH.js +18 -0
  40. package/dist/{chunk-7A4J67ZL.js → chunk-VWQGWGCH.js} +7 -7
  41. package/dist/chunk-W7YSMSGC.js +725 -0
  42. package/dist/{client-C51w7fMb.d.ts → client-DHmG7rn6.d.ts} +126 -93
  43. package/dist/{announcements-CHx3-HBw.d.ts → dashboards-CLemT6kj.d.ts} +14 -137
  44. package/dist/{deployments-kWoHFaqj.d.ts → deployments-DTULi7dF.d.ts} +450 -18
  45. package/dist/identity-integration-DOeNZaxF.d.ts +1271 -0
  46. package/dist/index.d.ts +13 -11
  47. package/dist/index.js +16 -11
  48. package/dist/internal.d.ts +29 -13
  49. package/dist/internal.js +57 -17
  50. package/dist/{integrations-B3y36OaB.d.ts → limits-kNzYdZ00.d.ts} +464 -53
  51. package/dist/{offers-BoV4ryUc.d.ts → offers-CYeN_I0Y.d.ts} +22 -4
  52. package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
  53. package/dist/portal-proxy.d.ts +75 -2
  54. package/dist/portal-proxy.js +153 -25
  55. package/dist/react/index.d.ts +214 -27
  56. package/dist/react/index.js +196 -42
  57. package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
  58. package/dist/reward-deliveries-drp-x1G-.d.ts +782 -0
  59. package/dist/runtime/authoring.js +1 -1
  60. package/dist/runtime/chunks/UGDV5W4N.js +1 -0
  61. package/dist/runtime/manifest.json +3 -3
  62. package/dist/runtime/schema.js +1 -1
  63. package/dist/schema.d.ts +330 -31
  64. package/dist/schema.js +147 -91
  65. package/dist/server/index.d.ts +14 -12
  66. package/dist/server/index.js +6425 -6260
  67. package/dist/sign-in-providers-B1Q9eDRm.d.ts +44 -0
  68. package/dist/submission-input-DZCbjQUH.d.ts +343 -0
  69. package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-NL0Asmsi.d.ts} +46 -6
  70. package/dist/telegram.d.ts +64 -0
  71. package/dist/telegram.js +23 -0
  72. package/dist/testing.d.ts +326 -27
  73. package/dist/testing.js +440 -90
  74. package/dist/tracker-data-esm3WG8R.d.ts +1881 -0
  75. package/dist/{transport-BrX9pIGN.d.ts → transport-Czht_irp.d.ts} +43483 -38512
  76. package/dist/{wallet-CIqFoxdm.d.ts → wallet-B7e06v4m.d.ts} +32 -9
  77. package/package.json +5 -1
  78. package/dist/accounts-DoabriBX.d.ts +0 -306
  79. package/dist/capability-error-DufwG3G0.d.ts +0 -159
  80. package/dist/chunk-3Y3L2F54.js +0 -982
  81. package/dist/chunk-DHXDBAJF.js +0 -544
  82. package/dist/chunk-EN3M5Z4J.js +0 -13
  83. package/dist/chunk-QNUHWK7R.js +0 -602
  84. package/dist/chunk-SE4PFJPT.js +0 -247
  85. package/dist/groups-CqcA2Ycs.d.ts +0 -2827
  86. package/dist/runtime/chunks/5QVFB4TU.js +0 -1
  87. package/dist/submission-input-C54Q8yAD.d.ts +0 -146
  88. package/dist/x-D1PGi8Sq.d.ts +0 -331
@@ -1,47 +1,57 @@
1
1
  import {
2
2
  createRelayAction,
3
3
  withActionId
4
- } from "./chunk-QEAS4ZGS.js";
4
+ } from "./chunk-AQOL3SK5.js";
5
5
  import {
6
+ setPluginTransport
7
+ } from "./chunk-MTKRIQEU.js";
8
+ import {
9
+ authProvidersSchema,
6
10
  collectionPassSchema,
11
+ consentInputSchema,
7
12
  creatorAccountProviderSchema,
8
13
  creatorAccountsSchema,
9
- participantActivityQuerySchema,
10
- participantActivitySchema,
14
+ memberConsentListSchema,
15
+ memberConsentSchema,
11
16
  participantDeliveriesSchema,
12
17
  participantEntitlementsSchema,
13
18
  questClaimInputSchema,
14
19
  questEnrollmentInputSchema,
15
20
  questEnrollmentSchema,
16
- questExperienceSchema,
17
21
  questOutcomePageSchema,
18
22
  questOutcomeQuerySchema,
19
23
  questOutcomeSchema,
20
24
  rewardDeliveriesSchema,
21
25
  rewardDeliveryQuerySchema
22
- } from "./chunk-QNUHWK7R.js";
26
+ } from "./chunk-EHUSD3O2.js";
27
+ import {
28
+ participantActivityQuerySchema,
29
+ participantActivitySchema,
30
+ questExperienceSchema
31
+ } from "./chunk-4NOFSGAL.js";
23
32
  import {
24
- badgeSchema,
25
33
  engagementBoundaryPageSchema,
26
34
  engagementPageQuerySchema,
27
35
  engagementPageSchema,
28
- leaderboardDefinitionResponseSchema,
29
- leaderboardHistoryPageSchema,
30
- leaderboardHistoryQuerySchema,
31
- leaderboardPageSchema,
32
- leaderboardPlacementSchema,
33
- leaderboardQuerySchema,
34
- memberBadgesSchema,
35
36
  offerSchema,
36
37
  redemptionSchema,
37
38
  referralAcceptSchema,
38
39
  referralDefinitionSchema,
39
40
  referralHistorySchema,
40
41
  referralSummarySchema
41
- } from "./chunk-3Y3L2F54.js";
42
+ } from "./chunk-QR6HH4DI.js";
42
43
  import {
43
44
  AVATAR_UPLOAD_LIMIT,
44
45
  avatarUploadTypes,
46
+ badgeCatalogSchema,
47
+ badgeSchema,
48
+ leaderboardDefinitionResponseSchema,
49
+ leaderboardHistoryPageSchema,
50
+ leaderboardHistoryQuerySchema,
51
+ leaderboardPageSchema,
52
+ leaderboardPlacementSchema,
53
+ leaderboardQuerySchema,
54
+ memberBadgesSchema,
45
55
  ownProfileSchema,
46
56
  pointBalancesSchema,
47
57
  pointHistoryPageSchema,
@@ -52,83 +62,85 @@ import {
52
62
  profileReferralSchema,
53
63
  profileSummarySchema,
54
64
  profileUpdateSchema
55
- } from "./chunk-SE4PFJPT.js";
65
+ } from "./chunk-W7YSMSGC.js";
66
+ import {
67
+ createHttpExchange,
68
+ untilAborted,
69
+ withQuery
70
+ } from "./chunk-ICXZZNPS.js";
56
71
  import {
57
72
  PARTICIPANT_TIMEOUT,
58
73
  lifetime,
59
- retryAfter,
60
74
  retrying,
61
75
  validTimeout
62
- } from "./chunk-XBV2CK2H.js";
63
- import {
64
- clientIdentity
65
- } from "./chunk-EN3M5Z4J.js";
76
+ } from "./chunk-3RFP6GT5.js";
66
77
  import {
67
78
  exchangeResultSchema,
68
79
  exchangeSchema,
69
80
  memberSummarySchema,
70
81
  participantSessionSchema,
71
82
  sessionMember
72
- } from "./chunk-PPB7HALD.js";
83
+ } from "./chunk-N4BDKS6Y.js";
73
84
  import {
74
- RelayError,
75
- RelayErrorCode,
76
85
  accountConnectionSchema,
77
86
  attemptSchema,
78
- authProviderSchema,
79
87
  campaignEnrollmentInputSchema,
80
88
  campaignEnrollmentSchema,
81
89
  campaignWithdrawalInputSchema,
82
- clientError,
83
90
  contentPerformancePageSchema,
84
91
  contentPerformanceQuerySchema,
85
92
  contentQualificationPageSchema,
86
93
  contentQualificationQuerySchema,
87
94
  evidenceSchema,
88
95
  identifier,
89
- isRelayError,
90
- isRequestError,
91
96
  knownResponse,
92
97
  linkedWalletSchema,
93
98
  memberProgressSchema,
94
99
  missingPrerequisiteSchema,
95
100
  pageQuerySchema,
96
- parseInput,
97
101
  questSubmissionResultSchema,
98
102
  questSubmissionSchema,
99
103
  quizEvidenceSchema,
104
+ signInAccountSchema,
105
+ signInProviderInputSchema,
100
106
  submissionEvidenceSchema,
101
107
  submitSchema,
102
108
  telegramAccountConnectionSchema,
103
109
  telegramMiniAppSignInSchema,
104
- telegramSignInMethodsSchema,
105
110
  tieredRewardReferenceSchema,
106
111
  validateSubmissionValue,
107
112
  valueEvidenceSchema,
108
113
  walletAddressInput,
109
114
  walletAddressInputSchema,
110
115
  walletMessageChallengeSchema,
111
- walletSignInNetworksSchema,
112
116
  walletSignatureSchema,
113
117
  walletUnlinkInputSchema
114
- } from "./chunk-ZDJLPN4L.js";
118
+ } from "./chunk-ID3BZXFZ.js";
119
+ import {
120
+ RelayError,
121
+ RelayErrorCode,
122
+ clientError,
123
+ isRelayError,
124
+ isRequestError,
125
+ parseInput
126
+ } from "./chunk-GLH6MEI2.js";
115
127
 
116
128
  // src/legacy-submissions.ts
117
129
  import * as z from "zod";
118
- var common = {
130
+ var common = /* @__PURE__ */ (() => ({
119
131
  id: identifier,
120
132
  quest: identifier,
121
133
  release: identifier.optional()
122
- };
123
- var claimInputSchema = z.union([
134
+ }))();
135
+ var claimInputSchema = /* @__PURE__ */ (() => z.union([
124
136
  submissionEvidenceSchema,
125
137
  z.object({ kind: z.literal("none") }).strict()
126
- ]);
127
- var draftSchema = z.union([
138
+ ]))();
139
+ var draftSchema = /* @__PURE__ */ (() => z.union([
128
140
  claimInputSchema,
129
141
  z.object({ kind: z.literal("photo"), file: z.instanceof(Blob) })
130
- ]);
131
- var activeRecordSchema = z.union([
142
+ ]))();
143
+ var activeRecordSchema = /* @__PURE__ */ (() => z.union([
132
144
  z.object({
133
145
  ...common,
134
146
  stage: z.literal("review"),
@@ -154,15 +166,15 @@ var activeRecordSchema = z.union([
154
166
  input: claimInputSchema,
155
167
  attempt: identifier
156
168
  })
157
- ]);
158
- var recordSchema = z.union([
169
+ ]))();
170
+ var recordSchema = /* @__PURE__ */ (() => z.union([
159
171
  activeRecordSchema,
160
172
  z.object({
161
173
  ...common,
162
174
  stage: z.literal("retired"),
163
175
  previous: activeRecordSchema
164
176
  })
165
- ]);
177
+ ]))();
166
178
  function legacySubmissions(transport, configuredStore, namespace) {
167
179
  async function open(quest, options = {
168
180
  input: "photo"
@@ -797,7 +809,7 @@ import * as z2 from "zod";
797
809
 
798
810
  // src/progress.ts
799
811
  function sessionEnded(error) {
800
- return isRequestError(error) && (error.code === RelayErrorCode.StaleSession || error.code === RelayErrorCode.NotSignedIn);
812
+ return isRequestError(error) && (error.code === RelayErrorCode.StaleSession || error.code === RelayErrorCode.NotSignedIn || error.code === RelayErrorCode.Unauthenticated);
801
813
  }
802
814
  function observeProgress(transport, listener, options = {}, onDispose = () => {
803
815
  }) {
@@ -1112,14 +1124,14 @@ function questActions(submission, latest) {
1112
1124
  }
1113
1125
 
1114
1126
  // src/client.ts
1115
- var authStartSchema = z2.strictObject({
1116
- provider: authProviderSchema,
1127
+ var authStartSchema = /* @__PURE__ */ (() => z2.strictObject({
1128
+ provider: signInProviderInputSchema,
1117
1129
  mode: z2.enum(["sign-in", "connect"])
1118
- });
1119
- var emailVerificationSchema = z2.strictObject({
1130
+ }))();
1131
+ var emailVerificationSchema = /* @__PURE__ */ (() => z2.strictObject({
1120
1132
  challenge: z2.string().min(1).max(200),
1121
1133
  code: z2.string().transform((code) => code.trim()).pipe(z2.string().regex(/^\d{6}$/, "Enter the 6-digit code"))
1122
- });
1134
+ }))();
1123
1135
  function errorBody(value) {
1124
1136
  const body = value !== null && typeof value === "object" ? value : {};
1125
1137
  const window = body.window === "tracker" ? "tracker" : body.window === "quest" ? "quest" : void 0;
@@ -1135,24 +1147,16 @@ function errorBody(value) {
1135
1147
  };
1136
1148
  }
1137
1149
  async function fromSigner(step, signal) {
1138
- let stop;
1139
1150
  try {
1140
- return await new Promise((resolve, reject) => {
1141
- stop = () => reject(
1142
- new RelayError("The request was cancelled", {
1143
- kind: "aborted",
1144
- code: RelayErrorCode.Aborted,
1145
- cause: signal?.reason
1146
- })
1147
- );
1148
- if (signal?.aborted) {
1149
- stop();
1150
- return;
1151
- }
1152
- signal?.addEventListener("abort", stop, { once: true });
1153
- step().then(resolve, reject);
1154
- });
1151
+ return await untilAborted(step, signal);
1155
1152
  } catch (error) {
1153
+ if (signal?.aborted && error === signal.reason) {
1154
+ throw new RelayError("The request was cancelled", {
1155
+ kind: "aborted",
1156
+ code: RelayErrorCode.Aborted,
1157
+ cause: error
1158
+ });
1159
+ }
1156
1160
  if (error instanceof RelayError) {
1157
1161
  throw error;
1158
1162
  }
@@ -1161,59 +1165,13 @@ async function fromSigner(step, signal) {
1161
1165
  RelayErrorCode.WalletSigner,
1162
1166
  { cause: error }
1163
1167
  );
1164
- } finally {
1165
- if (stop) {
1166
- signal?.removeEventListener("abort", stop);
1167
- }
1168
1168
  }
1169
1169
  }
1170
1170
  var invalidTimeout = () => clientError(
1171
1171
  "timeout must be a positive, finite number of milliseconds",
1172
1172
  RelayErrorCode.InvalidInput
1173
1173
  );
1174
- var uncertainStatuses = /* @__PURE__ */ new Set([500, 502, 504]);
1175
1174
  var methodOf = (call) => call.method ?? (call.json === void 0 ? "GET" : "POST");
1176
- function withQuery(path, values) {
1177
- const params = new URLSearchParams();
1178
- for (const [key, value] of Object.entries(values)) {
1179
- if (value !== void 0) {
1180
- params.set(key, String(value));
1181
- }
1182
- }
1183
- const search = params.toString();
1184
- return search ? path + "?" + search : path;
1185
- }
1186
- function interrupted(call, life, error, stage) {
1187
- const details = {
1188
- status: stage.status,
1189
- retryAfter: stage.headers ? retryAfter(stage.headers) : void 0,
1190
- operationId: call.operationId,
1191
- replaySafe: call.replaySafe,
1192
- uncertain: stage.sent && methodOf(call) !== "GET" && // An error status whose body broke off still refused the write, unless the status itself
1193
- // does not prove that (500, 502, 504).
1194
- (!stage.refused || uncertainStatuses.has(stage.status ?? 0)),
1195
- cause: error
1196
- };
1197
- const ended = life.ended();
1198
- if (ended === "aborted") {
1199
- return new RelayError("The request was cancelled", {
1200
- ...details,
1201
- kind: "aborted",
1202
- code: RelayErrorCode.Aborted
1203
- });
1204
- }
1205
- if (ended === "timeout") {
1206
- return new RelayError(`Relay did not respond within ${life.timeout} ms`, {
1207
- ...details,
1208
- kind: "timeout",
1209
- code: RelayErrorCode.Timeout
1210
- });
1211
- }
1212
- return new RelayError(
1213
- stage.status === void 0 ? "Could not reach Relay" : "Relay's response was cut off",
1214
- { ...details, kind: "network", code: RelayErrorCode.Network }
1215
- );
1216
- }
1217
1175
  function createRelayClient(options) {
1218
1176
  return relayClient(options);
1219
1177
  }
@@ -1227,158 +1185,28 @@ function relayClient(options) {
1227
1185
  RelayErrorCode.InvalidInput
1228
1186
  );
1229
1187
  }
1230
- try {
1231
- const headers = new Headers(options.headers);
1232
- if (options.token) {
1233
- headers.set("Authorization", `Bearer ${options.token}`);
1234
- }
1235
- headers.set("X-Relay-Organization", options.organization ?? "");
1236
- headers.set("X-Relay-Project", options.project ?? "");
1237
- } catch (error) {
1238
- throw clientError(
1239
- "headers, token, organization and project must be valid HTTP header values",
1240
- RelayErrorCode.InvalidInput,
1241
- { cause: error }
1242
- );
1243
- }
1244
1188
  const clientTimeout = options.timeout ?? PARTICIPANT_TIMEOUT;
1245
- async function credential(call, life) {
1246
- if (!options.getToken) {
1247
- return options.token;
1248
- }
1249
- const getToken = options.getToken;
1250
- try {
1251
- return await new Promise((resolve, reject) => {
1252
- const stop = () => reject(life.signal.reason);
1253
- life.signal.addEventListener("abort", stop, { once: true });
1254
- getToken().then(resolve, reject).finally(() => life.signal.removeEventListener("abort", stop));
1255
- });
1256
- } catch (error) {
1257
- if (life.signal.aborted) {
1258
- throw interrupted(call, life, error, { sent: false });
1259
- }
1260
- throw new RelayError("Could not get a Relay credential", {
1261
- // A token source that could not reach its own service failed like a network call.
1262
- kind: error instanceof TypeError ? "network" : "client",
1263
- code: RelayErrorCode.Credential,
1264
- operationId: call.operationId,
1265
- replaySafe: call.replaySafe,
1266
- cause: error
1267
- });
1268
- }
1269
- }
1270
- async function send(path, call, life) {
1271
- if (life.signal.aborted) {
1272
- throw interrupted(call, life, life.reason(), { sent: false });
1273
- }
1274
- const method = methodOf(call);
1275
- const token = await credential(call, life);
1276
- let headers;
1277
- let body2 = call.body;
1278
- try {
1279
- headers = new Headers(options.headers);
1280
- new Headers(call.headers).forEach(
1281
- (value, name) => headers.set(name, value)
1282
- );
1283
- headers.set("X-Domino-Client", clientIdentity());
1284
- if (token) {
1285
- try {
1286
- headers.set("Authorization", `Bearer ${token}`);
1287
- } catch (error) {
1288
- throw new RelayError(
1289
- "getToken returned a value that is not a token",
1290
- {
1291
- kind: "client",
1292
- code: RelayErrorCode.Credential,
1293
- operationId: call.operationId,
1294
- replaySafe: call.replaySafe,
1295
- cause: error
1296
- }
1297
- );
1298
- }
1299
- } else if (options.getToken) {
1300
- headers.delete("Authorization");
1301
- }
1302
- if (options.organization) {
1303
- headers.set("X-Relay-Organization", options.organization);
1304
- }
1305
- if (options.project) {
1306
- headers.set("X-Relay-Project", options.project);
1307
- }
1308
- if (options.environment) {
1309
- headers.set("X-Relay-Environment", options.environment);
1310
- }
1311
- if (call.options?.session) {
1312
- headers.set("X-Relay-Session", call.options.session);
1313
- }
1314
- if (call.json !== void 0) {
1315
- headers.set("Content-Type", "application/json");
1316
- body2 = JSON.stringify(call.json);
1317
- }
1318
- if (method !== "GET") {
1319
- headers.set("X-Relay-CSRF", "1");
1320
- }
1321
- } catch (error) {
1322
- if (isRelayError(error)) {
1323
- throw error;
1324
- }
1325
- throw clientError(
1326
- "The request has a header or body that cannot be sent",
1327
- RelayErrorCode.InvalidInput,
1328
- {
1329
- operationId: call.operationId,
1330
- replaySafe: call.replaySafe,
1331
- cause: error
1332
- }
1333
- );
1334
- }
1335
- if (life.signal.aborted) {
1336
- throw interrupted(call, life, life.reason(), { sent: false });
1337
- }
1338
- let response;
1339
- try {
1340
- response = await (options.fetch ?? fetch)(options.baseUrl + path, {
1341
- method,
1342
- headers,
1343
- body: body2,
1344
- signal: life.signal
1345
- });
1346
- } catch (error) {
1347
- throw interrupted(call, life, error, { sent: true });
1348
- }
1349
- if (!response.ok) {
1350
- let text;
1351
- try {
1352
- text = await response.text();
1353
- } catch (error) {
1354
- throw interrupted(call, life, error, {
1355
- sent: true,
1356
- status: response.status,
1357
- headers: response.headers,
1358
- refused: true
1359
- });
1360
- }
1361
- let value = null;
1362
- try {
1363
- value = JSON.parse(text);
1364
- } catch {
1365
- }
1366
- const { message, code, window, missing, retryAt } = errorBody(value);
1367
- throw new RelayError(message ?? `Request failed (${response.status})`, {
1368
- kind: "http",
1369
- status: response.status,
1370
- code,
1371
- window,
1372
- missing,
1373
- ...retryAt === void 0 ? {} : { retryAt },
1374
- operationId: call.operationId,
1375
- replaySafe: call.replaySafe,
1376
- uncertain: methodOf(call) !== "GET" && uncertainStatuses.has(response.status),
1377
- retryAfter: retryAfter(response.headers)
1378
- });
1379
- }
1380
- return response;
1381
- }
1189
+ const http = createHttpExchange(options, {
1190
+ csrf: true,
1191
+ session: (call) => call.options?.session,
1192
+ messages: {
1193
+ aborted: "The request was cancelled",
1194
+ timeout: (milliseconds) => `Relay did not respond within ${milliseconds} ms`,
1195
+ network: (status) => status === void 0 ? "Could not reach Relay" : "Relay's response was cut off",
1196
+ credential: "Could not get a Relay credential",
1197
+ invalidToken: "getToken returned a value that is not a token",
1198
+ invalidOptions: "headers, token, organization and project must be valid HTTP header values",
1199
+ unsendable: "The request has a header or body that cannot be sent"
1200
+ },
1201
+ // Unlike the management client's, a write that failed to connect stays uncertain: this client
1202
+ // does not read the socket error that would prove it was never sent.
1203
+ makeError: (message, details, call) => new RelayError(message, {
1204
+ ...details,
1205
+ operationId: call?.operationId,
1206
+ replaySafe: call?.replaySafe
1207
+ }),
1208
+ parseRefusal: errorBody
1209
+ });
1382
1210
  async function exchange(path, call, receive) {
1383
1211
  const timeout = call.options?.timeout ?? clientTimeout;
1384
1212
  if (!validTimeout(timeout)) {
@@ -1391,7 +1219,7 @@ function relayClient(options) {
1391
1219
  {
1392
1220
  replaySafe: methodOf(call) === "GET" || (call.replaySafe ?? call.operationId !== void 0)
1393
1221
  },
1394
- async () => receive(await send(path, call, life), life)
1222
+ async () => receive(await http.send(path, call, call, life), life)
1395
1223
  );
1396
1224
  } finally {
1397
1225
  life.end();
@@ -1401,7 +1229,7 @@ function relayClient(options) {
1401
1229
  try {
1402
1230
  return await reader(response);
1403
1231
  } catch (error) {
1404
- throw interrupted(call, life, error, {
1232
+ throw http.interrupted(error, methodOf(call), call, life, {
1405
1233
  sent: true,
1406
1234
  status: response.status,
1407
1235
  headers: response.headers
@@ -1593,7 +1421,26 @@ function relayClient(options) {
1593
1421
  }
1594
1422
  const ok = z2.object({ ok: z2.literal(true) });
1595
1423
  const acknowledged = z2.object({ ok: z2.boolean() });
1596
- return {
1424
+ const pluginProofSchema = z2.string().min(1, "Pass the vendor's signed proof").max(8192);
1425
+ const signInMethod = (path, field) => {
1426
+ const body2 = (proof, mode) => ({
1427
+ [field]: parseInput(pluginProofSchema, proof),
1428
+ mode
1429
+ });
1430
+ return {
1431
+ signIn: (proof, requestOptions) => changeSession(
1432
+ () => request(path, participantSessionSchema, {
1433
+ json: body2(proof, "sign-in"),
1434
+ options: requestOptions
1435
+ })
1436
+ ),
1437
+ connect: async (proof, requestOptions) => request(path, acknowledged, {
1438
+ json: body2(proof, "connect"),
1439
+ options: requestOptions
1440
+ })
1441
+ };
1442
+ };
1443
+ const client = {
1597
1444
  /** Owns one action key across uncertain writes. Reuse the helper until a definite answer. */
1598
1445
  action: createRelayAction,
1599
1446
  /** A JSON call using an explicit tolerant response schema from `@domino-sdk/relay/schema`. */
@@ -1682,7 +1529,17 @@ function relayClient(options) {
1682
1529
  })
1683
1530
  },
1684
1531
  badges: {
1685
- list: (options2) => request("/v1/badges", z2.array(badgeSchema), { options: options2 })
1532
+ /**
1533
+ * The project's active badge catalog, as an array.
1534
+ *
1535
+ * @deprecated Use `catalog`, which answers `{ items }` like `me.badges`. Removed in 2.0.0.
1536
+ */
1537
+ list: (options2) => request("/v1/badges", z2.array(badgeSchema), { options: options2 }),
1538
+ /**
1539
+ * The project's active badge catalog, oldest definition first, in `items`. Archived badges
1540
+ * are left out. Open to signed-out visitors.
1541
+ */
1542
+ catalog: (options2) => request("/v1/badges/catalog", badgeCatalogSchema, { options: options2 })
1686
1543
  },
1687
1544
  pointLedgers: {
1688
1545
  /**
@@ -1831,7 +1688,8 @@ function relayClient(options) {
1831
1688
  * Claims one of the signed-in member's outcomes skipped as `historical`, on a quest whose
1832
1689
  * historical policy is `"claim"` (`outcome.claimable`). Relay decides it again with
1833
1690
  * historical activity released and returns the outcome; a rule that still fails rejects
1834
- * with a `RelayError` whose code is that rule's skip code.
1691
+ * with a `RelayError` whose code is that rule's skip code. This claim is of a skipped
1692
+ * outcome; `me.claim` submits an attempt.
1835
1693
  */
1836
1694
  claim: async (value, requestOptions) => {
1837
1695
  const body2 = parseInput(questClaimInputSchema, withActionId(value));
@@ -1925,6 +1783,34 @@ function relayClient(options) {
1925
1783
  );
1926
1784
  }
1927
1785
  },
1786
+ /**
1787
+ * The signed-in member's marketing consent, per channel. The app shows the checkbox and sends
1788
+ * the wording beside it; Relay records the choice with its own time, and only members who
1789
+ * opted in reach the project's destinations.
1790
+ *
1791
+ * @experimental A minor release can change the consent API.
1792
+ */
1793
+ consent: {
1794
+ /**
1795
+ * The member's current consent on each channel they chose on. A channel missing from the
1796
+ * list has no record, which is not the same as withdrawn.
1797
+ */
1798
+ get: (requestOptions) => request("/v1/me/consent", memberConsentListSchema, {
1799
+ options: requestOptions
1800
+ }),
1801
+ /**
1802
+ * Grants (`granted: true`, with the `wording` the member saw) or withdraws one channel.
1803
+ * Repeating the current state and wording records nothing and answers the current state.
1804
+ */
1805
+ set: async (value, requestOptions) => {
1806
+ const body2 = parseInput(consentInputSchema, withActionId(value));
1807
+ return request("/v1/me/consent", memberConsentSchema, {
1808
+ json: body2,
1809
+ options: requestOptions,
1810
+ operationId: body2.actionId
1811
+ });
1812
+ }
1813
+ },
1928
1814
  /** The signed-in member's linked Solana, EVM and Cosmos wallets for this project. */
1929
1815
  wallets: {
1930
1816
  list: (requestOptions) => request(
@@ -1979,27 +1865,9 @@ function relayClient(options) {
1979
1865
  }
1980
1866
  },
1981
1867
  auth: {
1982
- providers: (requestOptions) => request(
1983
- "/v1/auth/providers",
1984
- z2.object({
1985
- providers: z2.array(
1986
- z2.object({
1987
- provider: authProviderSchema,
1988
- configured: z2.boolean()
1989
- })
1990
- ),
1991
- email: z2.boolean(),
1992
- /** The wallet sign-in this project enabled. */
1993
- wallets: walletSignInNetworksSchema,
1994
- demo: z2.boolean(),
1995
- /**
1996
- * Telegram's sign-in, which is not one of `providers` in SDK 1.x. Absent from Relay
1997
- * versions without Telegram.
1998
- */
1999
- telegram: telegramSignInMethodsSchema.optional()
2000
- }),
2001
- { options: requestOptions }
2002
- ),
1868
+ providers: (requestOptions) => request("/v1/auth/providers", authProvidersSchema, {
1869
+ options: requestOptions
1870
+ }),
2003
1871
  start: authStart,
2004
1872
  emailStart: async (email2, requestOptions) => request("/v1/auth/email/start", z2.object({ challenge: z2.string() }), {
2005
1873
  json: {
@@ -2064,12 +1932,15 @@ function relayClient(options) {
2064
1932
  },
2065
1933
  /**
2066
1934
  * Telegram sign-in and the member's Telegram account. Telegram is not an `AuthProvider` in
2067
- * SDK 1.x, so `accounts()`, `start()` and `disconnect()` leave it out and these take its place.
1935
+ * SDK 1.x, so `accounts()` leaves it out; `signInAccounts()`, `start()` and `disconnect()`
1936
+ * take it like any other sign-in provider. Mini App sign-in is Telegram's own.
2068
1937
  */
2069
1938
  telegram: {
2070
1939
  /**
2071
1940
  * Leaves for Telegram Login when the platform configured it (`providers().telegram.login`):
2072
1941
  * `"sign-in"` signs in, or signs up; `"connect"` links Telegram to the signed-in member.
1942
+ *
1943
+ * @deprecated Use `auth.start({ provider: "telegram", mode })`. Removed in 2.0.0.
2073
1944
  */
2074
1945
  start: async (mode, requestOptions) => request("/v1/auth/start", z2.object({ url: z2.string() }), {
2075
1946
  json: {
@@ -2078,13 +1949,21 @@ function relayClient(options) {
2078
1949
  },
2079
1950
  options: requestOptions
2080
1951
  }),
2081
- /** The member's Telegram account. */
1952
+ /**
1953
+ * The member's Telegram account.
1954
+ *
1955
+ * @deprecated Use the `"telegram"` entry of `auth.signInAccounts()`. Removed in 2.0.0.
1956
+ */
2082
1957
  account: (requestOptions) => request(
2083
1958
  "/v1/auth/accounts/telegram",
2084
1959
  telegramAccountConnectionSchema,
2085
1960
  { options: requestOptions }
2086
1961
  ),
2087
- /** Unlinks the member's Telegram account, as `disconnect()` does for the other providers. */
1962
+ /**
1963
+ * Unlinks the member's Telegram account, as `disconnect()` does for the other providers.
1964
+ *
1965
+ * @deprecated Use `auth.disconnect("telegram")`. Removed in 2.0.0.
1966
+ */
2088
1967
  disconnect: async (requestOptions) => request("/v1/auth/accounts/disconnect", acknowledged, {
2089
1968
  json: { provider: "telegram" },
2090
1969
  options: requestOptions
@@ -2094,6 +1973,9 @@ function relayClient(options) {
2094
1973
  * (`providers().telegram.miniApp`). Pass the Mini App's signed launch data,
2095
1974
  * `telegramMiniAppInitData()`. Relay checks Telegram's signature for the project's bot and
2096
1975
  * accepts launch data at most five minutes old, once.
1976
+ *
1977
+ * @deprecated Use `relay.telegram.miniApp` from `@domino-sdk/relay/telegram`
1978
+ * (`withTelegram(relay)`). Removed in 2.0.0.
2097
1979
  */
2098
1980
  miniApp: {
2099
1981
  /** Signs in, or signs up, as the Telegram user who opened the Mini App. */
@@ -2144,12 +2026,20 @@ function relayClient(options) {
2144
2026
  options: requestOptions
2145
2027
  })
2146
2028
  },
2147
- /** The member's connected sign-in accounts, one per provider. */
2029
+ /** The member's connected sign-in accounts, one per `AuthProvider`. */
2148
2030
  accounts: (requestOptions) => request("/v1/auth/accounts", z2.array(accountConnectionSchema), {
2149
2031
  options: requestOptions
2150
2032
  }),
2033
+ /**
2034
+ * The member's account on every sign-in provider the platform has, one entry each, Telegram
2035
+ * included: `accounts()` with an open `provider`, as `providers().signInProviders` lists them.
2036
+ */
2037
+ signInAccounts: (requestOptions) => request("/v1/auth/sign-in-accounts", z2.array(signInAccountSchema), {
2038
+ options: requestOptions
2039
+ }),
2040
+ /** Unlinks the member's account on `provider`, any of `signInAccounts()`'s. */
2151
2041
  disconnect: async (provider, requestOptions) => request("/v1/auth/accounts/disconnect", acknowledged, {
2152
- json: { provider: parseInput(authProviderSchema, provider) },
2042
+ json: { provider: parseInput(signInProviderInputSchema, provider) },
2153
2043
  options: requestOptions
2154
2044
  }),
2155
2045
  session: (requestOptions) => readSession(requestOptions),
@@ -2159,7 +2049,13 @@ function relayClient(options) {
2159
2049
  options: requestOptions
2160
2050
  })
2161
2051
  ),
2162
- /** Local development only. Existing hosted apps use createParticipantBackend from /portal-proxy. */
2052
+ /**
2053
+ * @deprecated `POST /v1/auth/exchange` refuses this body with 400: the route takes
2054
+ * `{ subject, accounts?, previousToken? }` with an identity integration server key as the
2055
+ * bearer, which a participant client does not hold. A server signs a user in with
2056
+ * `exchangeParticipant` from `@domino-sdk/relay/portal-proxy`; a hosted app proxies with
2057
+ * `createParticipantBackend` from the same entry. Removed in 2.0.0.
2058
+ */
2163
2059
  exchange: async (value, requestOptions) => request("/v1/auth/exchange", exchangeResultSchema, {
2164
2060
  json: parseInput(exchangeSchema, value),
2165
2061
  options: requestOptions
@@ -2168,6 +2064,12 @@ function relayClient(options) {
2168
2064
  me: {
2169
2065
  badges: (options2) => request("/v1/me/badges", memberBadgesSchema, { options: options2 }),
2170
2066
  activity: {
2067
+ /**
2068
+ * One page of the signed-in member's activity feed, oldest event first. A feed never
2069
+ * ends: every page, even an empty one, answers a `nextCursor` to read from next, so a
2070
+ * loop such as `paginate` never finishes on its own. Stop when a page comes back empty
2071
+ * or after as many events as you need, or follow the feed with `observe`.
2072
+ */
2171
2073
  list: async (query = {}, options2) => {
2172
2074
  const parsed = parseInput(participantActivityQuerySchema, query);
2173
2075
  return request(
@@ -2229,7 +2131,12 @@ function relayClient(options) {
2229
2131
  * The signed-in member, the seed of their generated avatar (`defaultAvatar(avatarSeed)`), and
2230
2132
  * their own verified sign-in email addresses: `email` (or null) and `emails`.
2231
2133
  */
2232
- get: async (requestOptions) => request("/v1/me", memberSummarySchema, { options: requestOptions }),
2134
+ get: async (requestOptions) => {
2135
+ const me = await request("/v1/me", memberSummarySchema, {
2136
+ options: requestOptions
2137
+ });
2138
+ return { ...me, clock: me.clock ?? { now: Date.now(), offsetMs: 0 } };
2139
+ },
2233
2140
  observeProgress: (listener, observeOptions) => {
2234
2141
  const observer = observeProgress(
2235
2142
  {
@@ -2257,11 +2164,13 @@ function relayClient(options) {
2257
2164
  }),
2258
2165
  /**
2259
2166
  * The member's reward deliveries, newest first, one page at a time. Pass a page's
2260
- * `nextCursor` back as `cursor` for older ones; `limit` is 1 to 500, 500 by default.
2167
+ * `nextCursor` back as `cursor` for older ones; `limit` is 1 to 500, 500 by default. The
2168
+ * page answers its deliveries as `items` (and, for 1.x callers, as `deliveries`), so
2169
+ * `paginate((cursor) => relay.me.rewardDeliveries({ cursor }))` reads them all.
2261
2170
  */
2262
- rewardDeliveries: (requestOptions = {}) => {
2171
+ rewardDeliveries: async (requestOptions = {}) => {
2263
2172
  const { cursor, limit, ...options2 } = requestOptions;
2264
- return request(
2173
+ const page = await request(
2265
2174
  withQuery(
2266
2175
  "/v1/reward-deliveries",
2267
2176
  parseInput(rewardDeliveryQuerySchema, { cursor, limit })
@@ -2269,6 +2178,7 @@ function relayClient(options) {
2269
2178
  rewardDeliveriesSchema,
2270
2179
  { options: options2 }
2271
2180
  );
2181
+ return { ...page, items: page.items ?? page.deliveries };
2272
2182
  },
2273
2183
  /**
2274
2184
  * `{ items }`: the member's balance in each of the project's point ledgers, in the project's
@@ -2301,7 +2211,11 @@ function relayClient(options) {
2301
2211
  { options: requestOptions }
2302
2212
  );
2303
2213
  },
2304
- /** Claims a quest for the signed-in member. Quest controllers (`quests.open`) call this. */
2214
+ /**
2215
+ * Submits an attempt at a quest for the signed-in member, whatever input the quest takes;
2216
+ * a quest whose interaction is `"claim"` takes none. Quest controllers (`quests.open`) call
2217
+ * this. `quests.claim` is different: it claims an outcome skipped as historical.
2218
+ */
2305
2219
  claim: async (value, requestOptions) => {
2306
2220
  const claim = parseInput(
2307
2221
  submitSchema.omit({ member: true }),
@@ -2396,6 +2310,8 @@ function relayClient(options) {
2396
2310
  )
2397
2311
  }
2398
2312
  };
2313
+ setPluginTransport(client, { signInMethod });
2314
+ return client;
2399
2315
  }
2400
2316
 
2401
2317
  export {