@domino-sdk/relay 1.72.0 → 1.74.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/CHANGELOG.md +25 -0
- package/dist/{accounts-COLmXRbW.d.ts → accounts-C9as33l1.d.ts} +2 -2
- package/dist/{attempt-captures-CVl161qB.d.ts → attempt-captures-DU4vi20Y.d.ts} +2 -2
- package/dist/authoring.d.ts +103 -106
- package/dist/authoring.js +187 -286
- package/dist/{automatic-outcomes-5l68PGr1.d.ts → automatic-outcomes-D0yMHSHL.d.ts} +2 -2
- package/dist/browser.d.ts +9 -9
- package/dist/browser.js +11 -11
- package/dist/{dashboards-DXpjHnq-.d.ts → capability-error-Bn6cCqof.d.ts} +298 -5
- package/dist/{catalog-BR3g-1H9.d.ts → catalog-9I6t18qP.d.ts} +2 -2
- package/dist/{chunk-W6DBNBMT.js → chunk-2LURSPDM.js} +232 -232
- package/dist/{chunk-VNEJH4NT.js → chunk-2M5FM7FW.js} +21 -0
- package/dist/{chunk-74SMLZZ5.js → chunk-6TDHRGBM.js} +1522 -1278
- package/dist/{chunk-QG6XVOOO.js → chunk-724CKAC7.js} +4 -4
- package/dist/{chunk-I7XIBXT2.js → chunk-7I7P5UVC.js} +3 -3
- package/dist/{chunk-LDO5GP7G.js → chunk-AL5XMXPO.js} +1 -1
- package/dist/{chunk-TW4RABVS.js → chunk-CW7FJ5PX.js} +1 -1
- package/dist/{chunk-BXUF3CRL.js → chunk-DNOLNMCW.js} +9 -9
- package/dist/{chunk-5RLIPTL7.js → chunk-E73HZCG2.js} +1 -1
- package/dist/{chunk-UEVZ3TST.js → chunk-ELHMJODS.js} +1 -1
- package/dist/{chunk-ASBDB436.js → chunk-F66GGNKD.js} +1 -1
- package/dist/{chunk-ETGKC2SB.js → chunk-HCOLMJFX.js} +2 -2
- package/dist/chunk-JZT2NLSG.js +7201 -0
- package/dist/{chunk-FGZGL5PG.js → chunk-KGZ7SRKJ.js} +2 -2
- package/dist/{chunk-3KKRXN5E.js → chunk-KP55TMCC.js} +1 -1
- package/dist/chunk-NI6XRGEL.js +374 -0
- package/dist/{chunk-VFHLMNYV.js → chunk-RALBAKKX.js} +1 -1
- package/dist/chunk-SVZ3QWHT.js +142 -0
- package/dist/{chunk-CVJTIVAP.js → chunk-T4PTFCSB.js} +2 -2
- package/dist/{chunk-KIRXE37T.js → chunk-TGQNNMCY.js} +6 -6
- package/dist/{client-B__hMWtK.d.ts → client-B2aVGf38.d.ts} +7 -7
- package/dist/{deployments-CT2kQloT.d.ts → deployments-CGV1rIZm.d.ts} +107 -107
- package/dist/{identity-integration-ClX4oUAu.d.ts → identity-integration-C03rUYc0.d.ts} +3 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/internal.d.ts +36197 -18
- package/dist/internal.js +518 -15
- package/dist/{limits-B7wbnWhd.d.ts → limits-p-Mg0oSi.d.ts} +1 -1
- package/dist/{offers-D4pyeY9b.d.ts → offers-CnMyMeQo.d.ts} +2 -2
- package/dist/portal-proxy.d.ts +2 -2
- package/dist/portal-proxy.js +10 -10
- package/dist/react/index.d.ts +11 -11
- package/dist/react/index.js +11 -11
- package/dist/{reward-deliveries-HGpj1VFz.d.ts → reward-deliveries-zWfsgc6m.d.ts} +1 -1
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/NYEWMPJH.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +35 -60
- package/dist/schema.js +10 -8
- package/dist/server/index.d.ts +13 -13
- package/dist/server/index.js +2972 -4528
- package/dist/{sign-in-providers-lbOXCF8N.d.ts → sign-in-providers-BG22ZZkl.d.ts} +2 -2
- package/dist/solana.d.ts +13 -13
- package/dist/solana.js +9 -9
- package/dist/stake-BSVjB3BJ.d.ts +254 -0
- package/dist/{station-check-in-qBiaftfE.d.ts → station-check-in-a1deSjbm.d.ts} +5 -5
- package/dist/{submission-input-U4aIkJuT.d.ts → submission-input-DBDLkTF8.d.ts} +2 -2
- package/dist/telegram.d.ts +7 -7
- package/dist/telegram.js +2 -2
- package/dist/testing.d.ts +159 -160
- package/dist/testing.js +47 -344
- package/dist/{tracker-data-2BYXZjsN.d.ts → tracker-data-Dwq9dWEm.d.ts} +474 -221
- package/dist/{transport-DcRXDZ1j.d.ts → transport-D77Rbf4D.d.ts} +77050 -74062
- package/dist/{wallet-BqswMAqZ.d.ts → wallet-CeqgtXNm.d.ts} +2 -7
- package/dist/{wallet-browser-B5r7u3xB.d.ts → wallet-browser-Cucpqn3F.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/capability-error-db7kO8-P.d.ts +0 -297
- package/dist/chunk-2UELTHW6.js +0 -467
- package/dist/chunk-GHBYWDEZ.js +0 -94
- package/dist/chunk-HN7DE2UN.js +0 -53
- package/dist/runtime/chunks/A7G5P76B.js +0 -1
package/dist/chunk-2UELTHW6.js
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createHttpExchange,
|
|
3
|
-
uncertainStatuses
|
|
4
|
-
} from "./chunk-ASBDB436.js";
|
|
5
|
-
import {
|
|
6
|
-
MANAGEMENT_TIMEOUT,
|
|
7
|
-
lifetime,
|
|
8
|
-
retrying,
|
|
9
|
-
validTimeout
|
|
10
|
-
} from "./chunk-ETGKC2SB.js";
|
|
11
|
-
import {
|
|
12
|
-
base58Bytes,
|
|
13
|
-
evmAddressSchema,
|
|
14
|
-
knownResponse,
|
|
15
|
-
solanaDevnet,
|
|
16
|
-
solanaMainnet
|
|
17
|
-
} from "./chunk-74SMLZZ5.js";
|
|
18
|
-
import {
|
|
19
|
-
RequestError,
|
|
20
|
-
isRequestError
|
|
21
|
-
} from "./chunk-VNEJH4NT.js";
|
|
22
|
-
|
|
23
|
-
// src/configuration.ts
|
|
24
|
-
function questConfiguration(release) {
|
|
25
|
-
return release.configuration ?? {
|
|
26
|
-
defaults: Object.fromEntries(
|
|
27
|
-
Object.entries(release.fields).map(([key, field]) => [
|
|
28
|
-
key,
|
|
29
|
-
field.default
|
|
30
|
-
])
|
|
31
|
-
),
|
|
32
|
-
overrides: { ...release.values },
|
|
33
|
-
preserved: Object.keys(release.values)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/wallet-signatures.ts
|
|
38
|
-
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
39
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
40
|
-
var text = /* @__PURE__ */ (() => new TextEncoder())();
|
|
41
|
-
var hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
42
|
-
function evmChecksumAddress(address) {
|
|
43
|
-
const lower = address.slice(2).toLowerCase();
|
|
44
|
-
const hash = hex(keccak_256(text.encode(lower)));
|
|
45
|
-
return "0x" + Array.from(
|
|
46
|
-
lower,
|
|
47
|
-
(character, index) => parseInt(hash[index], 16) >= 8 ? character.toUpperCase() : character
|
|
48
|
-
).join("");
|
|
49
|
-
}
|
|
50
|
-
function canonicalWalletAddress(chain, address) {
|
|
51
|
-
if (chain === "solana") {
|
|
52
|
-
return base58Bytes(address, 32) ? address : null;
|
|
53
|
-
}
|
|
54
|
-
if (!evmAddressSchema.safeParse(address).success) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
const digits = address.slice(2);
|
|
58
|
-
const checksummed = evmChecksumAddress(address);
|
|
59
|
-
const oneCase = digits === digits.toLowerCase() || digits === digits.toUpperCase();
|
|
60
|
-
return oneCase || checksummed === address ? checksummed : null;
|
|
61
|
-
}
|
|
62
|
-
function evmSigner(message, signature) {
|
|
63
|
-
if (!/^0x[0-9a-fA-F]{130}$/.test(signature)) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
const bytes = Uint8Array.from(
|
|
67
|
-
signature.slice(2).match(/../g),
|
|
68
|
-
(pair) => parseInt(pair, 16)
|
|
69
|
-
);
|
|
70
|
-
const v = bytes[64];
|
|
71
|
-
const recovery = v >= 27 ? v - 27 : v;
|
|
72
|
-
if (recovery !== 0 && recovery !== 1) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const body = text.encode(message);
|
|
76
|
-
const digest = keccak_256(
|
|
77
|
-
new Uint8Array([
|
|
78
|
-
...text.encode(`Ethereum Signed Message:
|
|
79
|
-
${body.length}`),
|
|
80
|
-
...body
|
|
81
|
-
])
|
|
82
|
-
);
|
|
83
|
-
try {
|
|
84
|
-
const key = secp256k1.Signature.fromBytes(bytes.slice(0, 64), "compact").addRecoveryBit(recovery).recoverPublicKey(digest).toBytes(false);
|
|
85
|
-
return "0x" + hex(keccak_256(key.slice(1)).slice(-20));
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async function walletSignatureValid(input) {
|
|
91
|
-
if (input.chain === "eip155") {
|
|
92
|
-
const signer = evmSigner(input.message, input.signature);
|
|
93
|
-
return signer !== null && signer === input.address.toLowerCase();
|
|
94
|
-
}
|
|
95
|
-
const key = base58Bytes(input.address, 32);
|
|
96
|
-
const signature = base58Bytes(input.signature, 64);
|
|
97
|
-
if (!key || !signature) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
const imported = await crypto.subtle.importKey(
|
|
102
|
-
"raw",
|
|
103
|
-
key,
|
|
104
|
-
"Ed25519",
|
|
105
|
-
false,
|
|
106
|
-
["verify"]
|
|
107
|
-
);
|
|
108
|
-
return await crypto.subtle.verify(
|
|
109
|
-
"Ed25519",
|
|
110
|
-
imported,
|
|
111
|
-
signature,
|
|
112
|
-
text.encode(input.message)
|
|
113
|
-
);
|
|
114
|
-
} catch {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// src/solana-rpc.ts
|
|
120
|
-
var solanaPublicEndpoints = {
|
|
121
|
-
[solanaMainnet]: "https://api.mainnet-beta.solana.com",
|
|
122
|
-
[solanaDevnet]: "https://api.devnet.solana.com"
|
|
123
|
-
};
|
|
124
|
-
async function solanaRpc(url, method, params) {
|
|
125
|
-
const response = await fetch(url, {
|
|
126
|
-
method: "POST",
|
|
127
|
-
headers: { "Content-Type": "application/json" },
|
|
128
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
129
|
-
signal: AbortSignal.timeout(3e4)
|
|
130
|
-
});
|
|
131
|
-
const answer = await response.json();
|
|
132
|
-
if (answer.error) {
|
|
133
|
-
throw new Error(answer.error.message ?? JSON.stringify(answer.error));
|
|
134
|
-
}
|
|
135
|
-
return answer.result;
|
|
136
|
-
}
|
|
137
|
-
async function confirmedSignature(url, signature, lastValidBlockHeight) {
|
|
138
|
-
for (; ; ) {
|
|
139
|
-
const {
|
|
140
|
-
value: [status]
|
|
141
|
-
} = await solanaRpc(url, "getSignatureStatuses", [[signature]]);
|
|
142
|
-
if (status?.err) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
if (status?.confirmationStatus === "confirmed" || status?.confirmationStatus === "finalized") {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
const height = await solanaRpc(url, "getBlockHeight", [
|
|
149
|
-
{ commitment: "confirmed" }
|
|
150
|
-
]);
|
|
151
|
-
if (height > lastValidBlockHeight) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/server/errors.ts
|
|
159
|
-
import * as z from "zod";
|
|
160
|
-
var ManagementErrorCode = {
|
|
161
|
-
/** The input or an option failed validation before anything was sent (kind `client`). */
|
|
162
|
-
InvalidInput: "invalid-input",
|
|
163
|
-
/** The client's `getToken` failed before anything was sent (kind `client` or `network`). */
|
|
164
|
-
Credential: "credential",
|
|
165
|
-
Network: "network",
|
|
166
|
-
Timeout: "timeout",
|
|
167
|
-
Aborted: "aborted",
|
|
168
|
-
InvalidResponse: "invalid-response"
|
|
169
|
-
};
|
|
170
|
-
var managementErrorSchema = /* @__PURE__ */ (() => z.looseObject({
|
|
171
|
-
error: z.string(),
|
|
172
|
-
code: z.string().optional()
|
|
173
|
-
}))();
|
|
174
|
-
function uncertainOutcome(init) {
|
|
175
|
-
if (init.method === void 0 || init.method === "GET") {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
switch (init.kind) {
|
|
179
|
-
case "network":
|
|
180
|
-
case "timeout":
|
|
181
|
-
case "aborted":
|
|
182
|
-
return true;
|
|
183
|
-
case "http":
|
|
184
|
-
return uncertainStatuses.has(init.status ?? 0);
|
|
185
|
-
case "invalid-response":
|
|
186
|
-
return (init.status ?? 0) >= 200 && (init.status ?? 0) < 300;
|
|
187
|
-
default:
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
var managementErrorBrand = /* @__PURE__ */ (() => /* @__PURE__ */ Symbol.for("@domino-sdk/relay.ManagementError"))();
|
|
192
|
-
function isManagementError(value) {
|
|
193
|
-
return isRequestError(value) && value[managementErrorBrand] === true;
|
|
194
|
-
}
|
|
195
|
-
var ManagementError = class extends RequestError {
|
|
196
|
-
name = "ManagementError";
|
|
197
|
-
[managementErrorBrand] = true;
|
|
198
|
-
/** The rest of the server's error body besides `error` and `code`, such as `moved`; absent when there is none. */
|
|
199
|
-
details;
|
|
200
|
-
/** The request's method; absent when the call failed before forming a request. */
|
|
201
|
-
method;
|
|
202
|
-
/** The management API path, below `/management/v1`, without its query; absent like `method`. */
|
|
203
|
-
path;
|
|
204
|
-
constructor(init) {
|
|
205
|
-
super(init.message, {
|
|
206
|
-
kind: init.kind,
|
|
207
|
-
uncertain: init.uncertain ?? uncertainOutcome(init),
|
|
208
|
-
status: init.status,
|
|
209
|
-
code: init.code,
|
|
210
|
-
operationId: init.actionId,
|
|
211
|
-
replaySafe: init.replaySafe,
|
|
212
|
-
retryAfter: init.retryAfter,
|
|
213
|
-
cause: init.cause
|
|
214
|
-
});
|
|
215
|
-
this.details = init.details && Object.keys(init.details).length ? init.details : void 0;
|
|
216
|
-
this.method = init.method;
|
|
217
|
-
this.path = init.path;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
var DEFAULT_MANAGEMENT_TIMEOUT = MANAGEMENT_TIMEOUT;
|
|
221
|
-
|
|
222
|
-
// src/server/transport.ts
|
|
223
|
-
import * as z2 from "zod";
|
|
224
|
-
var ManagementUploadBody = class {
|
|
225
|
-
constructor(body, headers, actionId) {
|
|
226
|
-
this.body = body;
|
|
227
|
-
this.headers = headers;
|
|
228
|
-
this.actionId = actionId;
|
|
229
|
-
}
|
|
230
|
-
body;
|
|
231
|
-
headers;
|
|
232
|
-
actionId;
|
|
233
|
-
};
|
|
234
|
-
function failureCause(error) {
|
|
235
|
-
if (typeof error !== "object" || error === null || !("cause" in error)) {
|
|
236
|
-
return {};
|
|
237
|
-
}
|
|
238
|
-
const { cause } = error;
|
|
239
|
-
return typeof cause === "object" && cause !== null ? cause : {};
|
|
240
|
-
}
|
|
241
|
-
function actionIdOf(input) {
|
|
242
|
-
if (input instanceof ManagementUploadBody) {
|
|
243
|
-
return input.actionId;
|
|
244
|
-
}
|
|
245
|
-
return typeof input === "object" && input !== null && "actionId" in input && typeof input.actionId === "string" ? input.actionId : void 0;
|
|
246
|
-
}
|
|
247
|
-
function unsent(error) {
|
|
248
|
-
const code = String(failureCause(error).code ?? "");
|
|
249
|
-
return /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|UND_ERR_CONNECT_TIMEOUT)$|CERT|TLS|SSL/.test(
|
|
250
|
-
code
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
function redirected(error) {
|
|
254
|
-
return /redirect/i.test(String(failureCause(error).message ?? ""));
|
|
255
|
-
}
|
|
256
|
-
function checkedTimeout(timeout) {
|
|
257
|
-
if (timeout !== void 0 && !validTimeout(timeout)) {
|
|
258
|
-
throw new ManagementError({
|
|
259
|
-
kind: "client",
|
|
260
|
-
code: ManagementErrorCode.InvalidInput,
|
|
261
|
-
message: "Management timeout must be a positive, finite number of milliseconds"
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return timeout;
|
|
265
|
-
}
|
|
266
|
-
function managementTransport(options) {
|
|
267
|
-
const clientTimeout = checkedTimeout(options.timeout) ?? DEFAULT_MANAGEMENT_TIMEOUT;
|
|
268
|
-
const redirect = options.redirect ? { redirect: options.redirect } : {};
|
|
269
|
-
const http = createHttpExchange(
|
|
270
|
-
{
|
|
271
|
-
baseUrl: `${options.baseUrl}/management/v1`,
|
|
272
|
-
headers: options.headers,
|
|
273
|
-
getToken: options.getToken,
|
|
274
|
-
fetch: options.fetch,
|
|
275
|
-
organization: options.organization,
|
|
276
|
-
project: options.project,
|
|
277
|
-
environment: options.environment
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
client: options.client,
|
|
281
|
-
credentialLast: true,
|
|
282
|
-
// A redirect fetch refused to follow was answered without being applied. The participant
|
|
283
|
-
// client has no such rule, so there a write that failed to connect stays uncertain.
|
|
284
|
-
neverSent: (error) => unsent(error) || redirected(error),
|
|
285
|
-
abortReason: true,
|
|
286
|
-
messages: {
|
|
287
|
-
aborted: "The management request was cancelled",
|
|
288
|
-
timeout: (milliseconds) => `The management request did not finish within ${milliseconds} ms`,
|
|
289
|
-
network: () => "The management request failed before Domino answered",
|
|
290
|
-
credential: "Could not get a management credential",
|
|
291
|
-
invalidToken: "getToken returned a value that is not a token",
|
|
292
|
-
invalidOptions: "Management headers, organization and project must be valid HTTP header values"
|
|
293
|
-
// No `unsendable`: a header or body that cannot be sent rejects with the platform's error.
|
|
294
|
-
},
|
|
295
|
-
makeError: (message, error, context) => new ManagementError({ ...context, ...error, message }),
|
|
296
|
-
// A body that is not the server's error JSON still rejects with the status.
|
|
297
|
-
parseRefusal: (body) => {
|
|
298
|
-
const parsed = managementErrorSchema.safeParse(body);
|
|
299
|
-
if (!parsed.success) {
|
|
300
|
-
return {};
|
|
301
|
-
}
|
|
302
|
-
const { error, code, ...details } = parsed.data;
|
|
303
|
-
return { message: error, code, details };
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
function callLifetime(call) {
|
|
308
|
-
return lifetime(
|
|
309
|
-
checkedTimeout(call?.timeout) ?? clientTimeout,
|
|
310
|
-
call?.signal ?? void 0
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
async function raw(path, init) {
|
|
314
|
-
const { timeout, signal, ...fetchInit } = init ?? {};
|
|
315
|
-
const life = callLifetime({ timeout, signal: signal ?? void 0 });
|
|
316
|
-
try {
|
|
317
|
-
return await http.send(
|
|
318
|
-
path,
|
|
319
|
-
{
|
|
320
|
-
method: fetchInit.method,
|
|
321
|
-
headers: fetchInit.headers,
|
|
322
|
-
body: fetchInit.body,
|
|
323
|
-
init: { ...fetchInit, ...redirect }
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
method: (fetchInit.method ?? "GET").toUpperCase(),
|
|
327
|
-
path: path.split("?")[0],
|
|
328
|
-
replaySafe: false
|
|
329
|
-
},
|
|
330
|
-
life
|
|
331
|
-
);
|
|
332
|
-
} finally {
|
|
333
|
-
life.end();
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
async function exchange(path, schema, input, method, call, replaySafe, tolerant = false) {
|
|
337
|
-
const actionId = actionIdOf(input);
|
|
338
|
-
const context = {
|
|
339
|
-
method,
|
|
340
|
-
replaySafe,
|
|
341
|
-
path: path.split("?")[0],
|
|
342
|
-
...actionId ? { actionId } : {}
|
|
343
|
-
};
|
|
344
|
-
const tolerance = tolerant ? { "X-Domino-Response": "tolerant-v1" } : {};
|
|
345
|
-
const request = input instanceof ManagementUploadBody ? {
|
|
346
|
-
method,
|
|
347
|
-
headers: {
|
|
348
|
-
"Content-Type": input.body.type,
|
|
349
|
-
...input.headers,
|
|
350
|
-
...tolerance
|
|
351
|
-
},
|
|
352
|
-
body: input.body,
|
|
353
|
-
init: redirect
|
|
354
|
-
} : { method, headers: tolerance, json: input, init: redirect };
|
|
355
|
-
const life = callLifetime(call);
|
|
356
|
-
try {
|
|
357
|
-
return await retrying(
|
|
358
|
-
life,
|
|
359
|
-
{ replaySafe: method === "GET" || replaySafe },
|
|
360
|
-
async () => {
|
|
361
|
-
const response = await http.send(path, request, context, life);
|
|
362
|
-
let body;
|
|
363
|
-
try {
|
|
364
|
-
body = response.status === 204 ? null : await response.json();
|
|
365
|
-
} catch (error) {
|
|
366
|
-
if (error instanceof SyntaxError && !life.signal.aborted) {
|
|
367
|
-
throw new ManagementError({
|
|
368
|
-
...context,
|
|
369
|
-
kind: "invalid-response",
|
|
370
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
371
|
-
status: response.status,
|
|
372
|
-
message: "Domino answered with a body that is not JSON",
|
|
373
|
-
cause: error
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
throw http.interrupted(error, method, context, life, {
|
|
377
|
-
sent: true,
|
|
378
|
-
status: response.status,
|
|
379
|
-
headers: response.headers
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
const parsed = knownResponse(schema).safeParse(
|
|
383
|
-
tolerant ? { status: response.status, operationId: actionId, result: body } : body
|
|
384
|
-
);
|
|
385
|
-
if (!parsed.success) {
|
|
386
|
-
throw new ManagementError({
|
|
387
|
-
...context,
|
|
388
|
-
kind: "invalid-response",
|
|
389
|
-
code: ManagementErrorCode.InvalidResponse,
|
|
390
|
-
status: response.status,
|
|
391
|
-
message: "Domino answered with a response this client does not recognize",
|
|
392
|
-
cause: parsed.error
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
return parsed.data;
|
|
396
|
-
}
|
|
397
|
-
);
|
|
398
|
-
} finally {
|
|
399
|
-
life.end();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const json = ({
|
|
403
|
-
path,
|
|
404
|
-
method,
|
|
405
|
-
body,
|
|
406
|
-
replaySafe
|
|
407
|
-
}) => exchange(
|
|
408
|
-
path,
|
|
409
|
-
z2.unknown(),
|
|
410
|
-
body,
|
|
411
|
-
method,
|
|
412
|
-
void 0,
|
|
413
|
-
method === "GET" || replaySafe
|
|
414
|
-
);
|
|
415
|
-
return { raw, exchange, json };
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// src/sequence-cursor.ts
|
|
419
|
-
import * as z3 from "zod";
|
|
420
|
-
var sequenceCursorSchema = /* @__PURE__ */ (() => z3.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z3.number().int().positive().safe()))();
|
|
421
|
-
|
|
422
|
-
// src/referral-reward-kinds.ts
|
|
423
|
-
var REFERRAL_INTEGRATION_REWARD_ERROR = "Referral programs can grant points and tiered rewards; Discord roles need a quest";
|
|
424
|
-
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
425
|
-
function containsReferralIntegrationReward(value) {
|
|
426
|
-
if (Array.isArray(value)) {
|
|
427
|
-
return value.some(
|
|
428
|
-
(reward) => isRecord(reward) && reward.kind === "integration"
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
if (!isRecord(value)) {
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
const definition = isRecord(value.definition) ? value.definition : value;
|
|
435
|
-
return isRecord(definition.rewards) && (containsReferralIntegrationReward(definition.rewards.inviter) || containsReferralIntegrationReward(definition.rewards.invitee)) || Array.isArray(definition.milestones) && definition.milestones.some(
|
|
436
|
-
(milestone) => isRecord(milestone) && containsReferralIntegrationReward(milestone.rewards)
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// src/csv.ts
|
|
441
|
-
var csvField = (value) => {
|
|
442
|
-
const text2 = value == null ? "" : String(value);
|
|
443
|
-
return /[",\r\n]/.test(text2) ? `"${text2.replaceAll('"', '""')}"` : text2;
|
|
444
|
-
};
|
|
445
|
-
var csvLines = (rows) => rows.map((fields) => fields.map(csvField).join(",")).join("\n");
|
|
446
|
-
|
|
447
|
-
export {
|
|
448
|
-
questConfiguration,
|
|
449
|
-
hex,
|
|
450
|
-
canonicalWalletAddress,
|
|
451
|
-
walletSignatureValid,
|
|
452
|
-
solanaPublicEndpoints,
|
|
453
|
-
solanaRpc,
|
|
454
|
-
confirmedSignature,
|
|
455
|
-
ManagementErrorCode,
|
|
456
|
-
managementErrorSchema,
|
|
457
|
-
isManagementError,
|
|
458
|
-
ManagementError,
|
|
459
|
-
DEFAULT_MANAGEMENT_TIMEOUT,
|
|
460
|
-
ManagementUploadBody,
|
|
461
|
-
actionIdOf,
|
|
462
|
-
managementTransport,
|
|
463
|
-
sequenceCursorSchema,
|
|
464
|
-
REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
465
|
-
containsReferralIntegrationReward,
|
|
466
|
-
csvLines
|
|
467
|
-
};
|
package/dist/chunk-GHBYWDEZ.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
capabilityFailureSchema
|
|
3
|
-
} from "./chunk-MWMCQLCG.js";
|
|
4
|
-
import {
|
|
5
|
-
attemptActionSchema,
|
|
6
|
-
contentPerformanceSnapshotSchema,
|
|
7
|
-
decisionSchema,
|
|
8
|
-
identifier,
|
|
9
|
-
rewardBundleSchema,
|
|
10
|
-
settingsValuesSchema,
|
|
11
|
-
trackerTriggerContextSchema
|
|
12
|
-
} from "./chunk-74SMLZZ5.js";
|
|
13
|
-
|
|
14
|
-
// src/server/attempt-captures.ts
|
|
15
|
-
import * as z from "zod";
|
|
16
|
-
var timestamp = /* @__PURE__ */ (() => z.number().int().nonnegative().safe())();
|
|
17
|
-
var capturedFactSchema = /* @__PURE__ */ (() => z.object({
|
|
18
|
-
/** The call's position in the run, from 0. */
|
|
19
|
-
sequence: z.number().int().nonnegative(),
|
|
20
|
-
/** The capability request quest code sent, after validation. */
|
|
21
|
-
request: z.record(z.string(), z.json()),
|
|
22
|
-
/**
|
|
23
|
-
* The answer every retry of the run receives: the result, or the failure quest code saw. Absent
|
|
24
|
-
* while the call has no answer, such as when the run stopped during it.
|
|
25
|
-
*/
|
|
26
|
-
outcome: z.union([
|
|
27
|
-
z.object({ value: z.json() }),
|
|
28
|
-
z.object({ error: capabilityFailureSchema })
|
|
29
|
-
]).optional(),
|
|
30
|
-
/**
|
|
31
|
-
* False when a retry of the run asks the provider again: a retryable failure Relay recorded but
|
|
32
|
-
* did not keep, or a call without an answer. A replay cannot answer such a call.
|
|
33
|
-
*/
|
|
34
|
-
captured: z.boolean()
|
|
35
|
-
}))();
|
|
36
|
-
var attemptCaptureSchema = /* @__PURE__ */ (() => z.object({
|
|
37
|
-
format: z.literal(1),
|
|
38
|
-
attempt: identifier,
|
|
39
|
-
environment: z.literal("test"),
|
|
40
|
-
quest: z.object({
|
|
41
|
-
id: identifier,
|
|
42
|
-
/** The quest's authoring key; null for a quest created in Console. */
|
|
43
|
-
key: identifier.nullable()
|
|
44
|
-
}),
|
|
45
|
-
release: identifier,
|
|
46
|
-
evaluationRun: z.number().int().nonnegative(),
|
|
47
|
-
/** The evaluator protocol the release was built for. */
|
|
48
|
-
protocol: z.number().int().positive(),
|
|
49
|
-
/** The seed of the run's `Math.random()` and `crypto.randomUUID()` streams. */
|
|
50
|
-
seed: z.string().min(1),
|
|
51
|
-
/** The run's frozen start time, `ctx.now`. */
|
|
52
|
-
now: timestamp,
|
|
53
|
-
context: z.object({
|
|
54
|
-
settings: settingsValuesSchema,
|
|
55
|
-
rewards: rewardBundleSchema,
|
|
56
|
-
humanReview: z.boolean(),
|
|
57
|
-
integrations: z.array(z.string()),
|
|
58
|
-
member: identifier,
|
|
59
|
-
input: z.record(z.string(), z.json()),
|
|
60
|
-
tracker: trackerTriggerContextSchema.nullable(),
|
|
61
|
-
/**
|
|
62
|
-
* The action that started the attempt, `ctx.action`. Absent from captures Relay made before it
|
|
63
|
-
* recorded actions.
|
|
64
|
-
*
|
|
65
|
-
* @experimental A minor release can change quest actions.
|
|
66
|
-
*/
|
|
67
|
-
action: attemptActionSchema.nullable().optional(),
|
|
68
|
-
/**
|
|
69
|
-
* The code station the member checked in at, for an attempt a station's code started: its
|
|
70
|
-
* `ctx.action` is `{ kind: "station-code", reference: station }`. Absent for any other attempt.
|
|
71
|
-
*
|
|
72
|
-
* @experimental A minor release can change check-in stations.
|
|
73
|
-
*/
|
|
74
|
-
station: z.string().optional(),
|
|
75
|
-
eligibleAt: timestamp,
|
|
76
|
-
calendar: z.object({
|
|
77
|
-
segments: z.array(
|
|
78
|
-
z.looseObject({ effectiveAt: timestamp, timeZone: z.string() })
|
|
79
|
-
)
|
|
80
|
-
}),
|
|
81
|
-
performance: contentPerformanceSnapshotSchema.nullable()
|
|
82
|
-
}),
|
|
83
|
-
facts: z.array(capturedFactSchema),
|
|
84
|
-
/**
|
|
85
|
-
* What quest code decided in the run, before Relay amended, claimed or reviewed it. Null while it
|
|
86
|
-
* has decided nothing, and for runs decided before Relay kept decisions.
|
|
87
|
-
*/
|
|
88
|
-
recorded: decisionSchema.nullable()
|
|
89
|
-
}))();
|
|
90
|
-
|
|
91
|
-
export {
|
|
92
|
-
capturedFactSchema,
|
|
93
|
-
attemptCaptureSchema
|
|
94
|
-
};
|
package/dist/chunk-HN7DE2UN.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
imageComparisonSchema,
|
|
3
|
-
imageExtractionSchema,
|
|
4
|
-
imageFieldsSchema,
|
|
5
|
-
imageInspectionSchema,
|
|
6
|
-
imageSightingsSchema
|
|
7
|
-
} from "./chunk-VFHLMNYV.js";
|
|
8
|
-
import {
|
|
9
|
-
photoResultSchema
|
|
10
|
-
} from "./chunk-74SMLZZ5.js";
|
|
11
|
-
|
|
12
|
-
// src/image-results.ts
|
|
13
|
-
import * as z from "zod";
|
|
14
|
-
var invalid = (message, path) => new z.ZodError([{ code: "custom", message, path, input: void 0 }]);
|
|
15
|
-
function parseImageExtraction(raw, value) {
|
|
16
|
-
const result = imageExtractionSchema.parse(value);
|
|
17
|
-
const fields = imageFieldsSchema.parse(raw);
|
|
18
|
-
for (const [key, field] of Object.entries(fields)) {
|
|
19
|
-
const extracted = result.values[key];
|
|
20
|
-
if (extracted === void 0) {
|
|
21
|
-
throw invalid("Image extraction omitted " + key, ["values", key]);
|
|
22
|
-
}
|
|
23
|
-
if (extracted !== null && typeof extracted !== field.type) {
|
|
24
|
-
throw invalid("Image extraction returned the wrong type for " + key, [
|
|
25
|
-
"values",
|
|
26
|
-
key
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (Object.keys(result.values).some((key) => !Object.hasOwn(fields, key))) {
|
|
31
|
-
throw invalid("Image extraction returned an undeclared field", ["values"]);
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
function parseImageResult(request, value) {
|
|
36
|
-
switch (request.operation) {
|
|
37
|
-
case "inspect":
|
|
38
|
-
return imageInspectionSchema.parse(value);
|
|
39
|
-
case "compare":
|
|
40
|
-
return imageComparisonSchema.parse(value);
|
|
41
|
-
case "review":
|
|
42
|
-
return photoResultSchema.parse(value);
|
|
43
|
-
case "extract":
|
|
44
|
-
return parseImageExtraction(request.fields, value);
|
|
45
|
-
case "seen":
|
|
46
|
-
return imageSightingsSchema.parse(value);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
parseImageExtraction,
|
|
52
|
-
parseImageResult
|
|
53
|
-
};
|