@domino-sdk/relay 1.60.0 → 1.62.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 +175 -8
- package/README.md +3 -2
- package/dist/{schema-CwbRkmlr.d.ts → accounts-CCqCKCVx.d.ts} +3127 -1764
- package/dist/action-9Xl0StBg.d.ts +33 -0
- package/dist/{analytics-URV-mxjH.d.ts → analytics-BwAKLi7O.d.ts} +347 -3
- package/dist/{attempt-captures-W2dgzGqE.d.ts → attempt-captures-Cm-5G0PC.d.ts} +1 -1
- package/dist/authoring.d.ts +130 -42
- package/dist/authoring.js +105 -19
- package/dist/{automatic-outcomes-Cmou89IS.d.ts → automatic-outcomes-pAsOyIVp.d.ts} +5 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +15 -11
- package/dist/browser.js +15 -11
- package/dist/{integrations-CmIkP1Gi.d.ts → capability-error-DFMwSuSf.d.ts} +160 -42
- package/dist/{pages-Bti7g5mX.d.ts → catalog--ZIlskAo.d.ts} +39 -561
- package/dist/{chunk-N3LJ6GFK.js → chunk-3KLC4AMA.js} +40 -11
- package/dist/{chunk-6ZG7WNYX.js → chunk-3PYYGFSB.js} +14 -2
- package/dist/{chunk-VWMIA2TT.js → chunk-5TEYFX6X.js} +2 -2
- package/dist/chunk-6WCIWXUV.js +31 -0
- package/dist/chunk-CICDIBOF.js +373 -0
- package/dist/{chunk-MHPKEVEW.js → chunk-CZFXGGEK.js} +5 -0
- package/dist/chunk-D26YNACF.js +320 -0
- package/dist/{chunk-KUPVQXUJ.js → chunk-E6IKQHTX.js} +2 -2
- package/dist/chunk-FWLQ5XCS.js +21 -0
- package/dist/{chunk-VVRQQRMQ.js → chunk-GKIFABGN.js} +150 -61
- package/dist/chunk-GTDW453U.js +522 -0
- package/dist/{chunk-Y2IGFLD2.js → chunk-HTZHBTIL.js} +69 -27
- package/dist/chunk-K2KS3JLY.js +188 -0
- package/dist/{chunk-GBSDAD3N.js → chunk-MK425RXJ.js} +3140 -3202
- package/dist/{chunk-YOAPPIWN.js → chunk-QYPMPWVX.js} +1 -1
- package/dist/chunk-UAKYDVT3.js +565 -0
- package/dist/{chunk-KWFY7L7X.js → chunk-UPQPUJOU.js} +36 -123
- package/dist/{chunk-2FHNY52R.js → chunk-UW5232GG.js} +65 -19
- package/dist/chunk-WSBYWVTZ.js +717 -0
- package/dist/{chunk-422J3QRW.js → chunk-XJFYAXET.js} +9 -8
- package/dist/{chunk-OTEUP2SG.js → chunk-XNKSSE32.js} +1 -1
- package/dist/{chunk-4OFH4BNX.js → chunk-Y322OTCH.js} +1 -1
- package/dist/{client-Cw1pB5sv.d.ts → client-B-hbHX30.d.ts} +109 -40
- package/dist/{deployments-DI-W7fBq.d.ts → deployments-M4OHn7G3.d.ts} +407 -18
- package/dist/identity-integration-3mX6b5iH.d.ts +1241 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +14 -11
- package/dist/internal.d.ts +14 -12
- package/dist/internal.js +26 -14
- package/dist/{offers-CqXfMIxq.d.ts → offers-DhAtss4_.d.ts} +21 -4
- package/dist/pages-B8q8Y_dQ.d.ts +715 -0
- package/dist/{participant-activity-DHL8QYks.d.ts → participant-activity-D-Drp24G.d.ts} +16 -3
- package/dist/portal-proxy.d.ts +59 -2
- package/dist/portal-proxy.js +109 -23
- package/dist/react/index.d.ts +211 -27
- package/dist/react/index.js +286 -29
- package/dist/{action-DBzILFx9.d.ts → request-error-D_dUPLwo.d.ts} +1 -31
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/Y4OAVXFR.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/schema.d.ts +154 -30
- package/dist/schema.js +128 -75
- package/dist/server/index.d.ts +14 -12
- package/dist/server/index.js +2189 -1631
- package/dist/sign-in-providers-BkjcDsFF.d.ts +39 -0
- package/dist/submission-input-DHGKhXfp.d.ts +342 -0
- package/dist/{telegram-browser-CTJh4Ro_.d.ts → telegram-browser-BCE7zdOb.d.ts} +49 -6
- package/dist/telegram.d.ts +64 -0
- package/dist/telegram.js +23 -0
- package/dist/testing.d.ts +112 -15
- package/dist/testing.js +321 -16
- package/dist/tracker-data-Hb1uQnk5.d.ts +1855 -0
- package/dist/{transport-B8Ss5lcz.d.ts → transport-DkhX2Cbs.d.ts} +5863 -2217
- package/dist/{wallet-DZWL7lJH.d.ts → wallet-DTO7SXj7.d.ts} +27 -7
- 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-MJEJQH5A.js +0 -962
- package/dist/chunk-N7YOS4ZU.js +0 -13
- package/dist/chunk-XQKUJL7H.js +0 -602
- package/dist/chunk-YNW2ZUUP.js +0 -247
- package/dist/groups-9Jm3peq3.d.ts +0 -2827
- package/dist/runtime/chunks/ADUMK6CR.js +0 -1
- package/dist/submission-input-D9EGH_yb.d.ts +0 -146
- package/dist/x-KFJD2x8y.d.ts +0 -331
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import {
|
|
2
|
+
badgeSchema,
|
|
3
|
+
pointLedgerReferenceSchema
|
|
4
|
+
} from "./chunk-WSBYWVTZ.js";
|
|
5
|
+
import {
|
|
6
|
+
authoringIdentityShape,
|
|
7
|
+
entitlementSchema,
|
|
8
|
+
identifier,
|
|
9
|
+
mediaUrlSchema,
|
|
10
|
+
memberProgressSchema,
|
|
11
|
+
pageCursorSchema,
|
|
12
|
+
prerequisiteSchema,
|
|
13
|
+
publishedReleaseSchema,
|
|
14
|
+
questPresentationContentSchema,
|
|
15
|
+
questScaleLimits,
|
|
16
|
+
responseShape,
|
|
17
|
+
retryCooldownMsSchema,
|
|
18
|
+
reviewModeSchema,
|
|
19
|
+
sdkRuntimeReferenceSchema,
|
|
20
|
+
settingsValuesSchema,
|
|
21
|
+
storedQuestDescriptionSchema,
|
|
22
|
+
storedReviewModeSchema,
|
|
23
|
+
tieredRewardReferenceSchema
|
|
24
|
+
} from "./chunk-MK425RXJ.js";
|
|
25
|
+
|
|
26
|
+
// src/participant-activity.ts
|
|
27
|
+
import * as z from "zod";
|
|
28
|
+
var base = { id: z.string(), at: z.number() };
|
|
29
|
+
var attempt = {
|
|
30
|
+
...base,
|
|
31
|
+
quest: z.string(),
|
|
32
|
+
attempt: z.string(),
|
|
33
|
+
completion: z.string().nullable()
|
|
34
|
+
};
|
|
35
|
+
var kinds = [
|
|
36
|
+
"attempt.accepted",
|
|
37
|
+
"attempt.rejected",
|
|
38
|
+
"attempt.review",
|
|
39
|
+
"points.awarded",
|
|
40
|
+
"entitlement.granted",
|
|
41
|
+
"entitlement.collected",
|
|
42
|
+
"delivery.updated",
|
|
43
|
+
"referral.qualified"
|
|
44
|
+
];
|
|
45
|
+
var knownRelayEventSchema = z.discriminatedUnion("kind", [
|
|
46
|
+
z.object({ ...attempt, kind: z.literal("attempt.accepted") }),
|
|
47
|
+
z.object({ ...attempt, kind: z.literal("attempt.rejected") }),
|
|
48
|
+
z.object({ ...attempt, kind: z.literal("attempt.review") }),
|
|
49
|
+
z.object({
|
|
50
|
+
...base,
|
|
51
|
+
kind: z.literal("points.awarded"),
|
|
52
|
+
entry: z.string(),
|
|
53
|
+
ledger: z.string(),
|
|
54
|
+
amount: z.number(),
|
|
55
|
+
quest: z.string().nullable(),
|
|
56
|
+
completion: z.string().nullable()
|
|
57
|
+
}),
|
|
58
|
+
z.object({
|
|
59
|
+
...base,
|
|
60
|
+
kind: z.literal("entitlement.granted"),
|
|
61
|
+
entitlement: z.string(),
|
|
62
|
+
tier: z.string(),
|
|
63
|
+
status: z.string()
|
|
64
|
+
}),
|
|
65
|
+
z.object({
|
|
66
|
+
...base,
|
|
67
|
+
kind: z.literal("entitlement.collected"),
|
|
68
|
+
entitlement: z.string()
|
|
69
|
+
}),
|
|
70
|
+
z.object({
|
|
71
|
+
...base,
|
|
72
|
+
kind: z.literal("delivery.updated"),
|
|
73
|
+
delivery: z.string(),
|
|
74
|
+
quest: z.string(),
|
|
75
|
+
completion: z.string(),
|
|
76
|
+
status: z.string()
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
...base,
|
|
80
|
+
kind: z.literal("referral.qualified"),
|
|
81
|
+
program: z.string()
|
|
82
|
+
})
|
|
83
|
+
]);
|
|
84
|
+
var relayEventSchema = z.union([
|
|
85
|
+
knownRelayEventSchema,
|
|
86
|
+
z.object({
|
|
87
|
+
...base,
|
|
88
|
+
kind: z.string().refine((kind) => !kinds.includes(kind))
|
|
89
|
+
}).catchall(z.json()).transform(({ kind, ...event }) => ({
|
|
90
|
+
...event,
|
|
91
|
+
kind: "unknown",
|
|
92
|
+
reportedKind: kind
|
|
93
|
+
}))
|
|
94
|
+
]);
|
|
95
|
+
var participantActivityQuerySchema = z.object({
|
|
96
|
+
cursor: pageCursorSchema.optional(),
|
|
97
|
+
/** `latest` answers no events and the cursor of the newest one, to follow only what comes next. */
|
|
98
|
+
start: z.literal("latest").optional(),
|
|
99
|
+
limit: z.number().int().min(1).max(100).default(50)
|
|
100
|
+
}).strict().refine((query) => !(query.cursor && query.start), {
|
|
101
|
+
message: "Pass either cursor or start, not both"
|
|
102
|
+
});
|
|
103
|
+
var participantActivitySchema = z.object({
|
|
104
|
+
member: z.string(),
|
|
105
|
+
items: z.array(relayEventSchema),
|
|
106
|
+
/**
|
|
107
|
+
* Never null: the feed has no last page, so an empty page still answers the cursor to read
|
|
108
|
+
* from next. A loop over it, such as `paginate`, stops on its own condition, such as an empty
|
|
109
|
+
* page or a count.
|
|
110
|
+
*/
|
|
111
|
+
nextCursor: pageCursorSchema
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// src/catalog.ts
|
|
115
|
+
import * as z2 from "zod";
|
|
116
|
+
var interactionSchema = z2.enum([
|
|
117
|
+
"photo",
|
|
118
|
+
"text",
|
|
119
|
+
"url",
|
|
120
|
+
"quiz",
|
|
121
|
+
"claim",
|
|
122
|
+
"staff",
|
|
123
|
+
"automatic"
|
|
124
|
+
]);
|
|
125
|
+
function questInteraction(trigger) {
|
|
126
|
+
return trigger.kind === "automatic" ? "automatic" : trigger.actor === "staff" ? "staff" : trigger.input === "none" ? "claim" : trigger.input;
|
|
127
|
+
}
|
|
128
|
+
var questTypeVersionSchema = z2.object({
|
|
129
|
+
archivedAt: z2.number().int().nonnegative().nullable().optional(),
|
|
130
|
+
key: identifier.optional(),
|
|
131
|
+
id: identifier,
|
|
132
|
+
version: identifier,
|
|
133
|
+
code: z2.string(),
|
|
134
|
+
/** The SDK runtime `code` imports. Absent, the code bundles its own SDK. */
|
|
135
|
+
runtime: sdkRuntimeReferenceSchema.optional(),
|
|
136
|
+
definition: storedQuestDescriptionSchema,
|
|
137
|
+
provider: storedReviewModeSchema,
|
|
138
|
+
createdAt: z2.number()
|
|
139
|
+
});
|
|
140
|
+
var collectionSlotSchema = z2.object({
|
|
141
|
+
archivedAt: z2.number().int().nonnegative().nullable().optional(),
|
|
142
|
+
id: identifier,
|
|
143
|
+
key: identifier.optional(),
|
|
144
|
+
title: z2.string().trim().min(1).max(120),
|
|
145
|
+
description: z2.string().max(4e3).optional(),
|
|
146
|
+
image: mediaUrlSchema.optional(),
|
|
147
|
+
imageAlt: z2.string().max(500).optional()
|
|
148
|
+
});
|
|
149
|
+
var collectionSlotDeclarationSchema = collectionSlotSchema.omit({ id: true, archivedAt: true }).extend(authoringIdentityShape).strict();
|
|
150
|
+
var questCollectionSchema = collectionSlotSchema.extend({
|
|
151
|
+
quests: z2.array(identifier).max(100).refine(
|
|
152
|
+
(v) => new Set(v).size === v.length,
|
|
153
|
+
"A collection can contain a quest only once"
|
|
154
|
+
)
|
|
155
|
+
});
|
|
156
|
+
var questInstanceSchema = z2.object({
|
|
157
|
+
badges: z2.array(identifier).max(10).refine(
|
|
158
|
+
(items) => new Set(items).size === items.length,
|
|
159
|
+
"Choose each badge once"
|
|
160
|
+
).optional(),
|
|
161
|
+
id: identifier,
|
|
162
|
+
title: z2.string().trim().min(1).max(120),
|
|
163
|
+
typeVersion: identifier,
|
|
164
|
+
presentation: questPresentationContentSchema.optional(),
|
|
165
|
+
settings: settingsValuesSchema,
|
|
166
|
+
requires: z2.array(prerequisiteSchema).max(30),
|
|
167
|
+
/**
|
|
168
|
+
* Milliseconds a member waits after a rejected attempt before submitting again, or `null` for
|
|
169
|
+
* no cooldown. Omitted: the quest type's own `retryCooldownMs`.
|
|
170
|
+
*/
|
|
171
|
+
retryCooldownMs: retryCooldownMsSchema.nullable().optional(),
|
|
172
|
+
/**
|
|
173
|
+
* Milliseconds a member waits after an accepted completion before submitting again, or `null`
|
|
174
|
+
* for no cooldown. Omitted: the quest type's own `completionCooldownMs`.
|
|
175
|
+
*/
|
|
176
|
+
completionCooldownMs: retryCooldownMsSchema.nullable().optional(),
|
|
177
|
+
status: z2.enum(["active", "paused", "archived"])
|
|
178
|
+
}).strict();
|
|
179
|
+
var questDraftChangesSchema = z2.object({
|
|
180
|
+
quests: z2.array(
|
|
181
|
+
questInstanceSchema.extend({ expectedRelease: identifier.nullable() })
|
|
182
|
+
).max(questScaleLimits.quests),
|
|
183
|
+
collections: z2.array(questCollectionSchema.omit({ archivedAt: true }).strict()).max(questScaleLimits.collections)
|
|
184
|
+
}).strict();
|
|
185
|
+
var draftBase = z2.object({
|
|
186
|
+
id: identifier,
|
|
187
|
+
revision: z2.number().int().positive(),
|
|
188
|
+
baseRevision: z2.number().int().nonnegative(),
|
|
189
|
+
changes: questDraftChangesSchema
|
|
190
|
+
});
|
|
191
|
+
var questDraftSchema = responseShape(
|
|
192
|
+
z2.discriminatedUnion("status", [
|
|
193
|
+
draftBase.extend({ status: z2.literal("draft") }),
|
|
194
|
+
draftBase.extend({
|
|
195
|
+
status: z2.literal("published"),
|
|
196
|
+
releaseIds: z2.array(identifier)
|
|
197
|
+
})
|
|
198
|
+
])
|
|
199
|
+
);
|
|
200
|
+
var questCatalogSchema = responseShape(
|
|
201
|
+
z2.object({
|
|
202
|
+
revision: z2.number().int().nonnegative(),
|
|
203
|
+
types: z2.array(questTypeVersionSchema),
|
|
204
|
+
collections: z2.array(questCollectionSchema),
|
|
205
|
+
quests: z2.array(questInstanceSchema),
|
|
206
|
+
drafts: z2.array(questDraftSchema),
|
|
207
|
+
releases: z2.array(publishedReleaseSchema).default([]),
|
|
208
|
+
supportedInteractions: z2.array(interactionSchema)
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
var catalogDeploymentSchema = z2.object({
|
|
212
|
+
expectedRevision: z2.number().int().nonnegative(),
|
|
213
|
+
types: z2.array(
|
|
214
|
+
z2.object({
|
|
215
|
+
code: z2.string().min(1).max(1e6),
|
|
216
|
+
runtime: sdkRuntimeReferenceSchema.optional(),
|
|
217
|
+
provider: reviewModeSchema
|
|
218
|
+
})
|
|
219
|
+
).max(questScaleLimits.questTypes).default([]),
|
|
220
|
+
collections: z2.array(collectionSlotDeclarationSchema).max(questScaleLimits.collections).default([]),
|
|
221
|
+
supportedInteractions: z2.array(interactionSchema).min(1).optional()
|
|
222
|
+
}).strict();
|
|
223
|
+
var catalogDeploymentPreviewSchema = responseShape(
|
|
224
|
+
z2.object({
|
|
225
|
+
revision: z2.number().int().nonnegative(),
|
|
226
|
+
types: z2.array(questTypeVersionSchema),
|
|
227
|
+
collections: z2.array(collectionSlotSchema),
|
|
228
|
+
supportedInteractions: z2.array(interactionSchema)
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
var saveQuestDraftSchema = z2.object({
|
|
232
|
+
id: identifier.optional(),
|
|
233
|
+
actionId: identifier,
|
|
234
|
+
expectedRevision: z2.number().int().nonnegative(),
|
|
235
|
+
baseRevision: z2.number().int().nonnegative(),
|
|
236
|
+
changes: questDraftChangesSchema
|
|
237
|
+
}).strict();
|
|
238
|
+
var publishQuestDraftSchema = z2.object({ id: identifier, expectedRevision: z2.number().int().positive() }).strict();
|
|
239
|
+
var questRewardViewSchema = z2.discriminatedUnion("kind", [
|
|
240
|
+
z2.object({
|
|
241
|
+
kind: z2.literal("points"),
|
|
242
|
+
label: z2.string(),
|
|
243
|
+
amount: z2.number().int().nonnegative(),
|
|
244
|
+
ledger: pointLedgerReferenceSchema
|
|
245
|
+
}),
|
|
246
|
+
z2.object({
|
|
247
|
+
kind: z2.literal("tier"),
|
|
248
|
+
label: z2.string(),
|
|
249
|
+
reward: tieredRewardReferenceSchema.extend({
|
|
250
|
+
title: z2.string(),
|
|
251
|
+
badge: badgeSchema.optional(),
|
|
252
|
+
/** The group the reward adds the member to: its key and the title the quest names it by. */
|
|
253
|
+
group: z2.object({ key: identifier, title: z2.string() }).optional()
|
|
254
|
+
}),
|
|
255
|
+
tier: identifier
|
|
256
|
+
}),
|
|
257
|
+
z2.object({ kind: z2.literal("integration"), label: z2.string() })
|
|
258
|
+
]);
|
|
259
|
+
var questViewSchema = responseShape(
|
|
260
|
+
memberProgressSchema.shape.quests.element.extend({
|
|
261
|
+
release: identifier,
|
|
262
|
+
interaction: interactionSchema,
|
|
263
|
+
lifecycle: z2.enum(["active", "paused", "archived"]),
|
|
264
|
+
rewards: z2.array(questRewardViewSchema)
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
var collectionViewSchema = z2.object({
|
|
268
|
+
key: identifier.optional(),
|
|
269
|
+
id: identifier,
|
|
270
|
+
title: z2.string(),
|
|
271
|
+
description: z2.string().optional(),
|
|
272
|
+
image: mediaUrlSchema.optional(),
|
|
273
|
+
imageAlt: z2.string().optional(),
|
|
274
|
+
quests: z2.array(questViewSchema)
|
|
275
|
+
});
|
|
276
|
+
var questExperienceSchema = responseShape(
|
|
277
|
+
z2.object({
|
|
278
|
+
entitlements: z2.array(entitlementSchema).default([]),
|
|
279
|
+
member: identifier,
|
|
280
|
+
quests: z2.array(questViewSchema),
|
|
281
|
+
collections: z2.array(collectionViewSchema)
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
var questPublicationPreviewSchema = responseShape(
|
|
285
|
+
z2.object({
|
|
286
|
+
draft: questDraftSchema,
|
|
287
|
+
releases: z2.array(publishedReleaseSchema),
|
|
288
|
+
affectedCollections: z2.array(questCollectionSchema)
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
var allocateQuestSchema = z2.object({ actionId: identifier }).strict();
|
|
292
|
+
var allocatedQuestSchema = z2.object({ id: identifier });
|
|
293
|
+
|
|
294
|
+
export {
|
|
295
|
+
knownRelayEventSchema,
|
|
296
|
+
relayEventSchema,
|
|
297
|
+
participantActivityQuerySchema,
|
|
298
|
+
participantActivitySchema,
|
|
299
|
+
interactionSchema,
|
|
300
|
+
questInteraction,
|
|
301
|
+
questTypeVersionSchema,
|
|
302
|
+
collectionSlotSchema,
|
|
303
|
+
collectionSlotDeclarationSchema,
|
|
304
|
+
questCollectionSchema,
|
|
305
|
+
questInstanceSchema,
|
|
306
|
+
questDraftChangesSchema,
|
|
307
|
+
questDraftSchema,
|
|
308
|
+
questCatalogSchema,
|
|
309
|
+
catalogDeploymentSchema,
|
|
310
|
+
catalogDeploymentPreviewSchema,
|
|
311
|
+
saveQuestDraftSchema,
|
|
312
|
+
publishQuestDraftSchema,
|
|
313
|
+
questRewardViewSchema,
|
|
314
|
+
questViewSchema,
|
|
315
|
+
collectionViewSchema,
|
|
316
|
+
questExperienceSchema,
|
|
317
|
+
questPublicationPreviewSchema,
|
|
318
|
+
allocateQuestSchema,
|
|
319
|
+
allocatedQuestSchema
|
|
320
|
+
};
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
imageFieldsSchema,
|
|
5
5
|
imageInspectionSchema,
|
|
6
6
|
imageSightingsSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QYPMPWVX.js";
|
|
8
8
|
import {
|
|
9
9
|
photoResultSchema
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MK425RXJ.js";
|
|
11
11
|
|
|
12
12
|
// src/image-results.ts
|
|
13
13
|
import * as z from "zod";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/telegram-browser.ts
|
|
2
|
+
function miniAppInitData() {
|
|
3
|
+
const scope = globalThis;
|
|
4
|
+
const fromScript = scope.Telegram?.WebApp?.initData;
|
|
5
|
+
if (typeof fromScript === "string" && fromScript.length > 0) {
|
|
6
|
+
return fromScript;
|
|
7
|
+
}
|
|
8
|
+
const hash = scope.location?.hash;
|
|
9
|
+
if (!hash) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return new URLSearchParams(hash.replace(/^#/, "")).get("tgWebAppData") || null;
|
|
13
|
+
}
|
|
14
|
+
function telegramMiniAppInitData() {
|
|
15
|
+
return miniAppInitData();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
miniAppInitData,
|
|
20
|
+
telegramMiniAppInitData
|
|
21
|
+
};
|