@frak-labs/core-sdk 1.1.3 → 1.1.5-beta.5b65e64f
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/cdn/bundle.js +1 -1
- package/dist/actions-Cyn4asew.cjs +2 -0
- package/dist/actions-Cyn4asew.cjs.map +1 -0
- package/dist/actions-DtPVuk2e.js +2 -0
- package/dist/actions-DtPVuk2e.js.map +1 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +3 -3
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +1 -1
- package/dist/bundle.d.cts +5 -4
- package/dist/bundle.d.ts +5 -4
- package/dist/bundle.js +1 -1
- package/dist/frakContext-Bgidv-Se.js +2 -0
- package/dist/frakContext-Bgidv-Se.js.map +1 -0
- package/dist/frakContext-CeVlWFcX.cjs +2 -0
- package/dist/frakContext-CeVlWFcX.cjs.map +1 -0
- package/dist/getCurrencyAmountKey-DQcwjJiB.js +2 -0
- package/dist/getCurrencyAmountKey-DQcwjJiB.js.map +1 -0
- package/dist/getCurrencyAmountKey-h2eOiYzv.cjs +2 -0
- package/dist/getCurrencyAmountKey-h2eOiYzv.cjs.map +1 -0
- package/dist/{index-lcImYQyL.d.ts → index-BCoPwxjq.d.cts} +4 -2
- package/dist/{index-C5pP_9We.d.cts → index-CiHjUnfc.d.ts} +43 -6
- package/dist/{index-DrYZwIjb.d.ts → index-D25z5B9K.d.cts} +43 -6
- package/dist/{index-DR4n-QOe.d.cts → index-trhAN7q9.d.ts} +4 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/merchantInformation--tLnowAN.d.ts +344 -0
- package/dist/merchantInformation-BSuahpjl.d.cts +344 -0
- package/dist/{openSso-BErs7_Bg.d.cts → openSso-CENLMWJx.d.ts} +4 -279
- package/dist/{openSso-DRLH4D9a.d.ts → openSso-CKvkAGts.d.cts} +4 -279
- package/dist/rewards.cjs +2 -0
- package/dist/rewards.cjs.map +1 -0
- package/dist/rewards.d.cts +101 -0
- package/dist/rewards.d.ts +101 -0
- package/dist/rewards.js +2 -0
- package/dist/rewards.js.map +1 -0
- package/dist/src-BXtnEE3a.js +2 -0
- package/dist/src-BXtnEE3a.js.map +1 -0
- package/dist/src-TpX-7MwJ.cjs +2 -0
- package/dist/src-TpX-7MwJ.cjs.map +1 -0
- package/package.json +16 -3
- package/src/actions/getMerchantInformation.test.ts +2 -0
- package/src/actions/referral/processReferral.test.ts +4 -4
- package/src/actions/referral/processReferral.ts +4 -4
- package/src/clients/createIFrameFrakClient.ts +7 -7
- package/src/clients/transports/iframeLifecycleManager.ts +5 -21
- package/src/config/sdkConfigStore.ts +6 -3
- package/src/context/frakContext.test.ts +55 -0
- package/src/context/frakContext.ts +13 -2
- package/src/index.ts +8 -0
- package/src/rewards/conditions.test.ts +60 -0
- package/src/rewards/conditions.ts +72 -0
- package/src/rewards/example.test.ts +92 -0
- package/src/rewards/example.ts +57 -0
- package/src/rewards/format.test.ts +143 -0
- package/src/rewards/format.ts +81 -0
- package/src/rewards/index.ts +27 -0
- package/src/rewards/select.test.ts +212 -0
- package/src/rewards/select.ts +132 -0
- package/src/rewards/value.test.ts +89 -0
- package/src/rewards/value.ts +73 -0
- package/src/types/index.ts +6 -0
- package/src/types/rpc/merchantInformation.ts +120 -13
- package/src/utils/analytics/events/lifecycle.ts +1 -1
- package/src/utils/analytics/events/referral.ts +3 -3
- package/src/utils/browser/deepLinkWithFallback.ts +4 -1
- package/src/utils/browser/inAppBrowser.ts +2 -2
- package/src/utils/cache/withCache.ts +30 -11
- package/src/utils/iframe/iframeHelper.test.ts +39 -0
- package/src/utils/iframe/iframeHelper.ts +31 -2
- package/src/utils/index.ts +5 -0
- package/src/utils/url/queryParams.test.ts +85 -0
- package/src/utils/url/queryParams.ts +57 -0
- package/dist/actions-D5rNeJC0.js +0 -1
- package/dist/actions-gmdNZvNh.cjs +0 -1
- package/dist/frakContext-Cfp7sSid.cjs +0 -1
- package/dist/frakContext-UEOk9Bk4.js +0 -1
- package/dist/src-BEMVYU3J.js +0 -1
- package/dist/src-C9inMs4I.cjs +0 -1
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
//#region src/types/tracking.d.ts
|
|
4
|
+
type UtmParams = {
|
|
5
|
+
source?: string;
|
|
6
|
+
medium?: string;
|
|
7
|
+
campaign?: string;
|
|
8
|
+
term?: string;
|
|
9
|
+
content?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Attribution parameters appended to outbound sharing URLs.
|
|
13
|
+
*
|
|
14
|
+
* Defaults are derived from the V2 Frak context when available:
|
|
15
|
+
* - `utmSource`: `"frak"`
|
|
16
|
+
* - `utmMedium`: `"referral"`
|
|
17
|
+
* - `utmCampaign`: merchantId (`context.m`)
|
|
18
|
+
* - `via`: `"frak"`
|
|
19
|
+
* - `ref`: clientId (`context.c`)
|
|
20
|
+
*
|
|
21
|
+
* Fields explicitly set here override the defaults. Existing params on the
|
|
22
|
+
* base URL are preserved (gap-fill policy) to respect merchant-provided UTMs.
|
|
23
|
+
*/
|
|
24
|
+
type AttributionParams = {
|
|
25
|
+
utmSource?: string;
|
|
26
|
+
utmMedium?: string;
|
|
27
|
+
utmCampaign?: string;
|
|
28
|
+
utmContent?: string;
|
|
29
|
+
utmTerm?: string;
|
|
30
|
+
via?: string;
|
|
31
|
+
ref?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Merchant-level attribution defaults.
|
|
35
|
+
*
|
|
36
|
+
* Same shape as {@link AttributionParams} minus `utmContent`, because
|
|
37
|
+
* `utm_content` describes the specific content/creative being shared and is
|
|
38
|
+
* inherently per-call or per-product (never a merchant-wide default).
|
|
39
|
+
*
|
|
40
|
+
* Used as the shape for both:
|
|
41
|
+
* - `FrakWalletSdkConfig.attribution` (SDK-side compile-time defaults)
|
|
42
|
+
* - Backend merchant-config attribution (dashboard-driven defaults)
|
|
43
|
+
*/
|
|
44
|
+
type AttributionDefaults = Omit<AttributionParams, "utmContent">;
|
|
45
|
+
type TrackArrivalParams = {
|
|
46
|
+
/** Sharer wallet address. Accepted in both V1 (legacy) and V2 (authenticated sharer) contexts. */referrerWallet?: Address;
|
|
47
|
+
referrerClientId?: string;
|
|
48
|
+
referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
|
|
49
|
+
referralTimestamp?: number;
|
|
50
|
+
};
|
|
51
|
+
type TrackArrivalResult = {
|
|
52
|
+
success: boolean;
|
|
53
|
+
identityGroupId?: string;
|
|
54
|
+
referralLinkId?: string;
|
|
55
|
+
error?: string;
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/types/config.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* All the currencies available
|
|
61
|
+
* @category Config
|
|
62
|
+
*/
|
|
63
|
+
type Currency = "eur" | "usd" | "gbp";
|
|
64
|
+
/**
|
|
65
|
+
* All the languages available
|
|
66
|
+
* @category Config
|
|
67
|
+
*/
|
|
68
|
+
type Language = "fr" | "en";
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for the Frak Wallet SDK
|
|
71
|
+
* @category Config
|
|
72
|
+
*/
|
|
73
|
+
type FrakWalletSdkConfig = {
|
|
74
|
+
/**
|
|
75
|
+
* The Frak wallet url
|
|
76
|
+
* @defaultValue "https://wallet.frak.id"
|
|
77
|
+
*/
|
|
78
|
+
walletUrl?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Some metadata about your implementation of the Frak SDK
|
|
81
|
+
*/
|
|
82
|
+
metadata: {
|
|
83
|
+
/**
|
|
84
|
+
* Your application name (will be displayed in a few modals and in SSO)
|
|
85
|
+
*/
|
|
86
|
+
name?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Your merchant ID from the Frak dashboard (UUID format)
|
|
89
|
+
* Used for referral tracking and analytics
|
|
90
|
+
* If not provided, will be auto-fetched from the backend using your domain
|
|
91
|
+
*/
|
|
92
|
+
merchantId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Language to display in the modal
|
|
95
|
+
* If undefined, will default to the browser language
|
|
96
|
+
*/
|
|
97
|
+
lang?: Language;
|
|
98
|
+
/**
|
|
99
|
+
* The currency to display in the modal
|
|
100
|
+
* @defaultValue `"eur"`
|
|
101
|
+
*/
|
|
102
|
+
currency?: Currency;
|
|
103
|
+
/**
|
|
104
|
+
* The logo URL that will be displayed in a few components
|
|
105
|
+
*/
|
|
106
|
+
logoUrl?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The homepage link that could be displayed in a few components
|
|
109
|
+
*/
|
|
110
|
+
homepageLink?: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Some customization for the modal
|
|
114
|
+
*/
|
|
115
|
+
customizations?: {
|
|
116
|
+
/**
|
|
117
|
+
* Custom CSS styles to apply to the modals and components
|
|
118
|
+
*/
|
|
119
|
+
css?: `${string}.css`;
|
|
120
|
+
/**
|
|
121
|
+
* Custom i18n configuration for the modal
|
|
122
|
+
*/
|
|
123
|
+
i18n?: I18nConfig;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* The domain name of your application
|
|
127
|
+
* @defaultValue window.location.host
|
|
128
|
+
*/
|
|
129
|
+
domain?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Wait for backend config before rendering components.
|
|
132
|
+
* When true (default), components show a spinner until backend config is resolved.
|
|
133
|
+
* When false, components render immediately with SDK static config / HTML attributes.
|
|
134
|
+
* @defaultValue true
|
|
135
|
+
*/
|
|
136
|
+
waitForBackendConfig?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Default attribution params (UTM / via / ref) appended to outbound
|
|
139
|
+
* sharing URLs. Per-call `displaySharingPage` overrides win, then backend
|
|
140
|
+
* config, then this SDK-level default. `utm_content` is intentionally
|
|
141
|
+
* excluded — it is per-content/per-product, never a merchant-wide default.
|
|
142
|
+
*/
|
|
143
|
+
attribution?: AttributionDefaults;
|
|
144
|
+
/**
|
|
145
|
+
* Preload specific UI views inside the listener iframe for better UX.
|
|
146
|
+
* Default: ["sharing"]
|
|
147
|
+
*/
|
|
148
|
+
preload?: ListenerPreloadOption[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Custom i18n configuration for the modal
|
|
152
|
+
* See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
|
|
153
|
+
*
|
|
154
|
+
* Available variables
|
|
155
|
+
* - `{{ productName }}` : The name of your website (`metadata.name`)
|
|
156
|
+
* - `{{ productOrigin }}` : The origin url of your website
|
|
157
|
+
* - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
|
|
158
|
+
*
|
|
159
|
+
* Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
|
|
160
|
+
* - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
|
|
161
|
+
* - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* // Multi language config
|
|
166
|
+
* const multiI18n = {
|
|
167
|
+
* fr: {
|
|
168
|
+
* "sdk.modal.title": "Titre de modal",
|
|
169
|
+
* "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
|
|
170
|
+
* },
|
|
171
|
+
* en: "https://example.com/en.json"
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* // Single language config
|
|
175
|
+
* const singleI18n = {
|
|
176
|
+
* "sdk.modal.title": "Modal title",
|
|
177
|
+
* "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @category Config
|
|
182
|
+
*/
|
|
183
|
+
type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
|
|
184
|
+
/**
|
|
185
|
+
* Options for preloading the listener UI
|
|
186
|
+
* @category Config
|
|
187
|
+
*/
|
|
188
|
+
type ListenerPreloadOption = "modal" | "sharing";
|
|
189
|
+
/**
|
|
190
|
+
* A localized i18n config (inline objects only — URL-based i18n removed)
|
|
191
|
+
* @category Config
|
|
192
|
+
*/
|
|
193
|
+
type LocalizedI18nConfig = {
|
|
194
|
+
[key: string]: string;
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/constants/interactionTypes.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* The supported interaction type keys
|
|
200
|
+
*
|
|
201
|
+
* - `referral` - User arrived via a referral link
|
|
202
|
+
* - `create_referral_link` - User created/shared a referral link
|
|
203
|
+
* - `purchase` - User completed a purchase
|
|
204
|
+
* - `custom.${string}` - Custom interaction type defined per campaign
|
|
205
|
+
*
|
|
206
|
+
* @inline
|
|
207
|
+
*/
|
|
208
|
+
type InteractionTypeKey = "referral" | "create_referral_link" | "purchase" | `custom.${string}`;
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/types/rpc/merchantInformation.d.ts
|
|
211
|
+
/**
|
|
212
|
+
* The type for the amount of tokens
|
|
213
|
+
*/
|
|
214
|
+
type TokenAmountType = {
|
|
215
|
+
amount: number;
|
|
216
|
+
eurAmount: number;
|
|
217
|
+
usdAmount: number;
|
|
218
|
+
gbpAmount: number;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* A tier definition for tiered rewards — pays either a flat token amount
|
|
222
|
+
* or a percent of the tier field value
|
|
223
|
+
*/
|
|
224
|
+
type RewardTier = {
|
|
225
|
+
minValue: number;
|
|
226
|
+
maxValue?: number;
|
|
227
|
+
amount: TokenAmountType;
|
|
228
|
+
} | {
|
|
229
|
+
minValue: number;
|
|
230
|
+
maxValue?: number;
|
|
231
|
+
percent: number;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Estimated reward amount — discriminated union by payout type
|
|
235
|
+
*
|
|
236
|
+
* - `fixed`: A known token amount (with fiat equivalents)
|
|
237
|
+
* - `percentage`: A percent of a purchase field (e.g. 5% of purchase_amount), with optional min/max caps
|
|
238
|
+
* - `tiered`: Amount depends on a field value matching tier brackets
|
|
239
|
+
*/
|
|
240
|
+
type EstimatedReward = {
|
|
241
|
+
payoutType: "fixed";
|
|
242
|
+
amount: TokenAmountType;
|
|
243
|
+
} | {
|
|
244
|
+
payoutType: "percentage";
|
|
245
|
+
percent: number;
|
|
246
|
+
percentOf: string;
|
|
247
|
+
maxAmount?: TokenAmountType;
|
|
248
|
+
minAmount?: TokenAmountType;
|
|
249
|
+
} | {
|
|
250
|
+
payoutType: "tiered";
|
|
251
|
+
tierField: string;
|
|
252
|
+
tiers: RewardTier[];
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Comparison operators usable in a {@link RuleCondition}.
|
|
256
|
+
* @group RPC Schema
|
|
257
|
+
*/
|
|
258
|
+
type ConditionOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | "exists" | "not_exists" | "between";
|
|
259
|
+
/**
|
|
260
|
+
* Dot-path of the rule-evaluation context field a {@link RuleCondition} targets.
|
|
261
|
+
*
|
|
262
|
+
* Only the paths the SDK actually reads are listed (for editor autocompletion);
|
|
263
|
+
* the trailing `string` member keeps the type open to any other path the backend
|
|
264
|
+
* may emit, so it never lies at runtime. Custom interaction data is addressed
|
|
265
|
+
* through `custom.${string}`.
|
|
266
|
+
* @group RPC Schema
|
|
267
|
+
*/
|
|
268
|
+
type RuleField = "purchase.amount" | "time.timestamp" | "attribution.referrerIdentityGroupId" | `custom.${string}` | (string & Record<never, never>);
|
|
269
|
+
/**
|
|
270
|
+
* A single leaf rule condition. Compares the value found at {@link RuleField}
|
|
271
|
+
* in the evaluation context against `value` (and `valueTo` for `between`).
|
|
272
|
+
* @group RPC Schema
|
|
273
|
+
*/
|
|
274
|
+
type RuleCondition = {
|
|
275
|
+
field: RuleField;
|
|
276
|
+
operator: ConditionOperator;
|
|
277
|
+
value: string | number | boolean | null;
|
|
278
|
+
valueTo?: string | number | boolean | null;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* A recursive group of conditions combined through a boolean `logic`.
|
|
282
|
+
* @group RPC Schema
|
|
283
|
+
*/
|
|
284
|
+
type ConditionGroup = {
|
|
285
|
+
logic: "all" | "any" | "none";
|
|
286
|
+
conditions: (RuleCondition | ConditionGroup)[];
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Campaign gating rules: a flat list of {@link RuleCondition} (implicitly
|
|
290
|
+
* AND-ed) or a nested {@link ConditionGroup} tree. Surfaced raw so integrators
|
|
291
|
+
* can inspect the rules and derive their own display (start date, minimum
|
|
292
|
+
* purchase, …) instead of relying on pre-computed fields.
|
|
293
|
+
* @group RPC Schema
|
|
294
|
+
*/
|
|
295
|
+
type RuleConditions = RuleCondition[] | ConditionGroup;
|
|
296
|
+
/**
|
|
297
|
+
* A reward offer exposed by a merchant campaign.
|
|
298
|
+
*
|
|
299
|
+
* Mirrors the backend `EstimatedRewardItem` one-to-one — a static parity
|
|
300
|
+
* assertion on the backend keeps its runtime-validated schema in lockstep with
|
|
301
|
+
* this published contract.
|
|
302
|
+
* @group RPC Schema
|
|
303
|
+
*/
|
|
304
|
+
type MerchantReward = {
|
|
305
|
+
/** Reward token address; falls back to the merchant token when omitted. */token?: Address; /** Identifier of the campaign rule this reward originates from. */
|
|
306
|
+
campaignId: string; /** Campaign display name. */
|
|
307
|
+
name: string; /** Interaction that triggers the reward. */
|
|
308
|
+
interactionTypeKey: InteractionTypeKey; /** Reward paid to the referrer, when the campaign defines one. */
|
|
309
|
+
referrer?: EstimatedReward; /** Reward paid to the referee, when the campaign defines one. */
|
|
310
|
+
referee?: EstimatedReward; /** Raw gating rules — inspect to derive start date, minimum purchase, … */
|
|
311
|
+
conditions: RuleConditions; /** Seconds a reward stays locked before settlement. */
|
|
312
|
+
defaultLockupSeconds?: number; /** Days before a pending reward expires. */
|
|
313
|
+
pendingRewardExpirationDays?: number; /** Per-user reward cap for this campaign. */
|
|
314
|
+
maxRewardsPerUser?: number; /** Merchant-wide per-user reward cap across every campaign. */
|
|
315
|
+
merchantMaxRewardsPerUser?: number; /** ISO-8601 campaign end date, or `null` when open-ended. */
|
|
316
|
+
expiresAt?: string | null;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Response of the `frak_getMerchantInformation` RPC method
|
|
320
|
+
* @group RPC Schema
|
|
321
|
+
*/
|
|
322
|
+
type GetMerchantInformationReturnType = {
|
|
323
|
+
/**
|
|
324
|
+
* Current merchant id
|
|
325
|
+
*/
|
|
326
|
+
id: string;
|
|
327
|
+
/**
|
|
328
|
+
* Some metadata
|
|
329
|
+
*/
|
|
330
|
+
onChainMetadata: {
|
|
331
|
+
/**
|
|
332
|
+
* Name of the merchant on-chain
|
|
333
|
+
*/
|
|
334
|
+
name: string;
|
|
335
|
+
/**
|
|
336
|
+
* Domain of the merchant on-chain
|
|
337
|
+
*/
|
|
338
|
+
domain: string;
|
|
339
|
+
};
|
|
340
|
+
rewards: MerchantReward[];
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
343
|
+
export { UtmParams as S, LocalizedI18nConfig as _, MerchantReward as a, TrackArrivalParams as b, RuleConditions as c, InteractionTypeKey as d, Currency as f, ListenerPreloadOption as g, Language as h, GetMerchantInformationReturnType as i, RuleField as l, I18nConfig as m, ConditionOperator as n, RewardTier as o, FrakWalletSdkConfig as p, EstimatedReward as r, RuleCondition as s, ConditionGroup as t, TokenAmountType as u, AttributionDefaults as v, TrackArrivalResult as x, AttributionParams as y };
|
|
344
|
+
//# sourceMappingURL=merchantInformation-BSuahpjl.d.cts.map
|
|
@@ -1,202 +1,9 @@
|
|
|
1
|
+
import { d as InteractionTypeKey, f as Currency, h as Language, i as GetMerchantInformationReturnType, m as I18nConfig, p as FrakWalletSdkConfig, v as AttributionDefaults, y as AttributionParams } from "./merchantInformation--tLnowAN.js";
|
|
2
|
+
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
1
3
|
import { OpenPanel } from "@openpanel/web";
|
|
2
4
|
import { Address, Hex } from "viem";
|
|
3
|
-
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
4
5
|
import { SiweMessage } from "viem/siwe";
|
|
5
6
|
|
|
6
|
-
//#region src/types/tracking.d.ts
|
|
7
|
-
type UtmParams = {
|
|
8
|
-
source?: string;
|
|
9
|
-
medium?: string;
|
|
10
|
-
campaign?: string;
|
|
11
|
-
term?: string;
|
|
12
|
-
content?: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Attribution parameters appended to outbound sharing URLs.
|
|
16
|
-
*
|
|
17
|
-
* Defaults are derived from the V2 Frak context when available:
|
|
18
|
-
* - `utmSource`: `"frak"`
|
|
19
|
-
* - `utmMedium`: `"referral"`
|
|
20
|
-
* - `utmCampaign`: merchantId (`context.m`)
|
|
21
|
-
* - `via`: `"frak"`
|
|
22
|
-
* - `ref`: clientId (`context.c`)
|
|
23
|
-
*
|
|
24
|
-
* Fields explicitly set here override the defaults. Existing params on the
|
|
25
|
-
* base URL are preserved (gap-fill policy) to respect merchant-provided UTMs.
|
|
26
|
-
*/
|
|
27
|
-
type AttributionParams = {
|
|
28
|
-
utmSource?: string;
|
|
29
|
-
utmMedium?: string;
|
|
30
|
-
utmCampaign?: string;
|
|
31
|
-
utmContent?: string;
|
|
32
|
-
utmTerm?: string;
|
|
33
|
-
via?: string;
|
|
34
|
-
ref?: string;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Merchant-level attribution defaults.
|
|
38
|
-
*
|
|
39
|
-
* Same shape as {@link AttributionParams} minus `utmContent`, because
|
|
40
|
-
* `utm_content` describes the specific content/creative being shared and is
|
|
41
|
-
* inherently per-call or per-product (never a merchant-wide default).
|
|
42
|
-
*
|
|
43
|
-
* Used as the shape for both:
|
|
44
|
-
* - `FrakWalletSdkConfig.attribution` (SDK-side compile-time defaults)
|
|
45
|
-
* - Backend merchant-config attribution (dashboard-driven defaults)
|
|
46
|
-
*/
|
|
47
|
-
type AttributionDefaults = Omit<AttributionParams, "utmContent">;
|
|
48
|
-
type TrackArrivalParams = {
|
|
49
|
-
/** Sharer wallet address. Accepted in both V1 (legacy) and V2 (authenticated sharer) contexts. */referrerWallet?: Address;
|
|
50
|
-
referrerClientId?: string;
|
|
51
|
-
referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
|
|
52
|
-
referralTimestamp?: number;
|
|
53
|
-
};
|
|
54
|
-
type TrackArrivalResult = {
|
|
55
|
-
success: boolean;
|
|
56
|
-
identityGroupId?: string;
|
|
57
|
-
referralLinkId?: string;
|
|
58
|
-
error?: string;
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/types/config.d.ts
|
|
62
|
-
/**
|
|
63
|
-
* All the currencies available
|
|
64
|
-
* @category Config
|
|
65
|
-
*/
|
|
66
|
-
type Currency = "eur" | "usd" | "gbp";
|
|
67
|
-
/**
|
|
68
|
-
* All the languages available
|
|
69
|
-
* @category Config
|
|
70
|
-
*/
|
|
71
|
-
type Language = "fr" | "en";
|
|
72
|
-
/**
|
|
73
|
-
* Configuration for the Frak Wallet SDK
|
|
74
|
-
* @category Config
|
|
75
|
-
*/
|
|
76
|
-
type FrakWalletSdkConfig = {
|
|
77
|
-
/**
|
|
78
|
-
* The Frak wallet url
|
|
79
|
-
* @defaultValue "https://wallet.frak.id"
|
|
80
|
-
*/
|
|
81
|
-
walletUrl?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Some metadata about your implementation of the Frak SDK
|
|
84
|
-
*/
|
|
85
|
-
metadata: {
|
|
86
|
-
/**
|
|
87
|
-
* Your application name (will be displayed in a few modals and in SSO)
|
|
88
|
-
*/
|
|
89
|
-
name?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Your merchant ID from the Frak dashboard (UUID format)
|
|
92
|
-
* Used for referral tracking and analytics
|
|
93
|
-
* If not provided, will be auto-fetched from the backend using your domain
|
|
94
|
-
*/
|
|
95
|
-
merchantId?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Language to display in the modal
|
|
98
|
-
* If undefined, will default to the browser language
|
|
99
|
-
*/
|
|
100
|
-
lang?: Language;
|
|
101
|
-
/**
|
|
102
|
-
* The currency to display in the modal
|
|
103
|
-
* @defaultValue `"eur"`
|
|
104
|
-
*/
|
|
105
|
-
currency?: Currency;
|
|
106
|
-
/**
|
|
107
|
-
* The logo URL that will be displayed in a few components
|
|
108
|
-
*/
|
|
109
|
-
logoUrl?: string;
|
|
110
|
-
/**
|
|
111
|
-
* The homepage link that could be displayed in a few components
|
|
112
|
-
*/
|
|
113
|
-
homepageLink?: string;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Some customization for the modal
|
|
117
|
-
*/
|
|
118
|
-
customizations?: {
|
|
119
|
-
/**
|
|
120
|
-
* Custom CSS styles to apply to the modals and components
|
|
121
|
-
*/
|
|
122
|
-
css?: `${string}.css`;
|
|
123
|
-
/**
|
|
124
|
-
* Custom i18n configuration for the modal
|
|
125
|
-
*/
|
|
126
|
-
i18n?: I18nConfig;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* The domain name of your application
|
|
130
|
-
* @defaultValue window.location.host
|
|
131
|
-
*/
|
|
132
|
-
domain?: string;
|
|
133
|
-
/**
|
|
134
|
-
* Wait for backend config before rendering components.
|
|
135
|
-
* When true (default), components show a spinner until backend config is resolved.
|
|
136
|
-
* When false, components render immediately with SDK static config / HTML attributes.
|
|
137
|
-
* @defaultValue true
|
|
138
|
-
*/
|
|
139
|
-
waitForBackendConfig?: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Default attribution params (UTM / via / ref) appended to outbound
|
|
142
|
-
* sharing URLs. Per-call `displaySharingPage` overrides win, then backend
|
|
143
|
-
* config, then this SDK-level default. `utm_content` is intentionally
|
|
144
|
-
* excluded — it is per-content/per-product, never a merchant-wide default.
|
|
145
|
-
*/
|
|
146
|
-
attribution?: AttributionDefaults;
|
|
147
|
-
/**
|
|
148
|
-
* Preload specific UI views inside the listener iframe for better UX.
|
|
149
|
-
* Default: ["sharing"]
|
|
150
|
-
*/
|
|
151
|
-
preload?: ListenerPreloadOption[];
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Custom i18n configuration for the modal
|
|
155
|
-
* See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
|
|
156
|
-
*
|
|
157
|
-
* Available variables
|
|
158
|
-
* - `{{ productName }}` : The name of your website (`metadata.name`)
|
|
159
|
-
* - `{{ productOrigin }}` : The origin url of your website
|
|
160
|
-
* - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
|
|
161
|
-
*
|
|
162
|
-
* Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
|
|
163
|
-
* - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
|
|
164
|
-
* - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* ```ts
|
|
168
|
-
* // Multi language config
|
|
169
|
-
* const multiI18n = {
|
|
170
|
-
* fr: {
|
|
171
|
-
* "sdk.modal.title": "Titre de modal",
|
|
172
|
-
* "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
|
|
173
|
-
* },
|
|
174
|
-
* en: "https://example.com/en.json"
|
|
175
|
-
* }
|
|
176
|
-
*
|
|
177
|
-
* // Single language config
|
|
178
|
-
* const singleI18n = {
|
|
179
|
-
* "sdk.modal.title": "Modal title",
|
|
180
|
-
* "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
|
|
181
|
-
* }
|
|
182
|
-
* ```
|
|
183
|
-
*
|
|
184
|
-
* @category Config
|
|
185
|
-
*/
|
|
186
|
-
type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
|
|
187
|
-
/**
|
|
188
|
-
* Options for preloading the listener UI
|
|
189
|
-
* @category Config
|
|
190
|
-
*/
|
|
191
|
-
type ListenerPreloadOption = "modal" | "sharing";
|
|
192
|
-
/**
|
|
193
|
-
* A localized i18n config (inline objects only — URL-based i18n removed)
|
|
194
|
-
* @category Config
|
|
195
|
-
*/
|
|
196
|
-
type LocalizedI18nConfig = {
|
|
197
|
-
[key: string]: string;
|
|
198
|
-
};
|
|
199
|
-
//#endregion
|
|
200
7
|
//#region src/types/resolvedConfig.d.ts
|
|
201
8
|
/**
|
|
202
9
|
* Response from the merchant resolve endpoint
|
|
@@ -404,19 +211,6 @@ type RedirectRequestEvent = {
|
|
|
404
211
|
};
|
|
405
212
|
};
|
|
406
213
|
//#endregion
|
|
407
|
-
//#region src/constants/interactionTypes.d.ts
|
|
408
|
-
/**
|
|
409
|
-
* The supported interaction type keys
|
|
410
|
-
*
|
|
411
|
-
* - `referral` - User arrived via a referral link
|
|
412
|
-
* - `create_referral_link` - User created/shared a referral link
|
|
413
|
-
* - `purchase` - User completed a purchase
|
|
414
|
-
* - `custom.${string}` - Custom interaction type defined per campaign
|
|
415
|
-
*
|
|
416
|
-
* @inline
|
|
417
|
-
*/
|
|
418
|
-
type InteractionTypeKey = "referral" | "create_referral_link" | "purchase" | `custom.${string}`;
|
|
419
|
-
//#endregion
|
|
420
214
|
//#region src/types/rpc/modal/generic.d.ts
|
|
421
215
|
/**
|
|
422
216
|
* Represent a generic modal step type
|
|
@@ -978,76 +772,6 @@ type SendInteractionParamsType = {
|
|
|
978
772
|
idempotencyKey?: string;
|
|
979
773
|
};
|
|
980
774
|
//#endregion
|
|
981
|
-
//#region src/types/rpc/merchantInformation.d.ts
|
|
982
|
-
/**
|
|
983
|
-
* The type for the amount of tokens
|
|
984
|
-
*/
|
|
985
|
-
type TokenAmountType = {
|
|
986
|
-
amount: number;
|
|
987
|
-
eurAmount: number;
|
|
988
|
-
usdAmount: number;
|
|
989
|
-
gbpAmount: number;
|
|
990
|
-
};
|
|
991
|
-
/**
|
|
992
|
-
* A tier definition for tiered rewards
|
|
993
|
-
*/
|
|
994
|
-
type RewardTier = {
|
|
995
|
-
minValue: number;
|
|
996
|
-
maxValue?: number;
|
|
997
|
-
amount: TokenAmountType;
|
|
998
|
-
};
|
|
999
|
-
/**
|
|
1000
|
-
* Estimated reward amount — discriminated union by payout type
|
|
1001
|
-
*
|
|
1002
|
-
* - `fixed`: A known token amount (with fiat equivalents)
|
|
1003
|
-
* - `percentage`: A percent of a purchase field (e.g. 5% of purchase_amount), with optional min/max caps
|
|
1004
|
-
* - `tiered`: Amount depends on a field value matching tier brackets
|
|
1005
|
-
*/
|
|
1006
|
-
type EstimatedReward = {
|
|
1007
|
-
payoutType: "fixed";
|
|
1008
|
-
amount: TokenAmountType;
|
|
1009
|
-
} | {
|
|
1010
|
-
payoutType: "percentage";
|
|
1011
|
-
percent: number;
|
|
1012
|
-
percentOf: string;
|
|
1013
|
-
maxAmount?: TokenAmountType;
|
|
1014
|
-
minAmount?: TokenAmountType;
|
|
1015
|
-
} | {
|
|
1016
|
-
payoutType: "tiered";
|
|
1017
|
-
tierField: string;
|
|
1018
|
-
tiers: RewardTier[];
|
|
1019
|
-
};
|
|
1020
|
-
/**
|
|
1021
|
-
* Response of the `frak_getMerchantInformation` RPC method
|
|
1022
|
-
* @group RPC Schema
|
|
1023
|
-
*/
|
|
1024
|
-
type GetMerchantInformationReturnType = {
|
|
1025
|
-
/**
|
|
1026
|
-
* Current merchant id
|
|
1027
|
-
*/
|
|
1028
|
-
id: string;
|
|
1029
|
-
/**
|
|
1030
|
-
* Some metadata
|
|
1031
|
-
*/
|
|
1032
|
-
onChainMetadata: {
|
|
1033
|
-
/**
|
|
1034
|
-
* Name of the merchant on-chain
|
|
1035
|
-
*/
|
|
1036
|
-
name: string;
|
|
1037
|
-
/**
|
|
1038
|
-
* Domain of the merchant on-chain
|
|
1039
|
-
*/
|
|
1040
|
-
domain: string;
|
|
1041
|
-
};
|
|
1042
|
-
rewards: {
|
|
1043
|
-
token?: Address;
|
|
1044
|
-
campaignId: string;
|
|
1045
|
-
interactionTypeKey: InteractionTypeKey;
|
|
1046
|
-
referrer?: EstimatedReward;
|
|
1047
|
-
referee?: EstimatedReward;
|
|
1048
|
-
}[];
|
|
1049
|
-
};
|
|
1050
|
-
//#endregion
|
|
1051
775
|
//#region src/types/rpc/userReferralStatus.d.ts
|
|
1052
776
|
/**
|
|
1053
777
|
* User referral status returned by `frak_getUserReferralStatus`.
|
|
@@ -1387,4 +1111,5 @@ declare const ssoPopupName = "frak-sso";
|
|
|
1387
1111
|
*/
|
|
1388
1112
|
declare function openSso(client: FrakClient, inputArgs: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1389
1113
|
//#endregion
|
|
1390
|
-
export {
|
|
1114
|
+
export { SendTransactionTxType as A, FinalActionType as B, DisplayModalParamsType as C, ModalStepTypes as D, ModalRpcStepsResultType as E, OpenSsoParamsType as F, MerchantConfigResponse as G, ModalStepMetadata as H, OpenSsoReturnType as I, SdkResolvedConfig as J, ResolvedPlacement as K, PrepareSsoParamsType as L, SiweAuthenticateReturnType as M, SiweAuthenticationParams as N, SendTransactionModalStepType as O, LoginModalStepType as P, PrepareSsoReturnType as R, SharingPageProduct as S, ModalRpcStepsInput as T, IFrameLifecycleEvent as U, FinalModalStepType as V, ClientLifecycleEvent as W, EmbeddedViewActionReferred as _, FrakContextV1 as a, DisplaySharingPageParamsType as b, FrakLifecycleEvent as c, WalletStatusReturnType as d, UserReferralStatusType as f, LoggedOutEmbeddedView as g, DisplayEmbeddedWalletResultType as h, FrakContext as i, SiweAuthenticateModalStepType as j, SendTransactionReturnType as k, IFrameTransport as l, DisplayEmbeddedWalletParamsType as m, ssoPopupFeatures as n, FrakContextV2 as o, SendInteractionParamsType as p, ResolvedSdkConfig as q, ssoPopupName as r, FrakClient as s, openSso as t, IFrameRpcSchema as u, EmbeddedViewActionSharing as v, ModalRpcMetadata as w, DisplaySharingPageResultType as x, LoggedInEmbeddedView as y, SsoMetadata as z };
|
|
1115
|
+
//# sourceMappingURL=openSso-CENLMWJx.d.ts.map
|