@domino-sdk/relay 0.29.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.
- package/dist/authoring.d.ts +2 -2
- package/dist/authoring.js +5 -2
- package/dist/browser.d.ts +186 -186
- package/dist/browser.js +5 -5
- package/dist/{chunk-5LLU7UUV.js → chunk-CB7RKKDX.js} +165 -739
- package/dist/{chunk-LAKQCIHX.js → chunk-CWIJDQDT.js} +165 -30
- package/dist/{chunk-YKS6P4IP.js → chunk-HINZLW46.js} +1 -1
- package/dist/chunk-TYYGYDYX.js +42 -0
- package/dist/{chunk-MVCKCDNR.js → chunk-UMKGCDBX.js} +2 -2
- package/dist/index.d.ts +396 -396
- package/dist/index.js +36 -36
- package/dist/portal-proxy.js +5 -5
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +5 -5
- package/dist/{submission-input-C0cOmO4Q.d.ts → submission-input-B6f27BHm.d.ts} +16 -1206
- package/package.json +1 -1
- package/dist/chunk-MRKFRCCI.js +0 -168
|
@@ -2,35 +2,146 @@ import {
|
|
|
2
2
|
identifier
|
|
3
3
|
} from "./chunk-BE5V6RFD.js";
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/profiles.ts
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
34
|
+
var profileSummarySchema = z.object({
|
|
18
35
|
id: identifier,
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
name: z.string(),
|
|
37
|
+
avatar: profileAvatarSchema
|
|
21
38
|
});
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
175
|
-
if (!
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
};
|
|
@@ -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-
|
|
3
|
+
} from "./chunk-CB7RKKDX.js";
|
|
4
4
|
import {
|
|
5
5
|
cosmosChain
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CWIJDQDT.js";
|
|
7
7
|
|
|
8
8
|
// src/base58.ts
|
|
9
9
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|