@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.34

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 (61) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/activity-B8k9Sa_a.d.ts +9112 -0
  4. package/dist/authoring.d.ts +1355 -182
  5. package/dist/authoring.js +658 -225
  6. package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
  7. package/dist/avatar.d.ts +29 -0
  8. package/dist/avatar.js +21 -0
  9. package/dist/browser-J7tUpXxy.d.ts +4154 -0
  10. package/dist/browser.d.ts +11 -4580
  11. package/dist/browser.js +8 -6
  12. package/dist/capability-error-DNMwKmlL.d.ts +458 -0
  13. package/dist/chunk-36HTX2BM.js +1223 -0
  14. package/dist/chunk-6QJ3LADK.js +112 -0
  15. package/dist/chunk-BGGKNIRP.js +171 -0
  16. package/dist/chunk-EYH5RDIE.js +496 -0
  17. package/dist/chunk-GQKYAQM6.js +84 -0
  18. package/dist/chunk-GUP7YRR4.js +42 -0
  19. package/dist/chunk-GZ6FJAXN.js +1659 -0
  20. package/dist/chunk-JON5SESL.js +2986 -0
  21. package/dist/chunk-MC6V6VMG.js +49 -0
  22. package/dist/chunk-NPGENI7K.js +37 -0
  23. package/dist/chunk-V7UKZLHA.js +35 -0
  24. package/dist/chunk-VFHHLN6A.js +284 -0
  25. package/dist/chunk-WJSSJ7AF.js +151 -0
  26. package/dist/{chunk-VH4OQ5VX.js → chunk-XFMSUPNS.js} +26 -5
  27. package/dist/{chunk-FDWRBMB3.js → chunk-ZVIRG24J.js} +150 -33
  28. package/dist/client-XiuFnug_.d.ts +4262 -0
  29. package/dist/groups-Ck-OxzjD.d.ts +2449 -0
  30. package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
  31. package/dist/images-Dv-P5VBw.d.ts +234 -0
  32. package/dist/index.d.ts +15 -13115
  33. package/dist/index.js +30 -689
  34. package/dist/internal.d.ts +159 -0
  35. package/dist/internal.js +79 -0
  36. package/dist/offers-Cy-e4o5x.d.ts +431 -0
  37. package/dist/outcomes-kVB-Juzs.d.ts +4902 -0
  38. package/dist/pages-BBYD21IE.d.ts +359 -0
  39. package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
  40. package/dist/portal-proxy.js +26 -9
  41. package/dist/profiles-D2aFcOxu.d.ts +297 -0
  42. package/dist/react/index.d.ts +3378 -3318
  43. package/dist/react/index.js +1635 -783
  44. package/dist/request-error-DWduJCGV.d.ts +62 -0
  45. package/dist/schema-DfJzH2ci.d.ts +5644 -0
  46. package/dist/schema.d.ts +15 -3388
  47. package/dist/schema.js +790 -3
  48. package/dist/server/index.d.ts +81498 -0
  49. package/dist/server/index.js +2520 -0
  50. package/dist/streaks-CWyq8Px5.d.ts +71 -0
  51. package/dist/submission-input-BZkm6ohU.d.ts +290 -0
  52. package/dist/units-CwgsPB_r.d.ts +9 -0
  53. package/dist/vite.d.ts +1 -1
  54. package/dist/vite.js +1 -0
  55. package/dist/wallet-YssWxGg8.d.ts +228 -0
  56. package/package.json +24 -5
  57. package/dist/chunk-4KNTMNXA.js +0 -1847
  58. package/dist/chunk-B76BAJ25.js +0 -624
  59. package/dist/chunk-NKGJEYZM.js +0 -1833
  60. package/dist/chunk-ONDBQSMU.js +0 -373
  61. package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
@@ -1,373 +0,0 @@
1
- import {
2
- identifier
3
- } from "./chunk-NKGJEYZM.js";
4
-
5
- // src/profiles.ts
6
- import { z } from "zod";
7
- var count = z.number().int().nonnegative().safe();
8
- var profileVisibilitySchema = z.enum([
9
- "private",
10
- "participants",
11
- "public"
12
- ]);
13
- var avatarProviderSchema = z.enum(["x", "discord", "google"]);
14
- var profileDefaultProviderSchema = z.enum(["x", "discord"]);
15
- var profileDefaultsSchema = z.array(profileDefaultProviderSchema).max(profileDefaultProviderSchema.options.length).refine(
16
- (providers) => new Set(providers).size === providers.length,
17
- "List each provider once"
18
- );
19
- var avatarSeedSchema = z.string().min(1).max(100);
20
- var profileAvatarSchema = z.discriminatedUnion("source", [
21
- z.object({
22
- source: z.literal("upload"),
23
- url: z.string().url(),
24
- seed: avatarSeedSchema
25
- }),
26
- z.object({
27
- source: z.literal("account"),
28
- provider: avatarProviderSchema,
29
- url: z.string().url(),
30
- seed: avatarSeedSchema
31
- }),
32
- z.object({ source: z.literal("generated"), seed: avatarSeedSchema })
33
- ]);
34
- var profileSummarySchema = z.object({
35
- id: identifier,
36
- name: z.string(),
37
- avatar: profileAvatarSchema
38
- });
39
- var invisible = /[\p{Cc}؜᠎​-‏‪-‮⁠-⁤⁦-⁩]/u;
40
- var displayNameSchema = z.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
41
- z.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
42
- );
43
- var profileUpdateSchema = z.object({
44
- displayName: displayNameSchema.nullable().optional(),
45
- avatar: z.discriminatedUnion("source", [
46
- z.object({
47
- source: z.literal("account"),
48
- provider: avatarProviderSchema
49
- }).strict(),
50
- z.object({ source: z.literal("generated") }).strict()
51
- ]).nullable().optional(),
52
- hidden: z.boolean().optional()
53
- }).strict().refine(
54
- (value) => Object.values(value).some((field) => field !== void 0),
55
- "Change at least one field"
56
- );
57
- var ownProfileSchema = profileSummarySchema.extend({
58
- /** The name the member chose, or null for the default. */
59
- displayName: z.string().nullable(),
60
- /** The avatar the member chose: `default` follows the project's defaults. */
61
- avatarChoice: z.enum(["default", "upload", "account", "generated"]),
62
- /** The account of an `account` choice. */
63
- avatarProvider: avatarProviderSchema.nullable(),
64
- hidden: z.boolean(),
65
- /** An operator locked the name and avatar; the member can still hide the profile. */
66
- locked: z.boolean(),
67
- /** Who can see profiles in this project, so the app can explain it. */
68
- visibility: profileVisibilitySchema,
69
- /** The member's connected accounts a picture or name can come from. */
70
- options: z.array(
71
- z.object({
72
- provider: avatarProviderSchema,
73
- name: z.string().nullable(),
74
- imageUrl: z.string().url().nullable()
75
- })
76
- )
77
- });
78
- var cursor = z.string().min(1).max(512);
79
- var profileCompletionQuerySchema = z.object({
80
- limit: z.coerce.number().int().min(1).max(100).default(20),
81
- cursor: cursor.optional()
82
- }).strict();
83
- var profileCompletionSchema = z.object({
84
- quest: identifier,
85
- key: identifier.optional(),
86
- title: z.string(),
87
- completions: count.positive(),
88
- /** Null for completions recorded before completion times were. */
89
- lastCompletedAt: count.nullable()
90
- });
91
- var profileCompletionPageSchema = z.object({
92
- items: z.array(profileCompletionSchema),
93
- nextCursor: cursor.nullable()
94
- });
95
- var profileReferralSchema = z.object({
96
- program: identifier,
97
- key: identifier.optional(),
98
- title: z.string(),
99
- /** Members this member invited. Invitations are shared by every program. */
100
- invited: count,
101
- /** Invited members who qualified in this program. */
102
- qualified: count,
103
- milestones: z.array(
104
- z.object({ id: identifier, count, reached: z.boolean() })
105
- )
106
- });
107
- var profileSettingsSchema = z.object({
108
- visibility: profileVisibilitySchema,
109
- defaults: profileDefaultsSchema,
110
- revision: count,
111
- actor: z.string().nullable(),
112
- updatedAt: count.nullable()
113
- });
114
- var profileSettingsInputSchema = profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
115
- actionId: identifier,
116
- /** The revision the change was made against; a newer one is a 409. */
117
- expectedRevision: count,
118
- reason: z.string().trim().min(1).max(500)
119
- }).strict();
120
- var profileModerationSchema = z.object({
121
- actionId: identifier,
122
- resetName: z.boolean().default(false),
123
- removeAvatar: z.boolean().default(false),
124
- /** True locks the name and avatar, false unlocks them. */
125
- lock: z.boolean().optional(),
126
- reason: z.string().trim().min(1).max(1e3)
127
- }).strict().refine(
128
- (value) => value.resetName || value.removeAvatar || value.lock !== void 0,
129
- "Choose an action"
130
- );
131
- var managedProfileSchema = ownProfileSchema.omit({ options: true }).extend({
132
- member: identifier,
133
- lockedAt: count.nullable(),
134
- lockedBy: z.string().nullable(),
135
- lockedReason: z.string().nullable(),
136
- updatedAt: count
137
- });
138
- var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
139
- var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
140
- function isProfileParticipantRoute(path, method) {
141
- return method === "GET" && (path === "/v1/me/profile" || /^\/v1\/profiles\/[\w-]+(?:\/completions|\/referrals\/[\w-]+)?$/.test(
142
- path
143
- ) || /^\/v1\/leaderboards\/[\w-]+\/profiles\/[\w-]+$/.test(path)) || method === "POST" && (path === "/v1/me/profile" || path === "/v1/me/profile/avatar");
144
- }
145
-
146
- // src/wallet.ts
147
- import { z as z2 } from "zod";
148
- var solanaAddressSchema = z2.string().min(32).max(44).regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
149
- var walletConnectionSchema = z2.object({
150
- chain: z2.literal("solana"),
151
- address: solanaAddressSchema,
152
- verifiedAt: z2.number().int().nonnegative(),
153
- revision: z2.number().int().positive()
154
- }).strict();
155
- var walletChallengeInputSchema = z2.object({
156
- chain: z2.literal("solana"),
157
- address: solanaAddressSchema
158
- }).strict();
159
- var walletChallengeSchema = walletChallengeInputSchema.extend({
160
- id: z2.string().uuid(),
161
- message: z2.string(),
162
- expiresAt: z2.number()
163
- });
164
- var walletProofSchema = z2.object({
165
- challenge: z2.string().uuid(),
166
- signature: z2.string().min(64).max(88).regex(/^[1-9A-HJ-NP-Za-km-z]+$/)
167
- }).strict();
168
- var solanaBalanceSchema = z2.object({
169
- address: solanaAddressSchema,
170
- network: z2.literal("mainnet-beta"),
171
- lamports: z2.string().regex(/^(0|[1-9][0-9]*)$/),
172
- slot: z2.number().int().nonnegative().safe(),
173
- observedAt: z2.number().int().nonnegative()
174
- }).strict();
175
- var walletChainSchema = z2.enum(["solana", "eip155", "cosmos"]);
176
- var cosmosNetworkPattern = /^cosmos:[-_a-zA-Z0-9]{1,32}$/;
177
- var cosmosNetworkSchema = z2.custom(
178
- (value) => typeof value === "string" && cosmosNetworkPattern.test(value),
179
- "Use a Cosmos network: cosmos:<chain ID>"
180
- );
181
- function cosmosChain(chain) {
182
- if (typeof chain === "string" && !chain.startsWith("cosmos:")) {
183
- throw new Error('Use a Cosmos network such as "cosmos:cosmoshub-4"');
184
- }
185
- const value = typeof chain === "string" ? { chainId: chain.slice("cosmos:".length) } : chain;
186
- if (typeof value?.chainId !== "string") {
187
- throw new Error(
188
- 'Pass a Cosmos chain as { chainId } or a network such as "cosmos:cosmoshub-4"'
189
- );
190
- }
191
- const network = `cosmos:${value.chainId}`;
192
- if (!cosmosNetworkPattern.test(network)) {
193
- throw new Error(
194
- "A Cosmos chain ID has 1 to 32 letters, digits, hyphens or underscores"
195
- );
196
- }
197
- if (value.chainInfo && value.chainInfo.chainId !== value.chainId) {
198
- throw new Error("The chain info describes another chain ID");
199
- }
200
- return { ...value, network };
201
- }
202
- var solanaMainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
203
- var evmAddressSchema = z2.string().regex(/^0x[0-9a-fA-F]{40}$/);
204
- var cosmosAddressSchema = z2.string().min(8).max(90).regex(
205
- /^(?:[a-z][a-z0-9]{0,82}1[02-9ac-hj-np-z]{38,}|[A-Z][A-Z0-9]{0,82}1[02-9AC-HJ-NP-Z]{38,})$/
206
- );
207
- var walletAddressInputSchema = z2.discriminatedUnion("chain", [
208
- z2.object({ chain: z2.literal("solana"), address: solanaAddressSchema }).strict(),
209
- z2.object({
210
- chain: z2.literal("eip155"),
211
- address: evmAddressSchema,
212
- /** Shown in the sign-in message's Chain ID line only: links are chain-agnostic. Defaults to 1. */
213
- chainId: z2.number().int().positive().safe().optional()
214
- }).strict(),
215
- z2.object({
216
- chain: z2.literal("cosmos"),
217
- network: cosmosNetworkSchema,
218
- address: cosmosAddressSchema
219
- }).strict()
220
- ]);
221
- var walletMessageChallengeSchema = z2.object({
222
- id: z2.string().min(1).max(200),
223
- purpose: z2.enum(["link", "sign-in"]),
224
- chain: walletChainSchema,
225
- network: cosmosNetworkSchema.nullable(),
226
- /** Canonical (base58, EIP-55 or lowercase bech32). The signer must sign with this address. */
227
- address: z2.string(),
228
- message: z2.string().max(4096),
229
- expiresAt: z2.number().int()
230
- });
231
- var walletSignatureSchema = z2.object({
232
- challenge: z2.string().min(1).max(200),
233
- /** solana: base58, 64 bytes · eip155: 0x and 130 hex digits (65 bytes) · cosmos: base64, 64 bytes (r‖s) */
234
- signature: z2.string().min(1).max(256),
235
- /** cosmos only: the base64 33-byte compressed secp256k1 key from signArbitrary's pub_key.value */
236
- publicKey: z2.string().max(128).optional()
237
- }).strict();
238
- var linkedWalletSchema = z2.object({
239
- chain: walletChainSchema,
240
- network: cosmosNetworkSchema.nullable(),
241
- address: z2.string(),
242
- verifiedAt: z2.number().int().nonnegative(),
243
- revision: z2.number().int().positive(),
244
- /** True when this wallet can sign in: it was first used through wallet sign-in. Linking never enables sign-in. */
245
- signIn: z2.boolean()
246
- });
247
- var walletUnlinkInputSchema = z2.object({ chain: walletChainSchema, address: z2.string().min(1).max(100) }).strict();
248
- async function walletAddressInput(signer) {
249
- const address = await signer.address();
250
- switch (signer.chain) {
251
- case "solana":
252
- return { chain: "solana", address };
253
- case "eip155":
254
- return {
255
- chain: "eip155",
256
- address,
257
- ...signer.chainId ? { chainId: await signer.chainId() } : {}
258
- };
259
- case "cosmos":
260
- if (!signer.network) {
261
- throw new Error("Choose the Cosmos chain for this wallet");
262
- }
263
- return { chain: "cosmos", network: signer.network, address };
264
- }
265
- }
266
- var WALLETS_PER_CHAIN = 5;
267
- var walletSignInFamilies = ["solana", "eip155", "cosmos"];
268
- var walletSignInNetworkSchema = z2.union([z2.enum(walletSignInFamilies), z2.string().regex(cosmosNetworkPattern)]).transform(
269
- (value) => value.startsWith("cosmos:") ? "cosmos" : value
270
- );
271
- var walletSignInNetworksSchema = z2.array(walletSignInNetworkSchema).transform(
272
- (values) => walletSignInFamilies.filter((family) => values.includes(family))
273
- );
274
- function walletSignInNetwork(wallet) {
275
- return wallet.chain;
276
- }
277
- function caip10(wallet, network) {
278
- if (wallet.chain === "cosmos") {
279
- if (!wallet.network || network && network !== wallet.network) {
280
- throw new Error("A Cosmos wallet belongs to its own network");
281
- }
282
- return `${wallet.network}:${wallet.address}`;
283
- }
284
- const selected = network ?? (wallet.chain === "solana" ? solanaMainnet : "eip155:1");
285
- const valid = wallet.chain === "solana" ? /^solana:[1-9A-HJ-NP-Za-km-z]{32}$/.test(selected) : isEvmChainId(selected);
286
- if (!valid) {
287
- throw new Error(`Use a ${wallet.chain} network for this wallet`);
288
- }
289
- return `${selected}:${wallet.address}`;
290
- }
291
- function isWalletParticipantRoute(path) {
292
- return /^\/v1\/me\/(?:wallet(?:\/challenge|\/verify)?|wallets(?:\/challenge|\/verify|\/unlink)?)$/.test(
293
- path
294
- );
295
- }
296
- function isEvmChainId(value) {
297
- return /^eip155:[1-9][0-9]{0,15}$/.test(value);
298
- }
299
- var evmChainIdSchema = z2.custom(
300
- (value) => typeof value === "string" && isEvmChainId(value),
301
- 'Use an EVM chain ID such as "eip155:8453"'
302
- );
303
- var units = z2.string().regex(/^(0|[1-9][0-9]*)$/);
304
- var walletBalanceSchema = z2.object({
305
- /** Canonical CAIP-2 ID: `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` or `eip155:<chain ID>`. */
306
- chain: z2.string(),
307
- /** The canonical mint (base58) or EIP-55 contract address; null for the native coin. */
308
- token: z2.string().nullable(),
309
- /** Null only for an ERC-20 contract without `decimals()`. */
310
- decimals: z2.number().int().min(0).max(255).nullable(),
311
- /** The sum over `wallets`. */
312
- total: units,
313
- wallets: z2.array(z2.object({ address: z2.string(), amount: units }).strict()),
314
- /** Solana: the lowest slot the reads saw. EVM: the latest block when the read started (approximate). */
315
- at: z2.object({ kind: z2.enum(["slot", "block"]), number: units }).strict(),
316
- observedAt: z2.number().int().nonnegative()
317
- }).strict();
318
- function isWalletSignInRoute(path) {
319
- return /^\/v1\/auth\/wallet\/(?:start|verify)$/.test(path);
320
- }
321
-
322
- export {
323
- profileVisibilitySchema,
324
- avatarProviderSchema,
325
- profileDefaultProviderSchema,
326
- profileDefaultsSchema,
327
- avatarSeedSchema,
328
- profileAvatarSchema,
329
- profileSummarySchema,
330
- displayNameSchema,
331
- profileUpdateSchema,
332
- ownProfileSchema,
333
- profileCompletionQuerySchema,
334
- profileCompletionSchema,
335
- profileCompletionPageSchema,
336
- profileReferralSchema,
337
- profileSettingsSchema,
338
- profileSettingsInputSchema,
339
- profileModerationSchema,
340
- managedProfileSchema,
341
- AVATAR_UPLOAD_LIMIT,
342
- avatarUploadTypes,
343
- isProfileParticipantRoute,
344
- solanaAddressSchema,
345
- walletConnectionSchema,
346
- walletChallengeInputSchema,
347
- walletChallengeSchema,
348
- walletProofSchema,
349
- solanaBalanceSchema,
350
- walletChainSchema,
351
- cosmosNetworkSchema,
352
- cosmosChain,
353
- solanaMainnet,
354
- evmAddressSchema,
355
- cosmosAddressSchema,
356
- walletAddressInputSchema,
357
- walletMessageChallengeSchema,
358
- walletSignatureSchema,
359
- linkedWalletSchema,
360
- walletUnlinkInputSchema,
361
- walletAddressInput,
362
- WALLETS_PER_CHAIN,
363
- walletSignInFamilies,
364
- walletSignInNetworkSchema,
365
- walletSignInNetworksSchema,
366
- walletSignInNetwork,
367
- caip10,
368
- isWalletParticipantRoute,
369
- isEvmChainId,
370
- evmChainIdSchema,
371
- walletBalanceSchema,
372
- isWalletSignInRoute
373
- };