@domino-sdk/relay 1.61.0 → 1.63.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 +276 -8
- package/README.md +3 -2
- package/dist/{schema-CZ6Rj0ZF.d.ts → accounts-nz3mzfRQ.d.ts} +3146 -1765
- package/dist/action-9Xl0StBg.d.ts +33 -0
- package/dist/{attempt-captures-DYnJVkfg.d.ts → attempt-captures-DMi8oR9T.d.ts} +1 -1
- package/dist/authoring.d.ts +171 -49
- package/dist/authoring.js +158 -49
- package/dist/{automatic-outcomes-If88LR9f.d.ts → automatic-outcomes-C_LLQU1p.d.ts} +15 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +15 -11
- package/dist/browser.js +18 -12
- package/dist/capability-error-CuI_F7yM.d.ts +296 -0
- package/dist/{pages-K7-KjSXw.d.ts → catalog-BaTOKpNw.d.ts} +56 -567
- package/dist/{chunk-XBV2CK2H.js → chunk-3RFP6GT5.js} +15 -3
- package/dist/{chunk-VURRFVNP.js → chunk-4GQW43UU.js} +239 -361
- package/dist/chunk-4NOFSGAL.js +320 -0
- package/dist/{chunk-24I4R732.js → chunk-5XLZ34PV.js} +34 -19
- package/dist/{chunk-L77O64I4.js → chunk-7X67QLPB.js} +43 -43
- package/dist/{chunk-RHBS5FJL.js → chunk-7Z4SZ6YM.js} +3 -3
- package/dist/{chunk-QEAS4ZGS.js → chunk-AQOL3SK5.js} +1 -1
- package/dist/chunk-EHUSD3O2.js +377 -0
- package/dist/chunk-FO2LCZTL.js +19 -0
- package/dist/{chunk-DYXDZFKA.js → chunk-FU5CGNTR.js} +166 -178
- package/dist/chunk-FWLQ5XCS.js +21 -0
- package/dist/chunk-GLH6MEI2.js +193 -0
- package/dist/chunk-ICXZZNPS.js +199 -0
- package/dist/{chunk-ZDJLPN4L.js → chunk-ID3BZXFZ.js} +2696 -2693
- package/dist/chunk-KP2MCX3R.js +587 -0
- package/dist/{chunk-SKGTNTLF.js → chunk-LZWXCBUB.js} +213 -297
- package/dist/chunk-MTKRIQEU.js +31 -0
- package/dist/{chunk-4OC7REYX.js → chunk-MWMCQLCG.js} +3 -3
- package/dist/{chunk-PPB7HALD.js → chunk-N4BDKS6Y.js} +27 -26
- package/dist/{chunk-5I54XBK2.js → chunk-N4LNEGQX.js} +2 -2
- package/dist/chunk-NQDEWJWE.js +554 -0
- package/dist/chunk-QR6HH4DI.js +508 -0
- package/dist/chunk-TLSQETTY.js +41 -0
- package/dist/{chunk-MHPKEVEW.js → chunk-U66GUVSG.js} +7 -2
- package/dist/{chunk-KDR2VAJP.js → chunk-UYVJZR33.js} +2 -2
- package/dist/chunk-UZ765UGH.js +18 -0
- package/dist/{chunk-7A4J67ZL.js → chunk-VWQGWGCH.js} +7 -7
- package/dist/chunk-W7YSMSGC.js +725 -0
- package/dist/{client-C51w7fMb.d.ts → client-DHmG7rn6.d.ts} +126 -93
- package/dist/{announcements-CHx3-HBw.d.ts → dashboards-CLemT6kj.d.ts} +14 -137
- package/dist/{deployments-kWoHFaqj.d.ts → deployments-DTULi7dF.d.ts} +450 -18
- package/dist/identity-integration-DOeNZaxF.d.ts +1271 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +16 -11
- package/dist/internal.d.ts +29 -13
- package/dist/internal.js +57 -17
- package/dist/{integrations-B3y36OaB.d.ts → limits-kNzYdZ00.d.ts} +464 -53
- package/dist/{offers-BoV4ryUc.d.ts → offers-CYeN_I0Y.d.ts} +22 -4
- package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
- package/dist/portal-proxy.d.ts +75 -2
- package/dist/portal-proxy.js +153 -25
- package/dist/react/index.d.ts +214 -27
- package/dist/react/index.js +196 -42
- package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
- package/dist/reward-deliveries-drp-x1G-.d.ts +782 -0
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/UGDV5W4N.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +330 -31
- package/dist/schema.js +147 -91
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +6425 -6260
- package/dist/sign-in-providers-B1Q9eDRm.d.ts +44 -0
- package/dist/submission-input-DZCbjQUH.d.ts +343 -0
- package/dist/{telegram-browser-BUceZIGZ.d.ts → telegram-browser-NL0Asmsi.d.ts} +46 -6
- package/dist/telegram.d.ts +64 -0
- package/dist/telegram.js +23 -0
- package/dist/testing.d.ts +326 -27
- package/dist/testing.js +440 -90
- package/dist/tracker-data-esm3WG8R.d.ts +1881 -0
- package/dist/{transport-BrX9pIGN.d.ts → transport-Czht_irp.d.ts} +43483 -38512
- package/dist/{wallet-CIqFoxdm.d.ts → wallet-B7e06v4m.d.ts} +32 -9
- package/package.json +5 -1
- package/dist/accounts-DoabriBX.d.ts +0 -306
- package/dist/capability-error-DufwG3G0.d.ts +0 -159
- package/dist/chunk-3Y3L2F54.js +0 -982
- package/dist/chunk-DHXDBAJF.js +0 -544
- package/dist/chunk-EN3M5Z4J.js +0 -13
- package/dist/chunk-QNUHWK7R.js +0 -602
- package/dist/chunk-SE4PFJPT.js +0 -247
- package/dist/groups-CqcA2Ycs.d.ts +0 -2827
- package/dist/runtime/chunks/5QVFB4TU.js +0 -1
- package/dist/submission-input-C54Q8yAD.d.ts +0 -146
- package/dist/x-D1PGi8Sq.d.ts +0 -331
package/dist/react/index.js
CHANGED
|
@@ -7,22 +7,28 @@ import {
|
|
|
7
7
|
discoverSignInWallets,
|
|
8
8
|
discoverSolanaWallets,
|
|
9
9
|
readSignInMethods,
|
|
10
|
-
signInOptionsFrom
|
|
10
|
+
signInOptionsFrom
|
|
11
|
+
} from "../chunk-5XLZ34PV.js";
|
|
12
|
+
import {
|
|
11
13
|
telegramMiniAppInitData
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
+
} from "../chunk-FWLQ5XCS.js";
|
|
15
|
+
import "../chunk-LZWXCBUB.js";
|
|
14
16
|
import {
|
|
15
17
|
createRelayAction
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-AQOL3SK5.js";
|
|
19
|
+
import "../chunk-MTKRIQEU.js";
|
|
20
|
+
import "../chunk-EHUSD3O2.js";
|
|
21
|
+
import "../chunk-4NOFSGAL.js";
|
|
22
|
+
import "../chunk-QR6HH4DI.js";
|
|
23
|
+
import "../chunk-W7YSMSGC.js";
|
|
24
|
+
import "../chunk-UYVJZR33.js";
|
|
25
|
+
import "../chunk-ICXZZNPS.js";
|
|
26
|
+
import "../chunk-FO2LCZTL.js";
|
|
27
|
+
import "../chunk-3RFP6GT5.js";
|
|
23
28
|
import {
|
|
24
29
|
sessionMember
|
|
25
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-N4BDKS6Y.js";
|
|
31
|
+
import "../chunk-ID3BZXFZ.js";
|
|
26
32
|
import {
|
|
27
33
|
RelayError,
|
|
28
34
|
RelayErrorCode,
|
|
@@ -30,11 +36,11 @@ import {
|
|
|
30
36
|
clientError,
|
|
31
37
|
isRelayError,
|
|
32
38
|
isRequestError
|
|
33
|
-
} from "../chunk-
|
|
39
|
+
} from "../chunk-GLH6MEI2.js";
|
|
34
40
|
|
|
35
41
|
// src/react/context.ts
|
|
36
42
|
import { createContext, useContext } from "react";
|
|
37
|
-
var StoreContext = createContext(null);
|
|
43
|
+
var StoreContext = /* @__PURE__ */ (() => createContext(null))();
|
|
38
44
|
function useStore() {
|
|
39
45
|
const store = useContext(StoreContext);
|
|
40
46
|
if (!store) {
|
|
@@ -52,12 +58,14 @@ var relayKeys = {
|
|
|
52
58
|
experience: ["experience"],
|
|
53
59
|
/** `useMe`. */
|
|
54
60
|
me: ["me"],
|
|
55
|
-
/** `useAccounts`. */
|
|
61
|
+
/** `useAccounts`, `useAccount`, `useTelegramAccount`, `useCreatorAccounts`. */
|
|
56
62
|
accounts: ["accounts"],
|
|
57
63
|
/** `useWallets`. */
|
|
58
64
|
wallets: ["wallets"],
|
|
59
65
|
/** `useMyProfile`, `useProfile`, `useProfileCompletions`, `useProfileReferral`. */
|
|
60
66
|
profiles: ["profiles"],
|
|
67
|
+
/** `useConsent`. */
|
|
68
|
+
consent: ["consent"],
|
|
61
69
|
/** `useLeaderboard`, `useLeaderboardPlacement`, `useLeaderboardHistory`. */
|
|
62
70
|
leaderboards: ["leaderboards"],
|
|
63
71
|
/** `useReferralSummary`. */
|
|
@@ -114,11 +122,11 @@ var activityChanges = {
|
|
|
114
122
|
|
|
115
123
|
// src/react/action.ts
|
|
116
124
|
import { useCallback, useRef, useState } from "react";
|
|
117
|
-
var IDLE = Object.freeze({
|
|
125
|
+
var IDLE = /* @__PURE__ */ (() => Object.freeze({
|
|
118
126
|
status: "idle",
|
|
119
127
|
data: void 0,
|
|
120
128
|
error: null
|
|
121
|
-
});
|
|
129
|
+
}))();
|
|
122
130
|
function actionError(cause) {
|
|
123
131
|
return isRequestError(cause) && !isRelayError(cause) ? new RelayError(cause.message, {
|
|
124
132
|
kind: cause.kind,
|
|
@@ -214,11 +222,11 @@ import {
|
|
|
214
222
|
} from "react";
|
|
215
223
|
|
|
216
224
|
// src/react/cache.ts
|
|
217
|
-
var LOADING = Object.freeze({
|
|
225
|
+
var LOADING = /* @__PURE__ */ (() => Object.freeze({
|
|
218
226
|
status: "loading",
|
|
219
227
|
data: void 0,
|
|
220
228
|
error: null
|
|
221
|
-
});
|
|
229
|
+
}))();
|
|
222
230
|
var UNUSED_MS = 5 * 6e4;
|
|
223
231
|
var STALE_MS = 3e4;
|
|
224
232
|
var relayError = (cause, fallback) => asRelayError(cause, fallback);
|
|
@@ -624,8 +632,11 @@ var ActivityFeed = class {
|
|
|
624
632
|
};
|
|
625
633
|
|
|
626
634
|
// src/react/role-delivery.ts
|
|
635
|
+
function grantsRole({ action }) {
|
|
636
|
+
return typeof action !== "string" || action === "grant-role";
|
|
637
|
+
}
|
|
627
638
|
function sanitizeDeliveries(deliveries) {
|
|
628
|
-
return deliveries.map(({ quest, status, revokedAt, reconciliation }) => ({
|
|
639
|
+
return deliveries.filter(grantsRole).map(({ quest, status, revokedAt, reconciliation }) => ({
|
|
629
640
|
quest,
|
|
630
641
|
status: reconciliation ? reconciliation.status === "granted" ? "delivered" : reconciliation.status : revokedAt ? "revoked" : status
|
|
631
642
|
}));
|
|
@@ -1032,11 +1043,11 @@ function quote(value) {
|
|
|
1032
1043
|
}
|
|
1033
1044
|
|
|
1034
1045
|
// src/react/store.ts
|
|
1035
|
-
var SIGNED_OUT = Object.freeze({
|
|
1046
|
+
var SIGNED_OUT = /* @__PURE__ */ (() => Object.freeze({
|
|
1036
1047
|
status: "signed-out",
|
|
1037
1048
|
data: void 0,
|
|
1038
1049
|
error: null
|
|
1039
|
-
});
|
|
1050
|
+
}))();
|
|
1040
1051
|
function scopeKey(session) {
|
|
1041
1052
|
if (!session) {
|
|
1042
1053
|
return "visitor";
|
|
@@ -1126,12 +1137,17 @@ var RelayStore = class {
|
|
|
1126
1137
|
/** The wallet the current session signed in with, while the store follows its accounts. */
|
|
1127
1138
|
#wallet = null;
|
|
1128
1139
|
#walletSigningOut = false;
|
|
1129
|
-
|
|
1140
|
+
/** Bumped by each `delivery.updated` the feed brings, so the role deliveries are read again. */
|
|
1141
|
+
#deliveryChanges = 0;
|
|
1142
|
+
/** Whether a wallet sign-in's session ends when the wallet switches account or locks. */
|
|
1143
|
+
#followWallet;
|
|
1144
|
+
constructor(client, polling = {}, { followWallet = true } = {}) {
|
|
1130
1145
|
this.client = client;
|
|
1131
1146
|
this.#polling = {
|
|
1132
1147
|
activityMs: polling.activityMs ?? ACTIVITY_MS,
|
|
1133
1148
|
snapshotMs: polling.snapshotMs ?? SNAPSHOT_MS
|
|
1134
1149
|
};
|
|
1150
|
+
this.#followWallet = followWallet;
|
|
1135
1151
|
}
|
|
1136
1152
|
/** `refreshSession` with one identity per store, for hooks to hand out as `refresh`. */
|
|
1137
1153
|
rereadSession = () => this.refreshSession();
|
|
@@ -1150,6 +1166,10 @@ var RelayStore = class {
|
|
|
1150
1166
|
get experience() {
|
|
1151
1167
|
return this.#experienceView;
|
|
1152
1168
|
}
|
|
1169
|
+
/** How many `delivery.updated` events the feed brought; changes when a delivery did. */
|
|
1170
|
+
get deliveryChanges() {
|
|
1171
|
+
return this.#deliveryChanges;
|
|
1172
|
+
}
|
|
1153
1173
|
/** The first query cache of this mount, the only one a public read's `initialData` seeds. */
|
|
1154
1174
|
get firstCache() {
|
|
1155
1175
|
return this.#firstCache;
|
|
@@ -1386,6 +1406,9 @@ var RelayStore = class {
|
|
|
1386
1406
|
/** Signs out when the wallet `session` signed in with reports another account, or none. */
|
|
1387
1407
|
#watchWallet(signer, address, session) {
|
|
1388
1408
|
this.#stopWallet(false);
|
|
1409
|
+
if (!this.#followWallet) {
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1389
1412
|
const signedIn = address.toLowerCase();
|
|
1390
1413
|
const watch = { session, stop: () => {
|
|
1391
1414
|
} };
|
|
@@ -1456,6 +1479,10 @@ var RelayStore = class {
|
|
|
1456
1479
|
if (keys.size > 0) {
|
|
1457
1480
|
void this.#scope?.cache.invalidate([...keys.values()]);
|
|
1458
1481
|
}
|
|
1482
|
+
if (events.some((event) => event.kind === "delivery.updated")) {
|
|
1483
|
+
this.#deliveryChanges += 1;
|
|
1484
|
+
this.#emit();
|
|
1485
|
+
}
|
|
1459
1486
|
}
|
|
1460
1487
|
#startObserver() {
|
|
1461
1488
|
if (this.#observer || !this.#mounted) {
|
|
@@ -1912,7 +1939,7 @@ function useBadgeCatalog() {
|
|
|
1912
1939
|
const relay = useRelay();
|
|
1913
1940
|
return useRelayQuery(
|
|
1914
1941
|
[...relayKeys.badges, "catalog"],
|
|
1915
|
-
(options) => relay.badges.
|
|
1942
|
+
async (options) => (await relay.badges.catalog(options)).items
|
|
1916
1943
|
);
|
|
1917
1944
|
}
|
|
1918
1945
|
function useBadges() {
|
|
@@ -2123,15 +2150,15 @@ import {
|
|
|
2123
2150
|
|
|
2124
2151
|
// src/react/use-role-deliveries.ts
|
|
2125
2152
|
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
2126
|
-
var NONE = Object.freeze([]);
|
|
2127
|
-
function useRoleDeliveries(relay, member, completions) {
|
|
2153
|
+
var NONE = /* @__PURE__ */ (() => Object.freeze([]))();
|
|
2154
|
+
function useRoleDeliveries(relay, member, completions, changes = 0) {
|
|
2128
2155
|
const [state, setState] = useState4(null);
|
|
2129
2156
|
useEffect3(() => {
|
|
2130
2157
|
if (!member || !completions) {
|
|
2131
2158
|
return;
|
|
2132
2159
|
}
|
|
2133
2160
|
const watch = watchRoleDeliveries({
|
|
2134
|
-
read: async () => (await relay.me.rewardDeliveries()).
|
|
2161
|
+
read: async () => (await relay.me.rewardDeliveries()).items,
|
|
2135
2162
|
onChange: (deliveries) => setState({ member, deliveries })
|
|
2136
2163
|
});
|
|
2137
2164
|
const wake = () => {
|
|
@@ -2146,13 +2173,13 @@ function useRoleDeliveries(relay, member, completions) {
|
|
|
2146
2173
|
window.removeEventListener("focus", wake);
|
|
2147
2174
|
document.removeEventListener("visibilitychange", wake);
|
|
2148
2175
|
};
|
|
2149
|
-
}, [relay, member, completions]);
|
|
2176
|
+
}, [relay, member, completions, changes]);
|
|
2150
2177
|
return member && completions && state?.member === member ? state.deliveries : NONE;
|
|
2151
2178
|
}
|
|
2152
2179
|
|
|
2153
2180
|
// src/react/experience.tsx
|
|
2154
2181
|
import { jsx } from "react/jsx-runtime";
|
|
2155
|
-
var Deliveries = createContext2(Object.freeze([]));
|
|
2182
|
+
var Deliveries = /* @__PURE__ */ (() => createContext2(Object.freeze([])))();
|
|
2156
2183
|
function useExperienceSnapshot() {
|
|
2157
2184
|
const store = useStore();
|
|
2158
2185
|
const get = () => store.experience;
|
|
@@ -2166,6 +2193,11 @@ function DeliveriesProvider({ children }) {
|
|
|
2166
2193
|
() => store.scope?.member ?? null,
|
|
2167
2194
|
() => null
|
|
2168
2195
|
);
|
|
2196
|
+
const changes = useSyncExternalStore3(
|
|
2197
|
+
store.subscribe,
|
|
2198
|
+
() => store.deliveryChanges,
|
|
2199
|
+
() => 0
|
|
2200
|
+
);
|
|
2169
2201
|
const ready = experience.status === "ready";
|
|
2170
2202
|
const deliveries = useRoleDeliveries(
|
|
2171
2203
|
store.client,
|
|
@@ -2173,7 +2205,8 @@ function DeliveriesProvider({ children }) {
|
|
|
2173
2205
|
ready ? completionMark([
|
|
2174
2206
|
...experience.data.quests,
|
|
2175
2207
|
...experience.data.collections.flatMap((c) => c.quests)
|
|
2176
|
-
]) : ""
|
|
2208
|
+
]) : "",
|
|
2209
|
+
changes
|
|
2177
2210
|
);
|
|
2178
2211
|
return /* @__PURE__ */ jsx(Deliveries, { value: deliveries, children });
|
|
2179
2212
|
}
|
|
@@ -2194,6 +2227,7 @@ function RelayProvider({
|
|
|
2194
2227
|
client,
|
|
2195
2228
|
baseUrl = "/relay",
|
|
2196
2229
|
polling,
|
|
2230
|
+
followWallet = true,
|
|
2197
2231
|
children
|
|
2198
2232
|
}) {
|
|
2199
2233
|
const origin = client ? null : baseUrl;
|
|
@@ -2202,10 +2236,11 @@ function RelayProvider({
|
|
|
2202
2236
|
const store = useMemo4(
|
|
2203
2237
|
() => new RelayStore(
|
|
2204
2238
|
client ?? createBrowserRelayClient({ baseUrl: origin ?? baseUrl }),
|
|
2205
|
-
{ activityMs, snapshotMs }
|
|
2239
|
+
{ activityMs, snapshotMs },
|
|
2240
|
+
{ followWallet }
|
|
2206
2241
|
),
|
|
2207
2242
|
// A given client ignores `baseUrl`; `polling` is compared by value.
|
|
2208
|
-
[client, origin, activityMs, snapshotMs]
|
|
2243
|
+
[client, origin, activityMs, snapshotMs, followWallet]
|
|
2209
2244
|
);
|
|
2210
2245
|
useEffect4(() => store.mount(), [store]);
|
|
2211
2246
|
return /* @__PURE__ */ jsx2(StoreContext, { value: store, children: /* @__PURE__ */ jsx2(DeliveriesProvider, { children }) });
|
|
@@ -2664,6 +2699,10 @@ function useSignIn() {
|
|
|
2664
2699
|
sendCode,
|
|
2665
2700
|
verifyCode,
|
|
2666
2701
|
startOver,
|
|
2702
|
+
/**
|
|
2703
|
+
* Leaves for the provider's consent screen: any of `providers().signInProviders`, Telegram
|
|
2704
|
+
* included.
|
|
2705
|
+
*/
|
|
2667
2706
|
withProvider,
|
|
2668
2707
|
/**
|
|
2669
2708
|
* Signs in, or signs up, with a wallet; the wallet asks the participant to sign a message. A
|
|
@@ -2671,11 +2710,15 @@ function useSignIn() {
|
|
|
2671
2710
|
* to another account in it, or locking it, signs out.
|
|
2672
2711
|
*/
|
|
2673
2712
|
withWallet,
|
|
2674
|
-
/**
|
|
2713
|
+
/**
|
|
2714
|
+
* Leaves for Telegram Login, where the platform configured it.
|
|
2715
|
+
*
|
|
2716
|
+
* @deprecated Use `withProvider("telegram")`. Removed in 2.0.0.
|
|
2717
|
+
*/
|
|
2675
2718
|
withTelegram,
|
|
2676
2719
|
/**
|
|
2677
2720
|
* Signs in, or signs up, inside a Telegram Mini App the project enabled, with its launch data
|
|
2678
|
-
* (`telegramMiniAppInitData()`).
|
|
2721
|
+
* (`telegramMiniAppInitData()` from `@domino-sdk/relay/telegram`).
|
|
2679
2722
|
*/
|
|
2680
2723
|
withTelegramMiniApp
|
|
2681
2724
|
}),
|
|
@@ -2739,7 +2782,7 @@ function useSignInOptions(input = {}) {
|
|
|
2739
2782
|
if (!methods) {
|
|
2740
2783
|
return null;
|
|
2741
2784
|
}
|
|
2742
|
-
if (!wallets && methods.providers.length === 0 && !methods.email && !methods.telegram?.login) {
|
|
2785
|
+
if (!wallets && methods.providers.length === 0 && !methods.signInProviders?.length && !methods.email && !methods.telegram?.login) {
|
|
2743
2786
|
return null;
|
|
2744
2787
|
}
|
|
2745
2788
|
return signInOptionsFrom(methods, wallets ?? [], {
|
|
@@ -2747,6 +2790,7 @@ function useSignInOptions(input = {}) {
|
|
|
2747
2790
|
walletsPending: !wallets,
|
|
2748
2791
|
actions: {
|
|
2749
2792
|
oauth: withProvider,
|
|
2793
|
+
provider: withProvider,
|
|
2750
2794
|
sendCode,
|
|
2751
2795
|
verifyCode,
|
|
2752
2796
|
wallet: withWallet,
|
|
@@ -2767,6 +2811,7 @@ function useSignInOptions(input = {}) {
|
|
|
2767
2811
|
return useMemo7(
|
|
2768
2812
|
() => ({
|
|
2769
2813
|
options: built?.options ?? null,
|
|
2814
|
+
signInProviders: built?.signInProviders ?? null,
|
|
2770
2815
|
unavailable: built?.unavailable ?? NONE_UNAVAILABLE,
|
|
2771
2816
|
telegram: built?.telegram ?? null,
|
|
2772
2817
|
methodsError,
|
|
@@ -2782,7 +2827,7 @@ function useSignInOptions(input = {}) {
|
|
|
2782
2827
|
}
|
|
2783
2828
|
|
|
2784
2829
|
// src/react/accounts.ts
|
|
2785
|
-
import { useMemo as useMemo8 } from "react";
|
|
2830
|
+
import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
|
|
2786
2831
|
function isConnected(accounts, provider) {
|
|
2787
2832
|
return Boolean(
|
|
2788
2833
|
accounts?.some(
|
|
@@ -2846,6 +2891,67 @@ function useAccounts() {
|
|
|
2846
2891
|
]
|
|
2847
2892
|
);
|
|
2848
2893
|
}
|
|
2894
|
+
function useAccount(provider) {
|
|
2895
|
+
const relay = useRelay();
|
|
2896
|
+
const invalidate = useInvalidate();
|
|
2897
|
+
const session = useScopeSession();
|
|
2898
|
+
const select = useCallback8(
|
|
2899
|
+
(accounts) => accounts.find((account2) => account2.provider === provider) ?? null,
|
|
2900
|
+
[provider]
|
|
2901
|
+
);
|
|
2902
|
+
const query = useMemberQuery(
|
|
2903
|
+
[...relayKeys.accounts, "sign-in"],
|
|
2904
|
+
(options) => relay.auth.signInAccounts(options),
|
|
2905
|
+
{ refetchOnFocus: true, select }
|
|
2906
|
+
);
|
|
2907
|
+
const { isPending, actionError: actionError2, resetAction, run, retry, settle } = useAction();
|
|
2908
|
+
const actions = useMemo8(
|
|
2909
|
+
() => ({
|
|
2910
|
+
connect: () => run(async () => {
|
|
2911
|
+
const { url } = await relay.auth.start(
|
|
2912
|
+
{ provider, mode: "connect" },
|
|
2913
|
+
{ session }
|
|
2914
|
+
);
|
|
2915
|
+
window.location.assign(url);
|
|
2916
|
+
}),
|
|
2917
|
+
disconnect: () => run(async () => {
|
|
2918
|
+
await relay.auth.disconnect(provider, { session });
|
|
2919
|
+
void invalidate([
|
|
2920
|
+
relayKeys.accounts,
|
|
2921
|
+
relayKeys.experience,
|
|
2922
|
+
relayKeys.profiles
|
|
2923
|
+
]);
|
|
2924
|
+
})
|
|
2925
|
+
}),
|
|
2926
|
+
[relay, invalidate, session, run, provider]
|
|
2927
|
+
);
|
|
2928
|
+
const account = query.data;
|
|
2929
|
+
return useMemo8(
|
|
2930
|
+
() => ({
|
|
2931
|
+
...query,
|
|
2932
|
+
isPending,
|
|
2933
|
+
actionError: actionError2,
|
|
2934
|
+
resetAction,
|
|
2935
|
+
retry,
|
|
2936
|
+
settle,
|
|
2937
|
+
/** True when the account can be used to verify quests right now. */
|
|
2938
|
+
isConnected: Boolean(
|
|
2939
|
+
account?.configured && account.status === "connected"
|
|
2940
|
+
),
|
|
2941
|
+
...actions
|
|
2942
|
+
}),
|
|
2943
|
+
[
|
|
2944
|
+
query,
|
|
2945
|
+
isPending,
|
|
2946
|
+
actionError2,
|
|
2947
|
+
resetAction,
|
|
2948
|
+
retry,
|
|
2949
|
+
settle,
|
|
2950
|
+
account,
|
|
2951
|
+
actions
|
|
2952
|
+
]
|
|
2953
|
+
);
|
|
2954
|
+
}
|
|
2849
2955
|
function useTelegramAccount() {
|
|
2850
2956
|
const relay = useRelay();
|
|
2851
2957
|
const invalidate = useInvalidate();
|
|
@@ -3049,8 +3155,54 @@ function useProfileCompletions(profile, options = {}) {
|
|
|
3049
3155
|
);
|
|
3050
3156
|
}
|
|
3051
3157
|
|
|
3158
|
+
// src/react/consent.ts
|
|
3159
|
+
import { useMemo as useMemo10 } from "react";
|
|
3160
|
+
function useConsent() {
|
|
3161
|
+
const relay = useRelay();
|
|
3162
|
+
const store = useStore();
|
|
3163
|
+
const session = useScopeSession();
|
|
3164
|
+
const query = useMemberQuery(
|
|
3165
|
+
relayKeys.consent,
|
|
3166
|
+
(options) => relay.consent.get(options)
|
|
3167
|
+
);
|
|
3168
|
+
const { isPending, actionError: actionError2, resetAction, run, retry, settle } = useAction();
|
|
3169
|
+
const actions = useMemo10(() => {
|
|
3170
|
+
const change = (channel, granted, wording) => run(async (actionId) => {
|
|
3171
|
+
const cache = store.scope?.cache;
|
|
3172
|
+
await relay.consent.set(
|
|
3173
|
+
{
|
|
3174
|
+
actionId,
|
|
3175
|
+
channel,
|
|
3176
|
+
granted,
|
|
3177
|
+
...wording === void 0 ? {} : { wording }
|
|
3178
|
+
},
|
|
3179
|
+
{ session }
|
|
3180
|
+
);
|
|
3181
|
+
void cache?.invalidate([relayKeys.consent]);
|
|
3182
|
+
});
|
|
3183
|
+
return {
|
|
3184
|
+
/** Records the member's opt-in on `channel`, with the wording they saw. */
|
|
3185
|
+
grant: (channel, wording) => change(channel, true, wording),
|
|
3186
|
+
/** Records the member's opt-out on `channel`, with the wording they saw if there was any. */
|
|
3187
|
+
withdraw: (channel, wording) => change(channel, false, wording)
|
|
3188
|
+
};
|
|
3189
|
+
}, [relay, store, session, run]);
|
|
3190
|
+
return useMemo10(
|
|
3191
|
+
() => ({
|
|
3192
|
+
...query,
|
|
3193
|
+
isPending,
|
|
3194
|
+
actionError: actionError2,
|
|
3195
|
+
resetAction,
|
|
3196
|
+
retry,
|
|
3197
|
+
settle,
|
|
3198
|
+
...actions
|
|
3199
|
+
}),
|
|
3200
|
+
[query, isPending, actionError2, resetAction, retry, settle, actions]
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3052
3204
|
// src/react/referrals.ts
|
|
3053
|
-
import { useCallback as
|
|
3205
|
+
import { useCallback as useCallback9, useEffect as useEffect7, useMemo as useMemo11, useRef as useRef7, useState as useState8 } from "react";
|
|
3054
3206
|
var PENDING = "domino:pending-referral";
|
|
3055
3207
|
var CODE = /^[a-zA-Z0-9_-]{1,100}$/;
|
|
3056
3208
|
function captureReferralCode(param = "ref") {
|
|
@@ -3100,7 +3252,7 @@ function useInvitation(param = "ref") {
|
|
|
3100
3252
|
action: createRelayAction()
|
|
3101
3253
|
};
|
|
3102
3254
|
}
|
|
3103
|
-
const accept =
|
|
3255
|
+
const accept = useCallback9(
|
|
3104
3256
|
async (code) => {
|
|
3105
3257
|
const owner = pending.current;
|
|
3106
3258
|
if (owner.action.busy) {
|
|
@@ -3145,7 +3297,7 @@ function useInvitation(param = "ref") {
|
|
|
3145
3297
|
void accept(state.code);
|
|
3146
3298
|
}
|
|
3147
3299
|
}, [member, state, accept]);
|
|
3148
|
-
return
|
|
3300
|
+
return useMemo11(() => ({ invitation: state, accept }), [state, accept]);
|
|
3149
3301
|
}
|
|
3150
3302
|
function useReferralSummary(options = {}) {
|
|
3151
3303
|
const relay = useRelay();
|
|
@@ -3155,7 +3307,7 @@ function useReferralSummary(options = {}) {
|
|
|
3155
3307
|
(request) => relay.referrals.summary(request),
|
|
3156
3308
|
{ intervalMs }
|
|
3157
3309
|
);
|
|
3158
|
-
return
|
|
3310
|
+
return useMemo11(() => {
|
|
3159
3311
|
let link = null;
|
|
3160
3312
|
if (query.data && typeof window !== "undefined") {
|
|
3161
3313
|
const url = new URL(path, window.location.origin);
|
|
@@ -3222,7 +3374,7 @@ function useQuestOutcomes(query = {}) {
|
|
|
3222
3374
|
}
|
|
3223
3375
|
|
|
3224
3376
|
// src/react/offers.ts
|
|
3225
|
-
import { useCallback as
|
|
3377
|
+
import { useCallback as useCallback10, useMemo as useMemo12 } from "react";
|
|
3226
3378
|
function useOffers() {
|
|
3227
3379
|
const relay = useRelay();
|
|
3228
3380
|
return useRelayQuery(
|
|
@@ -3237,11 +3389,11 @@ function useRedeemOffer() {
|
|
|
3237
3389
|
{ invalidates: [relayKeys.offers, relayKeys.balances] }
|
|
3238
3390
|
);
|
|
3239
3391
|
const { mutateAsync } = mutation;
|
|
3240
|
-
const redeem =
|
|
3392
|
+
const redeem = useCallback10(
|
|
3241
3393
|
(offer) => mutateAsync(offer).catch(() => null),
|
|
3242
3394
|
[mutateAsync]
|
|
3243
3395
|
);
|
|
3244
|
-
return
|
|
3396
|
+
return useMemo12(
|
|
3245
3397
|
() => ({ ...mutation, redeem, retry: replay, busy: mutation.isPending }),
|
|
3246
3398
|
[mutation, redeem, replay]
|
|
3247
3399
|
);
|
|
@@ -3281,11 +3433,13 @@ export {
|
|
|
3281
3433
|
roleDeliveryLabel,
|
|
3282
3434
|
roleDeliveryStatus,
|
|
3283
3435
|
telegramMiniAppInitData,
|
|
3436
|
+
useAccount,
|
|
3284
3437
|
useAccounts,
|
|
3285
3438
|
useActivity,
|
|
3286
3439
|
useBadgeCatalog,
|
|
3287
3440
|
useBadges,
|
|
3288
3441
|
useBalances,
|
|
3442
|
+
useConsent,
|
|
3289
3443
|
useCreatorAccounts,
|
|
3290
3444
|
useDeliveries,
|
|
3291
3445
|
useEntitlements,
|
|
@@ -64,34 +64,4 @@ declare class RequestError extends Error {
|
|
|
64
64
|
constructor(message: string, details: RequestErrorDetails);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
type OptionalActionId<T> = T extends {
|
|
69
|
-
actionId: string;
|
|
70
|
-
} ? Omit<T, "actionId"> & {
|
|
71
|
-
actionId?: string;
|
|
72
|
-
} : never;
|
|
73
|
-
/** One logical write. Keep this object until its outcome is definite. */
|
|
74
|
-
type RelayAction<T> = {
|
|
75
|
-
/** The pending write's key, also available on its uncertain error as `operationId`. */
|
|
76
|
-
readonly actionId: string | undefined;
|
|
77
|
-
readonly busy: boolean;
|
|
78
|
-
readonly error: RequestError | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Starts a write with a generated key. While an uncertain write is pending, replays its saved
|
|
81
|
-
* callback instead of accepting a different write. Concurrent calls share one request.
|
|
82
|
-
* Put refreshes and other follow-up work outside the callback.
|
|
83
|
-
*/
|
|
84
|
-
run(task: (actionId: string) => Promise<T>): Promise<T>;
|
|
85
|
-
/** Replays the exact pending callback and key, only when the error's recovery is `replay`. */
|
|
86
|
-
retry(): Promise<T>;
|
|
87
|
-
/** Acknowledge an authoritative, definite outcome after reconciliation. Refuses while busy. */
|
|
88
|
-
settle(): boolean;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Owns a mutation key across uncertain answers. A definite success or refusal ends the action;
|
|
92
|
-
* the next `run` gets a new key. `reconcile` failures stay pending and cannot be replayed.
|
|
93
|
-
* In-memory only: persist the key yourself if recovery must survive a reload or process restart.
|
|
94
|
-
*/
|
|
95
|
-
declare function createRelayAction<T = unknown>(): RelayAction<T>;
|
|
96
|
-
|
|
97
|
-
export { type OptionalActionId as O, type RelayAction as R, RequestError as a, type RequestErrorDetails as b, type RequestErrorKind as c, type RequestRecovery as d, createRelayAction as e, isRequestError as i };
|
|
67
|
+
export { RequestError as R, type RequestErrorDetails as a, type RequestErrorKind as b, type RequestRecovery as c, isRequestError as i };
|