@domino-sdk/relay 1.69.0 → 1.71.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 +28 -0
- package/build.mjs +3 -0
- package/dist/{accounts-DD4gAOCe.d.ts → accounts-COLmXRbW.d.ts} +144 -13
- package/dist/{attempt-captures-CbuCmthd.d.ts → attempt-captures-CVl161qB.d.ts} +3 -2
- package/dist/authoring.d.ts +68 -25
- package/dist/authoring.js +15 -9
- package/dist/{automatic-outcomes-DE3vfi8g.d.ts → automatic-outcomes-5l68PGr1.d.ts} +2 -2
- package/dist/browser.d.ts +9 -9
- package/dist/browser.js +11 -9
- package/dist/{catalog-Cf3fHDNn.d.ts → catalog-BR3g-1H9.d.ts} +41 -2
- package/dist/{chunk-ME2KUAVJ.js → chunk-3KKRXN5E.js} +1 -1
- package/dist/{chunk-CQVKOD3B.js → chunk-74SMLZZ5.js} +723 -685
- package/dist/{chunk-CZ23KRVK.js → chunk-CVJTIVAP.js} +1 -1
- package/dist/{chunk-TCREFRPK.js → chunk-DDID5QX5.js} +153 -4
- package/dist/{chunk-WVK3G2J2.js → chunk-EMKYDGZ3.js} +1 -1
- package/dist/{chunk-2A3BJ262.js → chunk-FGZGL5PG.js} +1 -1
- package/dist/{chunk-GEVARKEV.js → chunk-GHBYWDEZ.js} +8 -1
- package/dist/{chunk-RKTMSTT7.js → chunk-HN7DE2UN.js} +2 -2
- package/dist/{chunk-LGGD7S5T.js → chunk-IDG2VPYG.js} +32 -6
- package/dist/{chunk-SWLW4VN3.js → chunk-KC4UB4ZX.js} +1 -1
- package/dist/{chunk-ODJGTFPY.js → chunk-KIRXE37T.js} +6 -6
- package/dist/{chunk-VAGGGB6B.js → chunk-MDSSIOBC.js} +58 -1
- package/dist/{chunk-BRROI4CH.js → chunk-OFSJYXGI.js} +12 -4
- package/dist/{chunk-LZXDYSUH.js → chunk-PYZSCFMJ.js} +4 -0
- package/dist/{chunk-UGM6DUB2.js → chunk-QMKTYPK6.js} +4 -3
- package/dist/{chunk-PO2ZDY27.js → chunk-TW4RABVS.js} +1 -1
- package/dist/{chunk-AZDZEQFK.js → chunk-UEVZ3TST.js} +29 -2
- package/dist/{chunk-DIXYVGXO.js → chunk-VFHLMNYV.js} +1 -1
- package/dist/{chunk-WNEQEDMU.js → chunk-W6DBNBMT.js} +2 -2
- package/dist/{client-6eSYOl8h.d.ts → client-B__hMWtK.d.ts} +104 -7
- package/dist/{dashboards-DCOAXL54.d.ts → dashboards-DXpjHnq-.d.ts} +3 -3
- package/dist/{deployments-BIfdCMd5.d.ts → deployments-CT2kQloT.d.ts} +199 -3
- package/dist/{identity-integration-BlfOn8rc.d.ts → identity-integration-ClX4oUAu.d.ts} +4 -4
- package/dist/index.d.ts +10 -10
- package/dist/index.js +7 -7
- package/dist/internal.d.ts +44 -26
- package/dist/internal.js +26 -50
- package/dist/{limits-Ctaeq23J.d.ts → limits-B7wbnWhd.d.ts} +1 -1
- package/dist/{offers-COqHGbHm.d.ts → offers-D4pyeY9b.d.ts} +2 -2
- package/dist/portal-proxy.d.ts +2 -2
- package/dist/portal-proxy.js +11 -10
- package/dist/react/index.d.ts +31 -12
- package/dist/react/index.js +116 -41
- package/dist/{reward-deliveries-DFhYGJdx.d.ts → reward-deliveries-HGpj1VFz.d.ts} +1 -1
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/A7G5P76B.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +40 -16
- package/dist/schema.js +9 -7
- package/dist/server/index.d.ts +12 -12
- package/dist/server/index.js +944 -579
- package/dist/{sign-in-providers-C97mRNbG.d.ts → sign-in-providers-lbOXCF8N.d.ts} +2 -2
- package/dist/solana.d.ts +12 -12
- package/dist/solana.js +8 -8
- package/dist/{telegram-browser-gRMgGs7B.d.ts → station-check-in-qBiaftfE.d.ts} +89 -7
- package/dist/{submission-input-BD7nORuh.d.ts → submission-input-U4aIkJuT.d.ts} +2 -2
- package/dist/telegram.d.ts +7 -7
- package/dist/testing.d.ts +15 -11
- package/dist/testing.js +23 -12
- package/dist/{tracker-data-DQgX3FIc.d.ts → tracker-data-2BYXZjsN.d.ts} +3 -3
- package/dist/{transport-BLU8jrhg.d.ts → transport-fszraZPi.d.ts} +1736 -19
- package/dist/{wallet-CPAjrW4k.d.ts → wallet-BqswMAqZ.d.ts} +3 -1
- package/dist/{wallet-browser-BzPt_Qb5.d.ts → wallet-browser-B5r7u3xB.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/runtime/chunks/HKAI5OQA.js +0 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IDG2VPYG.js";
|
|
4
4
|
import {
|
|
5
5
|
connectSolanaAccount,
|
|
6
6
|
noAccount,
|
|
7
|
+
parseStationCodeLink,
|
|
7
8
|
registeredWallets
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MDSSIOBC.js";
|
|
10
|
+
import {
|
|
11
|
+
sessionMember
|
|
12
|
+
} from "./chunk-TW4RABVS.js";
|
|
9
13
|
import {
|
|
10
14
|
base58,
|
|
11
15
|
cosmosChain
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-74SMLZZ5.js";
|
|
13
17
|
import {
|
|
14
18
|
RelayErrorCode,
|
|
15
19
|
asRelayError,
|
|
16
|
-
clientError
|
|
20
|
+
clientError,
|
|
21
|
+
isRelayError
|
|
17
22
|
} from "./chunk-VNEJH4NT.js";
|
|
18
23
|
|
|
19
24
|
// src/wallet-browser.ts
|
|
@@ -515,6 +520,141 @@ function memberTime(me, at = Date.now()) {
|
|
|
515
520
|
return at + (me.clock?.offsetMs ?? 0);
|
|
516
521
|
}
|
|
517
522
|
|
|
523
|
+
// src/refusal.ts
|
|
524
|
+
function isRefusal(cause) {
|
|
525
|
+
return isRelayError(cause) && cause.kind === "http" && !cause.uncertain && cause.status !== void 0 && cause.status >= 400 && cause.status < 500;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/session-items.ts
|
|
529
|
+
function readSessionItem(key) {
|
|
530
|
+
try {
|
|
531
|
+
return window.sessionStorage.getItem(key);
|
|
532
|
+
} catch {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function writeSessionItem(key, value) {
|
|
537
|
+
try {
|
|
538
|
+
if (value === null) {
|
|
539
|
+
window.sessionStorage.removeItem(key);
|
|
540
|
+
} else {
|
|
541
|
+
window.sessionStorage.setItem(key, value);
|
|
542
|
+
}
|
|
543
|
+
} catch {
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function readSessionJson(key, valid) {
|
|
547
|
+
try {
|
|
548
|
+
const value = JSON.parse(readSessionItem(key) ?? "null");
|
|
549
|
+
return valid(value) ? value : null;
|
|
550
|
+
} catch {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// src/station-check-in.ts
|
|
556
|
+
var PENDING = "domino:pending-station-check-in";
|
|
557
|
+
var passing = /* @__PURE__ */ (() => /* @__PURE__ */ new Set(["rate-limited", "attempt-pending"]))();
|
|
558
|
+
var stored = () => readSessionJson(
|
|
559
|
+
PENDING,
|
|
560
|
+
(value) => typeof value === "object" && value !== null && ["quest", "station", "code", "actionId"].every(
|
|
561
|
+
(key) => typeof value[key] === "string"
|
|
562
|
+
)
|
|
563
|
+
);
|
|
564
|
+
function captureStationCheckIn() {
|
|
565
|
+
if (typeof window === "undefined") {
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
const url = new URL(window.location.href);
|
|
569
|
+
const linked = parseStationCodeLink(url);
|
|
570
|
+
if (!linked) {
|
|
571
|
+
return stored();
|
|
572
|
+
}
|
|
573
|
+
const kept = stored();
|
|
574
|
+
const pending = kept && kept.quest === linked.quest && kept.station === linked.station && kept.code === linked.code ? kept : { ...linked, actionId: crypto.randomUUID() };
|
|
575
|
+
writeSessionItem(PENDING, JSON.stringify(pending));
|
|
576
|
+
url.searchParams.delete("code");
|
|
577
|
+
window.history.replaceState(window.history.state, "", url);
|
|
578
|
+
return pending;
|
|
579
|
+
}
|
|
580
|
+
function stationCheckInRetryable(state) {
|
|
581
|
+
return state.status === "failed" || state.status === "refused" && passing.has(state.code);
|
|
582
|
+
}
|
|
583
|
+
function forgetStationCheckIn(pending) {
|
|
584
|
+
if (stored()?.actionId === pending.actionId) {
|
|
585
|
+
writeSessionItem(PENDING, null);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function checkInStation(pending, options = {}) {
|
|
589
|
+
return {
|
|
590
|
+
key: pending.station,
|
|
591
|
+
label: options.stations?.find((station) => station.key === pending.station)?.label ?? pending.station
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
async function sendStationCheckIn(relay, pending, options = {}) {
|
|
595
|
+
const where = {
|
|
596
|
+
quest: pending.quest,
|
|
597
|
+
station: checkInStation(pending, options)
|
|
598
|
+
};
|
|
599
|
+
try {
|
|
600
|
+
const attempt = await relay.quests.checkIn(
|
|
601
|
+
pending.quest,
|
|
602
|
+
pending.station,
|
|
603
|
+
{ code: pending.code, actionId: pending.actionId },
|
|
604
|
+
options.session ? { session: options.session } : void 0
|
|
605
|
+
);
|
|
606
|
+
forgetStationCheckIn(pending);
|
|
607
|
+
return { status: "checked-in", ...where, attempt };
|
|
608
|
+
} catch (caught) {
|
|
609
|
+
const error = asRelayError(caught, "The check-in couldn't be sent.");
|
|
610
|
+
if (error.status === 401 || error.code === "stale-session") {
|
|
611
|
+
return { status: "sign-in-required", ...where };
|
|
612
|
+
}
|
|
613
|
+
if (!isRefusal(caught)) {
|
|
614
|
+
return { status: "failed", ...where, error };
|
|
615
|
+
}
|
|
616
|
+
const code = error.code ?? (error.status === 429 ? "rate-limited" : "");
|
|
617
|
+
if (!passing.has(code)) {
|
|
618
|
+
forgetStationCheckIn(pending);
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
status: "refused",
|
|
622
|
+
...where,
|
|
623
|
+
code,
|
|
624
|
+
error,
|
|
625
|
+
...error.retryAfter === void 0 ? {} : { retryAfter: error.retryAfter }
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
async function checkInAtStation(relay, options = {}) {
|
|
630
|
+
const pending = captureStationCheckIn();
|
|
631
|
+
if (!pending) {
|
|
632
|
+
return { status: "none" };
|
|
633
|
+
}
|
|
634
|
+
let session;
|
|
635
|
+
try {
|
|
636
|
+
session = await relay.auth.session();
|
|
637
|
+
} catch (caught) {
|
|
638
|
+
return {
|
|
639
|
+
status: "failed",
|
|
640
|
+
quest: pending.quest,
|
|
641
|
+
station: checkInStation(pending, options),
|
|
642
|
+
error: asRelayError(caught, "Couldn't read who is signed in.")
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
if (!sessionMember(session)) {
|
|
646
|
+
return {
|
|
647
|
+
status: "sign-in-required",
|
|
648
|
+
quest: pending.quest,
|
|
649
|
+
station: checkInStation(pending, options)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
return sendStationCheckIn(relay, pending, {
|
|
653
|
+
...options,
|
|
654
|
+
session: session.id
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
518
658
|
// src/browser.ts
|
|
519
659
|
function createBrowserRelayClient(options) {
|
|
520
660
|
return createRelayClient({
|
|
@@ -694,6 +834,15 @@ export {
|
|
|
694
834
|
readSignInMethods,
|
|
695
835
|
signInOptions,
|
|
696
836
|
memberTime,
|
|
837
|
+
isRefusal,
|
|
838
|
+
readSessionItem,
|
|
839
|
+
writeSessionItem,
|
|
840
|
+
readSessionJson,
|
|
841
|
+
captureStationCheckIn,
|
|
842
|
+
stationCheckInRetryable,
|
|
843
|
+
checkInStation,
|
|
844
|
+
sendStationCheckIn,
|
|
845
|
+
checkInAtStation,
|
|
697
846
|
createBrowserRelayClient,
|
|
698
847
|
browserSubmissionStore
|
|
699
848
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
rewardBundleSchema,
|
|
10
10
|
settingsValuesSchema,
|
|
11
11
|
trackerTriggerContextSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-74SMLZZ5.js";
|
|
13
13
|
|
|
14
14
|
// src/server/attempt-captures.ts
|
|
15
15
|
import * as z from "zod";
|
|
@@ -65,6 +65,13 @@ var attemptCaptureSchema = /* @__PURE__ */ (() => z.object({
|
|
|
65
65
|
* @experimental A minor release can change quest actions.
|
|
66
66
|
*/
|
|
67
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(),
|
|
68
75
|
eligibleAt: timestamp,
|
|
69
76
|
calendar: z.object({
|
|
70
77
|
segments: z.array(
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
imageFieldsSchema,
|
|
5
5
|
imageInspectionSchema,
|
|
6
6
|
imageSightingsSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VFHLMNYV.js";
|
|
8
8
|
import {
|
|
9
9
|
photoResultSchema
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-74SMLZZ5.js";
|
|
11
11
|
|
|
12
12
|
// src/image-results.ts
|
|
13
13
|
import * as z from "zod";
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
createHttpExchange,
|
|
10
10
|
untilAborted,
|
|
11
11
|
withQuery
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EMKYDGZ3.js";
|
|
13
13
|
import {
|
|
14
14
|
PARTICIPANT_TIMEOUT,
|
|
15
15
|
lifetime,
|
|
16
16
|
retrying,
|
|
17
17
|
validTimeout
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KC4UB4ZX.js";
|
|
19
19
|
import {
|
|
20
20
|
authProvidersSchema,
|
|
21
21
|
collectionPassSchema,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
questOutcomeSchema,
|
|
35
35
|
rewardDeliveriesSchema,
|
|
36
36
|
rewardDeliveryQuerySchema
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-3KKRXN5E.js";
|
|
38
38
|
import {
|
|
39
39
|
exchangeResultSchema,
|
|
40
40
|
exchangeSchema,
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
participantSessionSchema,
|
|
45
45
|
questExperienceSchema,
|
|
46
46
|
sessionMember
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-TW4RABVS.js";
|
|
48
48
|
import {
|
|
49
49
|
engagementBoundaryPageSchema,
|
|
50
50
|
engagementPageQuerySchema,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
referralDefinitionSchema,
|
|
56
56
|
referralHistorySchema,
|
|
57
57
|
referralSummarySchema
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-FGZGL5PG.js";
|
|
59
59
|
import {
|
|
60
60
|
AVATAR_UPLOAD_LIMIT,
|
|
61
61
|
accountConnectionSchema,
|
|
@@ -99,6 +99,7 @@ import {
|
|
|
99
99
|
quizEvidenceSchema,
|
|
100
100
|
signInAccountSchema,
|
|
101
101
|
signInProviderInputSchema,
|
|
102
|
+
stationCheckInSchema,
|
|
102
103
|
submissionEvidenceSchema,
|
|
103
104
|
submitSchema,
|
|
104
105
|
telegramAccountConnectionSchema,
|
|
@@ -113,7 +114,7 @@ import {
|
|
|
113
114
|
walletTransactionChallengeSchema,
|
|
114
115
|
walletTransactionProofSchema,
|
|
115
116
|
walletUnlinkInputSchema
|
|
116
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-74SMLZZ5.js";
|
|
117
118
|
import {
|
|
118
119
|
RelayError,
|
|
119
120
|
RelayErrorCode,
|
|
@@ -1697,6 +1698,31 @@ function relayClient(options) {
|
|
|
1697
1698
|
operationId: body2.actionId
|
|
1698
1699
|
});
|
|
1699
1700
|
},
|
|
1701
|
+
/**
|
|
1702
|
+
* Checks the signed-in member in at a quest's code station with the code they were given,
|
|
1703
|
+
* and resolves with the queued attempt, which the quest decides with `{ kind:
|
|
1704
|
+
* "station-code", reference: station }` in `ctx.action`; a repeat with the same `actionId`
|
|
1705
|
+
* resolves with the first attempt. Refusals: 422 `station-unknown` when the quest has no
|
|
1706
|
+
* such station, 422 `station-proof-mismatch` when transactions prove it, 409
|
|
1707
|
+
* `station-code-not-set` while it has no code in this environment, 409 `station-revoked`,
|
|
1708
|
+
* 409 `station-closed` outside its window, 422 `station-code-invalid` for a wrong code, and
|
|
1709
|
+
* 429 `rate-limited` (with `Retry-After`) after 10 wrong codes from the member at the station
|
|
1710
|
+
* in an hour or 600 at the station in 10 minutes, right codes included until it ends.
|
|
1711
|
+
*
|
|
1712
|
+
* @experimental A minor release can change check-in stations.
|
|
1713
|
+
*/
|
|
1714
|
+
checkIn: async (quest, station, value, requestOptions) => {
|
|
1715
|
+
const body2 = parseInput(stationCheckInSchema, withActionId(value));
|
|
1716
|
+
return request(
|
|
1717
|
+
`/v1/me/quests/${parseInput(identifier, quest)}/stations/${parseInput(identifier, station)}/check-in`,
|
|
1718
|
+
attemptSchema,
|
|
1719
|
+
{
|
|
1720
|
+
json: body2,
|
|
1721
|
+
options: requestOptions,
|
|
1722
|
+
operationId: body2.actionId
|
|
1723
|
+
}
|
|
1724
|
+
);
|
|
1725
|
+
},
|
|
1700
1726
|
/**
|
|
1701
1727
|
* Why automatic quests did or did not run for the signed-in member's activity, newest first:
|
|
1702
1728
|
* each admission, and each skip with its stable code.
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
imageSightingsSchema,
|
|
7
7
|
imageUploadsSchema,
|
|
8
8
|
publishedImageSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VFHLMNYV.js";
|
|
10
10
|
import {
|
|
11
11
|
dashboardArtifactSchema,
|
|
12
12
|
dashboardIssue,
|
|
13
13
|
dashboardPreviewSchema,
|
|
14
14
|
normalizeDashboard
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CVJTIVAP.js";
|
|
16
16
|
import {
|
|
17
17
|
authProvidersSchema,
|
|
18
18
|
collectionPassSchema,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
questOutcomePageSchema,
|
|
24
24
|
questOutcomeSchema,
|
|
25
25
|
rewardDeliveriesSchema
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3KKRXN5E.js";
|
|
27
27
|
import {
|
|
28
28
|
catalogDeploymentSchema,
|
|
29
29
|
collectionViewSchema,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
questExperienceSchema,
|
|
38
38
|
questTypeVersionSchema,
|
|
39
39
|
questViewSchema
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-TW4RABVS.js";
|
|
41
41
|
import {
|
|
42
42
|
engagementArtifactSchema,
|
|
43
43
|
engagementBoundaryPageSchema,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
referralDefinitionSchema,
|
|
53
53
|
referralHistorySchema,
|
|
54
54
|
referralSummarySchema
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-FGZGL5PG.js";
|
|
56
56
|
import {
|
|
57
57
|
accountConnectionSchema,
|
|
58
58
|
attemptSchema,
|
|
@@ -120,7 +120,7 @@ import {
|
|
|
120
120
|
walletTransactionChallengeSchema,
|
|
121
121
|
walletTransactionsSchema,
|
|
122
122
|
whereSettings
|
|
123
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-74SMLZZ5.js";
|
|
124
124
|
|
|
125
125
|
// src/deployments.ts
|
|
126
126
|
import * as z from "zod";
|
|
@@ -77,11 +77,68 @@ function getHostEnvironment() {
|
|
|
77
77
|
return pending ??= readHostEnvironment();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// src/station-qr.ts
|
|
81
|
+
function stationPayLink(url, station) {
|
|
82
|
+
const target = new URL(url);
|
|
83
|
+
target.searchParams.set("station", station);
|
|
84
|
+
return `solana:${encodeURIComponent(target.href)}`;
|
|
85
|
+
}
|
|
86
|
+
function stationCodeLink(url, { quest, station, code }) {
|
|
87
|
+
const target = new URL(url);
|
|
88
|
+
target.searchParams.set("quest", quest);
|
|
89
|
+
target.searchParams.set("station", station);
|
|
90
|
+
target.searchParams.set("code", code);
|
|
91
|
+
return target.href;
|
|
92
|
+
}
|
|
93
|
+
function parseStationCodeLink(link) {
|
|
94
|
+
let params;
|
|
95
|
+
try {
|
|
96
|
+
params = new URL(link).searchParams;
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const quest = params.get("quest");
|
|
101
|
+
const station = params.get("station");
|
|
102
|
+
const code = params.get("code");
|
|
103
|
+
return quest && station && code ? { quest, station, code } : null;
|
|
104
|
+
}
|
|
105
|
+
var escapeXml = (text) => text.replace(
|
|
106
|
+
/[&<>"']/g,
|
|
107
|
+
(character) => ({
|
|
108
|
+
"&": "&",
|
|
109
|
+
"<": "<",
|
|
110
|
+
">": ">",
|
|
111
|
+
'"': """,
|
|
112
|
+
"'": "'"
|
|
113
|
+
})[character] ?? character
|
|
114
|
+
);
|
|
115
|
+
async function stationQrSvg(link, label) {
|
|
116
|
+
const { encodeQR } = await import("qr");
|
|
117
|
+
const modules = encodeQR(link, "raw", { ecc: "medium", border: 4 });
|
|
118
|
+
const size = modules.length;
|
|
119
|
+
const scale = 10;
|
|
120
|
+
const width = size * scale;
|
|
121
|
+
const labelHeight = 6 * scale;
|
|
122
|
+
const path = modules.flatMap(
|
|
123
|
+
(row, y) => row.flatMap((dark, x) => dark ? [`M${x} ${y}h1v1h-1z`] : [])
|
|
124
|
+
).join("");
|
|
125
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${width + labelHeight}" viewBox="0 0 ${width} ${width + labelHeight}">
|
|
126
|
+
<rect width="100%" height="100%" fill="#fff"/>
|
|
127
|
+
<path transform="scale(${scale})" fill="#000" shape-rendering="crispEdges" d="${path}"/>
|
|
128
|
+
<text x="${width / 2}" y="${width + labelHeight / 2}" font-family="sans-serif" font-size="${2.4 * scale}" text-anchor="middle" dominant-baseline="middle" fill="#000">${escapeXml(label)}</text>
|
|
129
|
+
</svg>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
|
|
80
133
|
export {
|
|
81
134
|
noAccount,
|
|
82
135
|
registeredWallets,
|
|
83
136
|
connectSolanaAccount,
|
|
84
137
|
hostEnvironmentPath,
|
|
85
138
|
hostEnvironmentSchema,
|
|
86
|
-
getHostEnvironment
|
|
139
|
+
getHostEnvironment,
|
|
140
|
+
stationPayLink,
|
|
141
|
+
stationCodeLink,
|
|
142
|
+
parseStationCodeLink,
|
|
143
|
+
stationQrSvg
|
|
87
144
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHttpExchange,
|
|
3
3
|
uncertainStatuses
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EMKYDGZ3.js";
|
|
5
5
|
import {
|
|
6
6
|
MANAGEMENT_TIMEOUT,
|
|
7
7
|
lifetime,
|
|
8
8
|
retrying,
|
|
9
9
|
validTimeout
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-KC4UB4ZX.js";
|
|
11
11
|
import {
|
|
12
12
|
base58Bytes,
|
|
13
13
|
evmAddressSchema,
|
|
14
14
|
knownResponse,
|
|
15
15
|
solanaDevnet,
|
|
16
16
|
solanaMainnet
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-74SMLZZ5.js";
|
|
18
18
|
import {
|
|
19
19
|
RequestError,
|
|
20
20
|
isRequestError
|
|
@@ -437,6 +437,13 @@ function containsReferralIntegrationReward(value) {
|
|
|
437
437
|
);
|
|
438
438
|
}
|
|
439
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
|
+
|
|
440
447
|
export {
|
|
441
448
|
questConfiguration,
|
|
442
449
|
hex,
|
|
@@ -455,5 +462,6 @@ export {
|
|
|
455
462
|
managementTransport,
|
|
456
463
|
sequenceCursorSchema,
|
|
457
464
|
REFERRAL_INTEGRATION_REWARD_ERROR,
|
|
458
|
-
containsReferralIntegrationReward
|
|
465
|
+
containsReferralIntegrationReward,
|
|
466
|
+
csvLines
|
|
459
467
|
};
|
|
@@ -32,6 +32,10 @@ var participantRoutes = [
|
|
|
32
32
|
{ method: "POST", path: `/v1/attempts/:attempt${id}/retry` },
|
|
33
33
|
{ method: "GET", path: `/v1/me/quests/:quest${id}/submission` },
|
|
34
34
|
{ method: "POST", path: `/v1/me/quests/:quest${id}/submission` },
|
|
35
|
+
{
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: `/v1/me/quests/:quest${id}/stations/:station${id}/check-in`
|
|
38
|
+
},
|
|
35
39
|
{ method: "GET", path: `/v1/me/submissions/:submission${id}` },
|
|
36
40
|
{ method: "POST", path: `/v1/me/submissions/:submission${id}` },
|
|
37
41
|
{ method: "POST", path: `/v1/me/submissions/:submission${id}/submit` },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
imageAssetArtifactSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFHLMNYV.js";
|
|
4
4
|
import {
|
|
5
5
|
authScopeSchema,
|
|
6
6
|
exchangeResultSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TW4RABVS.js";
|
|
8
8
|
import {
|
|
9
9
|
appIdentityKindSchema,
|
|
10
10
|
cosmosAddressSchema,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
openIdentityKindSchema,
|
|
18
18
|
pageCursorSchema,
|
|
19
19
|
solanaAddressSchema
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-74SMLZZ5.js";
|
|
21
21
|
|
|
22
22
|
// src/credential-secrets.ts
|
|
23
23
|
import * as z from "zod";
|
|
@@ -623,6 +623,7 @@ ${body}`)
|
|
|
623
623
|
return null;
|
|
624
624
|
}
|
|
625
625
|
const parsed = scheduledInvocationSchema.safeParse(
|
|
626
|
+
// A signed body that isn't JSON fails the schema and is refused.
|
|
626
627
|
await new Response(body).json().catch(() => null)
|
|
627
628
|
);
|
|
628
629
|
if (!parsed.success || Math.abs(Date.now() - parsed.data.startedAt) > 6e4) {
|
|
@@ -2,13 +2,22 @@ import {
|
|
|
2
2
|
discordMessageDataSchema,
|
|
3
3
|
discordMessageTextDataSchema,
|
|
4
4
|
discordReactionDataSchema,
|
|
5
|
+
galleryKinds,
|
|
5
6
|
isKnownTrackerSource,
|
|
6
7
|
takesSolanaTransaction,
|
|
7
8
|
trackerDataSchema,
|
|
8
9
|
xAccountRoles
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-74SMLZZ5.js";
|
|
10
11
|
|
|
11
12
|
// src/quest-shape.ts
|
|
13
|
+
var QuestShapeError = class extends Error {
|
|
14
|
+
constructor(message, code) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.name = "QuestShapeError";
|
|
18
|
+
}
|
|
19
|
+
code;
|
|
20
|
+
};
|
|
12
21
|
function validateQuestShape(description, options = {}) {
|
|
13
22
|
const {
|
|
14
23
|
trigger,
|
|
@@ -18,7 +27,8 @@ function validateQuestShape(description, options = {}) {
|
|
|
18
27
|
retryCooldownMs,
|
|
19
28
|
completionCooldownMs,
|
|
20
29
|
authorBudgets = [],
|
|
21
|
-
stations
|
|
30
|
+
stations,
|
|
31
|
+
gallery
|
|
22
32
|
} = description;
|
|
23
33
|
const tracker = trigger.kind === "automatic" ? trigger.tracker : void 0;
|
|
24
34
|
const content = tracker?.content === true;
|
|
@@ -67,6 +77,22 @@ function validateQuestShape(description, options = {}) {
|
|
|
67
77
|
"Stations are for quests a signed Solana transaction completes: a member-submitted manual() quest without input"
|
|
68
78
|
);
|
|
69
79
|
}
|
|
80
|
+
if (gallery && options.template) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
"Reusable quest types cannot declare a photo gallery: declare it on a quest written in code"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (gallery && !options.authoring && !(trigger.kind === "manual" && trigger.input === "photo")) {
|
|
86
|
+
throw new QuestShapeError(
|
|
87
|
+
"A photo gallery is for a quest whose input is a photo: manual({ input: evidence.photo() })",
|
|
88
|
+
"gallery-requires-photo"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (gallery && !galleryKinds.some((kind) => kind === gallery.kind)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Unknown gallery kind "${gallery.kind}": use ${galleryKinds.map((kind) => `"${kind}"`).join(" or ")}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
70
96
|
if (trigger.kind === "automatic" && !tracker) {
|
|
71
97
|
if (!options.template && requires.length === 0) {
|
|
72
98
|
throw new Error("Automatic quests need at least one prerequisite");
|
|
@@ -120,6 +146,7 @@ function sourceDataSchema(source) {
|
|
|
120
146
|
}
|
|
121
147
|
|
|
122
148
|
export {
|
|
149
|
+
QuestShapeError,
|
|
123
150
|
validateQuestShape,
|
|
124
151
|
sourceRoles,
|
|
125
152
|
sourceDataSchema
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
activityTypeSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KIRXE37T.js";
|
|
4
4
|
import {
|
|
5
5
|
completionRecordSchema,
|
|
6
6
|
completionSourceSchema,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
pageLimit,
|
|
11
11
|
solanaAddressSchema,
|
|
12
12
|
solanaSignatureSchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-74SMLZZ5.js";
|
|
14
14
|
|
|
15
15
|
// src/server/webhooks.ts
|
|
16
16
|
import * as z from "zod";
|