@domino-sdk/relay 1.73.0 → 1.75.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 (69) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/{accounts-0ynaUjt0.d.ts → accounts-C9as33l1.d.ts} +4 -4
  3. package/dist/{attempt-captures-DlR6J8Dd.d.ts → attempt-captures-DU4vi20Y.d.ts} +2 -2
  4. package/dist/authoring.d.ts +13 -13
  5. package/dist/authoring.js +4 -4
  6. package/dist/{automatic-outcomes-B1xDz9JR.d.ts → automatic-outcomes-D0yMHSHL.d.ts} +2 -2
  7. package/dist/browser.d.ts +10 -10
  8. package/dist/browser.js +8 -8
  9. package/dist/{capability-error-CYTmnCtI.d.ts → capability-error-D56xxE2i.d.ts} +5 -5
  10. package/dist/{catalog-D5EYZsX6.d.ts → catalog-9I6t18qP.d.ts} +2 -2
  11. package/dist/{chunk-CW7FJ5PX.js → chunk-3KHVIUKK.js} +1 -1
  12. package/dist/{chunk-O5KGY6SP.js → chunk-4WODSE6Y.js} +232 -232
  13. package/dist/{chunk-ELHMJODS.js → chunk-7B7MDHJ6.js} +1 -1
  14. package/dist/{chunk-6TDHRGBM.js → chunk-7QHROIML.js} +3 -0
  15. package/dist/{chunk-NAFLHTRY.js → chunk-CEG67D4T.js} +1 -1
  16. package/dist/chunk-E2DB4MKM.js +7295 -0
  17. package/dist/chunk-FBS65R66.js +142 -0
  18. package/dist/{chunk-KP55TMCC.js → chunk-HEQ7HLXG.js} +1 -1
  19. package/dist/{chunk-TGQNNMCY.js → chunk-IMX45NSW.js} +6 -6
  20. package/dist/{chunk-RALBAKKX.js → chunk-K3PEQXDV.js} +1 -1
  21. package/dist/{chunk-7I7P5UVC.js → chunk-SIKP4VMU.js} +56 -7
  22. package/dist/{chunk-NI6XRGEL.js → chunk-SPLXHFVX.js} +2 -2
  23. package/dist/{chunk-KGZ7SRKJ.js → chunk-TAZ5AEYF.js} +1 -1
  24. package/dist/{chunk-TF52WMQL.js → chunk-UHYKKC5U.js} +9 -8
  25. package/dist/{chunk-T4PTFCSB.js → chunk-XEXB3WZE.js} +1 -1
  26. package/dist/{chunk-OBPT6RBU.js → chunk-XJCKQSFS.js} +4 -3
  27. package/dist/{chunk-XLDAVVK2.js → chunk-ZEYI662X.js} +3 -3
  28. package/dist/{client-CFLNrX4Z.d.ts → client-336yROej.d.ts} +8 -8
  29. package/dist/{deployments-D8zg4ZF2.d.ts → deployments-CGV1rIZm.d.ts} +3 -3
  30. package/dist/{identity-integration-Bf2Gk33g.d.ts → identity-integration-DnSgQjbY.d.ts} +5 -3
  31. package/dist/index.d.ts +11 -11
  32. package/dist/index.js +7 -7
  33. package/dist/internal.d.ts +35347 -20
  34. package/dist/internal.js +514 -17
  35. package/dist/{limits-tAQm4GCJ.d.ts → limits-DICxln-i.d.ts} +9 -3
  36. package/dist/{offers-C0gBIxI0.d.ts → offers-CnMyMeQo.d.ts} +2 -2
  37. package/dist/portal-proxy.d.ts +9 -2
  38. package/dist/portal-proxy.js +125 -50
  39. package/dist/{profiles-DjOGwqm8.d.ts → profiles-CLDKZVFx.d.ts} +2 -2
  40. package/dist/react/index.d.ts +11 -11
  41. package/dist/react/index.js +8 -8
  42. package/dist/{reward-deliveries-Cr8IN_UG.d.ts → reward-deliveries-zWfsgc6m.d.ts} +1 -1
  43. package/dist/runtime/authoring.js +1 -1
  44. package/dist/runtime/chunks/H6GH644T.js +1 -0
  45. package/dist/runtime/manifest.json +3 -3
  46. package/dist/runtime/schema.js +1 -1
  47. package/dist/schema.d.ts +20 -77
  48. package/dist/schema.js +7 -7
  49. package/dist/server/index.d.ts +14 -14
  50. package/dist/server/index.js +3028 -4501
  51. package/dist/{sign-in-providers-gcJ5lRcX.d.ts → sign-in-providers-BMtk_NWY.d.ts} +2 -2
  52. package/dist/solana.d.ts +14 -14
  53. package/dist/solana.js +8 -8
  54. package/dist/stake-BSVjB3BJ.d.ts +254 -0
  55. package/dist/{station-check-in-D1v_RJ4G.d.ts → station-check-in-vcDKQOet.d.ts} +5 -5
  56. package/dist/{submission-input-BmzJu3w9.d.ts → submission-input-D_NiBR0W.d.ts} +9 -4
  57. package/dist/telegram.d.ts +8 -8
  58. package/dist/testing.d.ts +4 -4
  59. package/dist/testing.js +16 -8
  60. package/dist/{tracker-data-qMsOa5Dp.d.ts → tracker-data-Dwq9dWEm.d.ts} +75 -3
  61. package/dist/{transport-DSE0GUUl.d.ts → transport-BMwM6JlS.d.ts} +72491 -69151
  62. package/dist/{wallet-BgUIA3IN.d.ts → wallet-CeqgtXNm.d.ts} +2 -2
  63. package/dist/{wallet-browser-C2LVqgmB.d.ts → wallet-browser-Cucpqn3F.d.ts} +1 -1
  64. package/package.json +2 -1
  65. package/dist/chunk-4YN4QROW.js +0 -94
  66. package/dist/chunk-MYLLSM6I.js +0 -53
  67. package/dist/chunk-NX7CRWVX.js +0 -467
  68. package/dist/nfts-BagOxV_E.d.ts +0 -106
  69. package/dist/runtime/chunks/NYEWMPJH.js +0 -1
@@ -1057,5 +1057,5 @@ interface WalletReader {
1057
1057
  stake?(query: WalletStakeQuery): Promise<WalletStake | null>;
1058
1058
  }
1059
1059
 
1060
- export { solanaSignatureSchema as a$, walletTransactionsSchema as aA, walletProgramAccountSchema as aB, walletStakeSchema as aC, WALLETS_PER_CHAIN as aO, anchorIdlSchema as aP, caip10 as aQ, cosmosAddressSchema as aR, cosmosChain as aS, evmAddressSchema as aT, evmChainIdSchema as aU, isSolanaNetwork as aV, maxSolanaSeeds as aW, solanaAddressSchema as aX, solanaMemoProgram as aY, solanaProgramIdlSchema as aZ, solanaSeedSchema as a_, cosmosDenomSchema as ab, cosmosNetworkSchema as ac, isContractCall as ad, isContractEvent as ae, isEvmAddress as af, isEvmChainId as ag, isNftCollection as ah, isSolanaProgram as ai, maxWalletEventLogs as aj, maxWalletEventLookback as ak, maxWalletTransactionLookback as al, maxWalletTransactions as am, parseContractCall as an, parseContractEvent as ao, parseContractFunction as ap, parseNftCollection as aq, walletAddressInputSchema as ar, walletSignatureSchema as as, walletTransactionProofSchema as at, linkedWalletSchema as au, walletBalanceSchema as av, walletNftsSchema as aw, walletCallSchema as ax, walletDelegationsSchema as ay, walletEventsSchema as az, solanaTransactionFixtureInputSchema as b0, walletAddressInput as b1, walletBalanceSampleSchema as b2, walletChainSchema as b3, walletMessageChallengeSchema as b4, walletProgramActivitySchema as b5, walletSignInFamilies as b6, walletSignInNetwork as b7, walletSignInNetworkSchema as b8, walletSignInNetworksSchema as b9, walletTransactionChallengeSchema as ba, walletUnlinkInputSchema as bb, evmWalletOn as bc, solanaMainnet as n, solanaDevnet as s };
1061
- export type { WalletNftSample as $, ContractCallReturnType as A, ContractEventInput as B, CosmosChain as C, ContractEventParts as D, ContractFunction as E, CosmosDenom as F, EvmChainId as G, NftCollectionParts as H, NftStandard as I, SolanaSeedInteger as J, WalletBalance as K, LinkedWallet as L, WalletBalanceChange as M, NftCollection as N, WalletBalanceQuery as O, WalletBalanceSample as P, WalletCall as Q, WalletCallArgument as R, SolanaIdlSource as S, WalletCallQuery as T, WalletDelegations as U, WalletDelegationsQuery as V, WalletAddressInput as W, WalletEventCondition as X, WalletEventValue as Y, WalletEvents as Z, WalletEventsQuery as _, CosmosNetwork as a, WalletNfts as a0, WalletNftsQuery as a1, WalletProgramAccount as a2, WalletProgramAccountQuery as a3, WalletProgramAccountSample as a4, WalletProgramActivity as a5, WalletStake as a6, WalletStakeQuery as a7, WalletStakeSample as a8, WalletTransactions as a9, SolanaCollectionKind as aD, ProgramAccountPointKind as aE, StakePointKind as aF, AnchorIdl as aG, KnownProgramAccountPointKind as aH, KnownSolanaCollectionKind as aI, KnownSolanaIdlSource as aJ, KnownStakePointKind as aK, KnownWalletProofKind as aL, SolanaProgramIdl as aM, SolanaTransactionFixtureInput as aN, WalletTransactionsQuery as aa, WalletChain as b, WalletMessageChallenge as c, WalletProofKind as d, WalletSignInNetwork as e, WalletSignature as f, WalletSigner as g, WalletTransactionChallenge as h, WalletTransactionProof as i, WalletUnlinkInput as j, WalletBalanceSourceQuery as k, WalletNftSourceQuery as l, SolanaNetwork as m, SolanaSeed as o, ContractCall as p, ContractEvent as q, SolanaProgram as r, WalletProgramActivitySourceQuery as t, WalletStakeSourceQuery as u, WalletProgramAccountSourceQuery as v, WalletTransaction as w, WalletInstruction as x, WalletReader as y, ContractCallParts as z };
1060
+ export { walletEventsSchema as a$, WALLETS_PER_CHAIN as aF, anchorIdlSchema as aG, caip10 as aH, cosmosAddressSchema as aI, cosmosChain as aJ, evmAddressSchema as aK, evmChainIdSchema as aL, isSolanaNetwork as aM, linkedWalletSchema as aN, maxSolanaSeeds as aO, solanaAddressSchema as aP, solanaMemoProgram as aQ, solanaProgramIdlSchema as aR, solanaSeedSchema as aS, solanaSignatureSchema as aT, solanaTransactionFixtureInputSchema as aU, walletAddressInput as aV, walletBalanceSampleSchema as aW, walletBalanceSchema as aX, walletCallSchema as aY, walletChainSchema as aZ, walletDelegationsSchema as a_, cosmosDenomSchema as ab, cosmosNetworkSchema as ac, isContractCall as ad, isContractEvent as ae, isEvmAddress as af, isEvmChainId as ag, isNftCollection as ah, isSolanaProgram as ai, maxWalletEventLogs as aj, maxWalletEventLookback as ak, maxWalletTransactionLookback as al, maxWalletTransactions as am, parseContractCall as an, parseContractEvent as ao, parseContractFunction as ap, parseNftCollection as aq, walletAddressInputSchema as ar, walletSignatureSchema as as, walletTransactionProofSchema as at, walletMessageChallengeSchema as b0, walletNftsSchema as b1, walletProgramAccountSchema as b2, walletProgramActivitySchema as b3, walletSignInFamilies as b4, walletSignInNetwork as b5, walletSignInNetworkSchema as b6, walletSignInNetworksSchema as b7, walletStakeSchema as b8, walletTransactionChallengeSchema as b9, walletTransactionsSchema as ba, walletUnlinkInputSchema as bb, evmWalletOn as bc, solanaMainnet as l, solanaDevnet as s };
1061
+ export type { WalletNftSample as $, ContractCallReturnType as A, ContractEventInput as B, CosmosChain as C, ContractEventParts as D, ContractFunction as E, CosmosDenom as F, EvmChainId as G, NftCollectionParts as H, NftStandard as I, SolanaSeedInteger as J, WalletBalance as K, LinkedWallet as L, WalletBalanceChange as M, NftCollection as N, WalletBalanceQuery as O, WalletBalanceSample as P, WalletCall as Q, WalletCallArgument as R, SolanaIdlSource as S, WalletCallQuery as T, WalletDelegations as U, WalletDelegationsQuery as V, WalletAddressInput as W, WalletEventCondition as X, WalletEventValue as Y, WalletEvents as Z, WalletEventsQuery as _, CosmosNetwork as a, WalletNfts as a0, WalletNftsQuery as a1, WalletProgramAccount as a2, WalletProgramAccountQuery as a3, WalletProgramAccountSample as a4, WalletProgramActivity as a5, WalletStake as a6, WalletStakeQuery as a7, WalletStakeSample as a8, WalletTransactions as a9, KnownSolanaIdlSource as aA, KnownStakePointKind as aB, KnownWalletProofKind as aC, SolanaProgramIdl as aD, SolanaTransactionFixtureInput as aE, WalletTransactionsQuery as aa, SolanaCollectionKind as au, ProgramAccountPointKind as av, StakePointKind as aw, AnchorIdl as ax, KnownProgramAccountPointKind as ay, KnownSolanaCollectionKind as az, WalletChain as b, WalletMessageChallenge as c, WalletProofKind as d, WalletSignInNetwork as e, WalletSignature as f, WalletSigner as g, WalletTransactionChallenge as h, WalletTransactionProof as i, WalletUnlinkInput as j, SolanaNetwork as k, SolanaSeed as m, ContractCall as n, ContractEvent as o, SolanaProgram as p, WalletBalanceSourceQuery as q, WalletProgramActivitySourceQuery as r, WalletNftSourceQuery as t, WalletStakeSourceQuery as u, WalletProgramAccountSourceQuery as v, WalletTransaction as w, WalletInstruction as x, WalletReader as y, ContractCallParts as z };
@@ -1,4 +1,4 @@
1
- import { C as CosmosChain, a as CosmosNetwork, g as WalletSigner, e as WalletSignInNetwork } from './wallet-BgUIA3IN.js';
1
+ import { C as CosmosChain, a as CosmosNetwork, g as WalletSigner, e as WalletSignInNetwork } from './wallet-CeqgtXNm.js';
2
2
 
3
3
  /** An EIP-1193 provider, such as `window.ethereum` or an EIP-6963 announcement's provider. */
4
4
  type Eip1193Provider = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domino-sdk/relay",
3
- "version": "1.73.0",
3
+ "version": "1.75.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -100,6 +100,7 @@
100
100
  "react-dom": "19.3.0",
101
101
  "rollup": "4.63.3",
102
102
  "rollup-plugin-dts": "6.5.1",
103
+ "tsup": "8.5.1",
103
104
  "typescript": "6.0.2"
104
105
  },
105
106
  "license": "UNLICENSED",
@@ -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-6TDHRGBM.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
- };
@@ -1,53 +0,0 @@
1
- import {
2
- imageComparisonSchema,
3
- imageExtractionSchema,
4
- imageFieldsSchema,
5
- imageInspectionSchema,
6
- imageSightingsSchema
7
- } from "./chunk-RALBAKKX.js";
8
- import {
9
- photoResultSchema
10
- } from "./chunk-6TDHRGBM.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
- };
@@ -1,467 +0,0 @@
1
- import {
2
- createHttpExchange,
3
- uncertainStatuses
4
- } from "./chunk-NAFLHTRY.js";
5
- import {
6
- MANAGEMENT_TIMEOUT,
7
- lifetime,
8
- retrying,
9
- validTimeout
10
- } from "./chunk-OBPT6RBU.js";
11
- import {
12
- base58Bytes,
13
- evmAddressSchema,
14
- knownResponse,
15
- solanaDevnet,
16
- solanaMainnet
17
- } from "./chunk-6TDHRGBM.js";
18
- import {
19
- RequestError,
20
- isRequestError
21
- } from "./chunk-2M5FM7FW.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
- };