@domino-sdk/relay 0.28.0 → 0.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.
@@ -1,36 +1,147 @@
1
1
  import {
2
2
  identifier
3
- } from "./chunk-IXLY3A7B.js";
3
+ } from "./chunk-BE5V6RFD.js";
4
4
 
5
- // src/auth.ts
5
+ // src/profiles.ts
6
6
  import { z } from "zod";
7
- var authScopeSchema = z.object({
8
- organization: identifier,
9
- project: identifier,
10
- environment: z.enum(["test", "live"])
11
- }).strict();
12
- var principalSchema = z.discriminatedUnion("kind", [
13
- z.object({ kind: z.literal("member"), member: identifier }).strict(),
14
- z.object({ kind: z.literal("staff"), subject: identifier }).strict(),
15
- z.object({ kind: z.literal("operator"), subject: identifier }).strict()
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 })
16
33
  ]);
17
- var sessionSchema = authScopeSchema.extend({
34
+ var profileSummarySchema = z.object({
18
35
  id: identifier,
19
- principal: principalSchema,
20
- expiresAt: z.number()
36
+ name: z.string(),
37
+ avatar: profileAvatarSchema
21
38
  });
22
- var memberSummarySchema = z.object({
23
- member: identifier,
24
- avatarSeed: z.string().min(1).max(100)
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
+ )
25
77
  });
26
- var exchangeSchema = authScopeSchema.extend({
27
- identity: z.object({ issuer: identifier, subject: z.string().min(1).max(200) }).strict(),
28
- role: z.enum(["member", "staff", "operator"])
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()
29
82
  }).strict();
30
- var exchangeResultSchema = z.object({
31
- token: z.string(),
32
- session: sessionSchema
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()
33
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
+ }
34
145
 
35
146
  // src/wallet.ts
36
147
  import { z as z2 } from "zod";
@@ -171,8 +282,8 @@ function caip10(wallet, network) {
171
282
  return `${wallet.network}:${wallet.address}`;
172
283
  }
173
284
  const selected = network ?? (wallet.chain === "solana" ? solanaMainnet : "eip155:1");
174
- const syntax = wallet.chain === "solana" ? /^solana:[1-9A-HJ-NP-Za-km-z]{32}$/ : /^eip155:[1-9][0-9]{0,15}$/;
175
- if (!syntax.test(selected)) {
285
+ const valid = wallet.chain === "solana" ? /^solana:[1-9A-HJ-NP-Za-km-z]{32}$/.test(selected) : isEvmChainId(selected);
286
+ if (!valid) {
176
287
  throw new Error(`Use a ${wallet.chain} network for this wallet`);
177
288
  }
178
289
  return `${selected}:${wallet.address}`;
@@ -182,6 +293,13 @@ function isWalletParticipantRoute(path) {
182
293
  path
183
294
  );
184
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
+ );
185
303
  var units = z2.string().regex(/^(0|[1-9][0-9]*)$/);
186
304
  var walletBalanceSchema = z2.object({
187
305
  /** Canonical CAIP-2 ID: `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` or `eip155:<chain ID>`. */
@@ -202,12 +320,27 @@ function isWalletSignInRoute(path) {
202
320
  }
203
321
 
204
322
  export {
205
- authScopeSchema,
206
- principalSchema,
207
- sessionSchema,
208
- memberSummarySchema,
209
- exchangeSchema,
210
- exchangeResultSchema,
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,
211
344
  solanaAddressSchema,
212
345
  walletConnectionSchema,
213
346
  walletChallengeInputSchema,
@@ -233,6 +366,8 @@ export {
233
366
  walletSignInNetwork,
234
367
  caip10,
235
368
  isWalletParticipantRoute,
369
+ isEvmChainId,
370
+ evmChainIdSchema,
236
371
  walletBalanceSchema,
237
372
  isWalletSignInRoute
238
373
  };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  profileSummarySchema
3
- } from "./chunk-D6BX627V.js";
3
+ } from "./chunk-CWIJDQDT.js";
4
4
  import {
5
5
  contentMetricSchema,
6
6
  contentMetricsSchema,
7
7
  identifier,
8
8
  pointsRewardSchema,
9
9
  tierRewardSchema
10
- } from "./chunk-IXLY3A7B.js";
10
+ } from "./chunk-BE5V6RFD.js";
11
11
 
12
12
  // src/engagement.ts
13
13
  import { z } from "zod";
@@ -447,6 +447,16 @@ var leaderboardPageSchema = z4.object({
447
447
  nearby: z4.array(leaderboardRowSchema),
448
448
  nextCursor: z4.string().nullable()
449
449
  });
450
+ var leaderboardPlacementSchema = z4.object({
451
+ leaderboard: identifier,
452
+ key: identifier.optional(),
453
+ title: z4.string(),
454
+ profile: identifier,
455
+ rank: integer.positive().nullable(),
456
+ score: integer.nullable(),
457
+ /** Ranked participants on the board. */
458
+ total: integer.nonnegative()
459
+ });
450
460
  var leaderboardPreviewSchema = z4.object({
451
461
  published: publishedLeaderboardSchema,
452
462
  before: leaderboardPageSchema.nullable(),
@@ -601,6 +611,7 @@ export {
601
611
  leaderboardQuerySchema,
602
612
  leaderboardRowSchema,
603
613
  leaderboardPageSchema,
614
+ leaderboardPlacementSchema,
604
615
  leaderboardPreviewSchema,
605
616
  pointsMutationSchema,
606
617
  pointsEntrySchema,
@@ -0,0 +1,42 @@
1
+ import {
2
+ identifier
3
+ } from "./chunk-BE5V6RFD.js";
4
+
5
+ // src/auth.ts
6
+ import { z } from "zod";
7
+ var authScopeSchema = z.object({
8
+ organization: identifier,
9
+ project: identifier,
10
+ environment: z.enum(["test", "live"])
11
+ }).strict();
12
+ var principalSchema = z.discriminatedUnion("kind", [
13
+ z.object({ kind: z.literal("member"), member: identifier }).strict(),
14
+ z.object({ kind: z.literal("staff"), subject: identifier }).strict(),
15
+ z.object({ kind: z.literal("operator"), subject: identifier }).strict()
16
+ ]);
17
+ var sessionSchema = authScopeSchema.extend({
18
+ id: identifier,
19
+ principal: principalSchema,
20
+ expiresAt: z.number()
21
+ });
22
+ var memberSummarySchema = z.object({
23
+ member: identifier,
24
+ avatarSeed: z.string().min(1).max(100)
25
+ });
26
+ var exchangeSchema = authScopeSchema.extend({
27
+ identity: z.object({ issuer: identifier, subject: z.string().min(1).max(200) }).strict(),
28
+ role: z.enum(["member", "staff", "operator"])
29
+ }).strict();
30
+ var exchangeResultSchema = z.object({
31
+ token: z.string(),
32
+ session: sessionSchema
33
+ });
34
+
35
+ export {
36
+ authScopeSchema,
37
+ principalSchema,
38
+ sessionSchema,
39
+ memberSummarySchema,
40
+ exchangeSchema,
41
+ exchangeResultSchema
42
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createRelayClient
3
- } from "./chunk-ZP43MHO3.js";
3
+ } from "./chunk-CB7RKKDX.js";
4
4
  import {
5
5
  cosmosChain
6
- } from "./chunk-AL5GXMKI.js";
6
+ } from "./chunk-CWIJDQDT.js";
7
7
 
8
8
  // src/base58.ts
9
9
  var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";