@frak-labs/core-sdk 1.0.2-beta.9985efe7 → 1.0.2-beta.9d4f564a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +0 -1
  2. package/package.json +4 -4
  3. package/src/actions/ensureIdentity.ts +3 -3
  4. package/src/actions/openSso.ts +4 -4
  5. package/src/actions/referral/processReferral.test.ts +38 -22
  6. package/src/actions/referral/processReferral.ts +6 -4
  7. package/src/actions/referral/referralInteraction.test.ts +7 -7
  8. package/src/actions/referral/referralInteraction.ts +1 -1
  9. package/src/actions/sendInteraction.ts +1 -1
  10. package/src/actions/trackPurchaseStatus.test.ts +4 -4
  11. package/src/actions/trackPurchaseStatus.ts +3 -3
  12. package/src/actions/wrapper/siweAuthenticate.test.ts +1 -5
  13. package/src/actions/wrapper/siweAuthenticate.ts +25 -1
  14. package/src/clients/createIFrameFrakClient.ts +5 -21
  15. package/src/clients/index.ts +0 -1
  16. package/src/clients/transports/iframeLifecycleManager.test.ts +10 -10
  17. package/src/clients/transports/iframeLifecycleManager.ts +3 -3
  18. package/src/config/index.ts +3 -0
  19. package/src/{utils → config}/sdkConfigStore.ts +1 -1
  20. package/src/{utils/constants.test.ts → constants.test.ts} +1 -6
  21. package/src/constants.ts +15 -0
  22. package/src/context/address.ts +76 -0
  23. package/src/{utils/FrakContext.test.ts → context/frakContext.test.ts} +4 -2
  24. package/src/{utils/FrakContext.ts → context/frakContext.ts} +4 -4
  25. package/src/{utils → context}/frakContextV2Codec.test.ts +1 -1
  26. package/src/{utils → context}/frakContextV2Codec.ts +6 -6
  27. package/src/context/index.ts +6 -0
  28. package/src/index.ts +16 -22
  29. package/src/stubs/rrweb.ts +8 -4
  30. package/src/types/client.ts +0 -3
  31. package/src/utils/{deepLinkWithFallback.ts → browser/deepLinkWithFallback.ts} +10 -5
  32. package/src/utils/{inAppBrowser.ts → browser/inAppBrowser.ts} +13 -0
  33. package/src/utils/browser/index.ts +13 -0
  34. package/src/utils/{formatAmount.test.ts → format/formatAmount.test.ts} +1 -1
  35. package/src/utils/{formatAmount.ts → format/formatAmount.ts} +1 -1
  36. package/src/utils/{getCurrencyAmountKey.test.ts → format/getCurrencyAmountKey.test.ts} +2 -2
  37. package/src/utils/{getCurrencyAmountKey.ts → format/getCurrencyAmountKey.ts} +1 -1
  38. package/src/utils/{getSupportedCurrency.test.ts → format/getSupportedCurrency.test.ts} +2 -2
  39. package/src/utils/{getSupportedCurrency.ts → format/getSupportedCurrency.ts} +2 -2
  40. package/src/utils/{getSupportedLocale.test.ts → format/getSupportedLocale.test.ts} +3 -3
  41. package/src/utils/{getSupportedLocale.ts → format/getSupportedLocale.ts} +2 -2
  42. package/src/utils/format/index.ts +4 -0
  43. package/src/utils/{iframeHelper.test.ts → iframe/iframeHelper.test.ts} +3 -3
  44. package/src/utils/{iframeHelper.ts → iframe/iframeHelper.ts} +3 -3
  45. package/src/utils/iframe/index.ts +6 -0
  46. package/src/utils/index.ts +31 -24
  47. package/src/utils/sso/index.ts +6 -0
  48. package/src/utils/{sso.ts → sso/sso.ts} +2 -2
  49. package/cdn/bundle.js +0 -14
  50. package/dist/actions-DihYM-OG.js +0 -1
  51. package/dist/actions-cYbmqewX.cjs +0 -1
  52. package/dist/actions.cjs +0 -1
  53. package/dist/actions.d.cts +0 -3
  54. package/dist/actions.d.ts +0 -3
  55. package/dist/actions.js +0 -1
  56. package/dist/bundle.cjs +0 -1
  57. package/dist/bundle.d.cts +0 -4
  58. package/dist/bundle.d.ts +0 -4
  59. package/dist/bundle.js +0 -1
  60. package/dist/index-BsBbSMxk.d.cts +0 -646
  61. package/dist/index-DzVPSUQq.d.ts +0 -716
  62. package/dist/index-quaxtKRh.d.ts +0 -646
  63. package/dist/index-s1vE3jLz.d.cts +0 -716
  64. package/dist/index.cjs +0 -1
  65. package/dist/index.d.cts +0 -3
  66. package/dist/index.d.ts +0 -3
  67. package/dist/index.js +0 -1
  68. package/dist/openSso-DyUQew2K.d.ts +0 -1392
  69. package/dist/openSso-rQhLhPbq.d.cts +0 -1392
  70. package/dist/sdkConfigStore-BXzz5PlK.js +0 -1
  71. package/dist/sdkConfigStore-DDL_fjYX.cjs +0 -1
  72. package/dist/src-BfqUdz3x.js +0 -13
  73. package/dist/src-x06nhpns.cjs +0 -13
  74. package/src/clients/DebugInfo.test.ts +0 -418
  75. package/src/clients/DebugInfo.ts +0 -182
  76. package/src/utils/computeLegacyProductId.ts +0 -11
  77. package/src/utils/constants.ts +0 -9
  78. /package/src/{utils → clients}/ssoUrlListener.test.ts +0 -0
  79. /package/src/{utils → clients}/ssoUrlListener.ts +0 -0
  80. /package/src/{utils → config}/backendUrl.test.ts +0 -0
  81. /package/src/{utils → config}/backendUrl.ts +0 -0
  82. /package/src/{utils → config}/clientId.test.ts +0 -0
  83. /package/src/{utils → config}/clientId.ts +0 -0
  84. /package/src/{utils → config}/sdkConfigStore.test.ts +0 -0
  85. /package/src/{utils → context}/mergeAttribution.test.ts +0 -0
  86. /package/src/{utils → context}/mergeAttribution.ts +0 -0
  87. /package/src/utils/{deepLinkWithFallback.test.ts → browser/deepLinkWithFallback.test.ts} +0 -0
@@ -1,716 +0,0 @@
1
- import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, ct as AttributionParams, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, st as AttributionDefaults, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-DyUQew2K.js";
2
- import { Hex } from "viem";
3
- import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
4
-
5
- //#region src/types/compression.d.ts
6
- /**
7
- * The received encoded data from a client
8
- * -> The encoded should contain a HashProtectedData once decoded
9
- * @ignore
10
- */
11
- type CompressedData = Uint8Array;
12
- /**
13
- * The encoded data to send to a client / received by a client
14
- * @ignore
15
- */
16
- type HashProtectedData<DataType> = Readonly<DataType & {
17
- validationHash: string;
18
- }>;
19
- /**
20
- * Represent a key provider used for the hashed and secure compression
21
- * @ignore
22
- */
23
- type KeyProvider<DataType> = (value: DataType) => string[];
24
- //#endregion
25
- //#region src/clients/createIFrameFrakClient.d.ts
26
- /**
27
- * Create a new iframe Frak client
28
- * @param args
29
- * @param args.config - The configuration to use for the Frak Wallet SDK.
30
- * When `config.domain` is set, it is used to resolve the correct merchant config in tunneled/proxied environments (e.g. Shopify dev with Cloudflare tunnel).
31
- * @param args.iframe - The iframe to use for the communication
32
- * @returns The created Frak Client
33
- *
34
- * @example
35
- * const frakConfig: FrakWalletSdkConfig = {
36
- * metadata: {
37
- * name: "My app title",
38
- * },
39
- * }
40
- * const iframe = await createIframe({ config: frakConfig });
41
- * const client = createIFrameFrakClient({ config: frakConfig, iframe });
42
- */
43
- declare function createIFrameFrakClient({
44
- config,
45
- iframe
46
- }: {
47
- config: FrakWalletSdkConfig;
48
- iframe: HTMLIFrameElement;
49
- }): FrakClient;
50
- //#endregion
51
- //#region src/clients/DebugInfo.d.ts
52
- /** @ignore */
53
- declare class DebugInfoGatherer {
54
- private config?;
55
- private iframe?;
56
- private isSetupDone;
57
- private lastResponse;
58
- private lastRequest;
59
- constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
60
- setLastResponse(message: RpcMessage, response: RpcResponse): void;
61
- setLastRequest(event: RpcMessage): void;
62
- updateSetupStatus(status: boolean): void;
63
- private base64Encode;
64
- /**
65
- * Extract information from the iframe status
66
- */
67
- private getIframeStatus;
68
- private getNavigatorInfo;
69
- private gatherDebugInfo;
70
- static empty(): DebugInfoGatherer;
71
- /**
72
- * Format Frak debug information
73
- */
74
- formatDebugInfo(error: Error | unknown | string): string;
75
- }
76
- //#endregion
77
- //#region src/clients/setupClient.d.ts
78
- /**
79
- * Directly setup the Frak client with an iframe
80
- * Return when the FrakClient is ready (setup and communication estbalished with the wallet)
81
- *
82
- * @param config - The configuration to use for the Frak Wallet SDK
83
- * @returns a Promise with the Frak Client
84
- *
85
- * @example
86
- * const frakConfig: FrakWalletSdkConfig = {
87
- * metadata: {
88
- * name: "My app title",
89
- * },
90
- * }
91
- * const client = await setupClient({ config: frakConfig });
92
- */
93
- declare function setupClient({
94
- config
95
- }: {
96
- config: FrakWalletSdkConfig;
97
- }): Promise<FrakClient | undefined>;
98
- //#endregion
99
- //#region src/constants/locales.d.ts
100
- /**
101
- * The keys for each locales
102
- * @inline
103
- */
104
- type LocalesKey = keyof typeof locales;
105
- /**
106
- * Map the currency to the locale
107
- */
108
- declare const locales: {
109
- readonly eur: "fr-FR";
110
- readonly usd: "en-US";
111
- readonly gbp: "en-GB";
112
- };
113
- //#endregion
114
- //#region src/utils/analytics/events/component.d.ts
115
- type ButtonBaseProps = {
116
- placement?: string;
117
- target_interaction?: string;
118
- has_reward?: boolean;
119
- };
120
- type BannerVariant = "referral" | "inapp";
121
- type BannerOutcome = "clicked" | "dismissed";
122
- type PostPurchaseVariant = "referrer" | "referee";
123
- type ShareClickAction = "share-modal" | "embedded-wallet" | "sharing-page";
124
- type SdkComponentEventMap = {
125
- share_button_clicked: ButtonBaseProps & {
126
- click_action: ShareClickAction;
127
- };
128
- share_modal_error: ButtonBaseProps & {
129
- error?: string;
130
- };
131
- open_in_app_clicked: {
132
- placement?: string;
133
- path: string;
134
- };
135
- app_not_installed: {
136
- placement?: string;
137
- path: string;
138
- };
139
- banner_impression: {
140
- placement?: string;
141
- variant: BannerVariant;
142
- has_reward?: boolean;
143
- };
144
- banner_resolved: {
145
- placement?: string;
146
- variant: BannerVariant;
147
- outcome: BannerOutcome;
148
- };
149
- post_purchase_impression: {
150
- placement?: string;
151
- variant: PostPurchaseVariant;
152
- has_reward?: boolean;
153
- };
154
- post_purchase_clicked: {
155
- placement?: string;
156
- variant: PostPurchaseVariant;
157
- };
158
- };
159
- //#endregion
160
- //#region src/utils/analytics/events/lifecycle.d.ts
161
- type SdkHandshakeFailureReason = "timeout" | "origin" | "asset_push" | "unknown";
162
- type SdkLifecycleEventMap = {
163
- sdk_initialized: {
164
- sdkVersion?: string;
165
- };
166
- sdk_iframe_connected: {
167
- handshake_duration_ms: number;
168
- };
169
- sdk_iframe_handshake_failed: {
170
- reason: SdkHandshakeFailureReason;
171
- };
172
- /**
173
- * Emitted by the CDN bootstrap when `initFrakSdk()` throws before a
174
- * client is available. Uses a transient OpenPanel instance so broken
175
- * partner integrations are still captured.
176
- */
177
- sdk_init_failed: {
178
- reason: string;
179
- config_missing?: boolean;
180
- };
181
- };
182
- //#endregion
183
- //#region src/utils/analytics/events/referral.d.ts
184
- type SdkReferralEventMap = {
185
- user_referred_started: {
186
- referrer?: string;
187
- referrerClientId?: string;
188
- referrerWallet?: string;
189
- walletStatus?: string;
190
- };
191
- user_referred_completed: {
192
- status: "success";
193
- };
194
- };
195
- //#endregion
196
- //#region src/utils/analytics/events/index.d.ts
197
- /**
198
- * Merged SDK event map. Consumed by the SDK's typed `trackEvent`.
199
- * Stays isolated from wallet-shared because the SDK ships in partner
200
- * bundles (different OpenPanel client id, no wallet-shared dependency
201
- * allowed — see `packages/wallet-shared/AGENTS.md`).
202
- */
203
- type SdkEventMap = SdkLifecycleEventMap & SdkComponentEventMap & SdkReferralEventMap;
204
- //#endregion
205
- //#region src/utils/analytics/trackEvent.d.ts
206
- /**
207
- * Track an analytics event via the SDK's OpenPanel instance.
208
- * Fire-and-forget — silently catches errors so analytics never break a
209
- * partner integration.
210
- *
211
- * The client must be passed explicitly because the OpenPanel instance is
212
- * scoped to each `FrakClient` (a partner site may hold multiple iframes).
213
- *
214
- * @param client - The Frak client instance (no-op if undefined)
215
- * @param event - Typed event name from the SDK event map
216
- * @param properties - Typed properties for the given event
217
- */
218
- declare function trackEvent<K extends keyof SdkEventMap>(client: FrakClient | undefined, event: K, properties?: SdkEventMap[K]): void;
219
- //#endregion
220
- //#region src/utils/backendUrl.d.ts
221
- /**
222
- * Get the backend URL for API calls
223
- * Tries to derive from SDK config, falls back to production
224
- *
225
- * @param walletUrl - Optional wallet URL to derive from (overrides global config)
226
- */
227
- declare function getBackendUrl(walletUrl?: string): string;
228
- //#endregion
229
- //#region src/utils/cache/withCache.d.ts
230
- type WithCacheOptions = {
231
- /** The key to cache the data against */cacheKey: string; /** Time in ms that cached data will remain valid. Default: 30_000 (30s). Set to 0 to disable caching. */
232
- cacheTime?: number;
233
- };
234
- /**
235
- * Returns the result of a given promise, and caches the result for
236
- * subsequent invocations against a provided cache key.
237
- *
238
- * Also deduplicates concurrent calls — if multiple callers request the same
239
- * cache key while the promise is pending, they share the same promise.
240
- *
241
- * @example
242
- * ```ts
243
- * // First call fetches, subsequent calls return cached data for 30s
244
- * const data = await withCache(
245
- * () => client.request({ method: "frak_getMerchantInformation" }),
246
- * { cacheKey: "merchantInfo", cacheTime: 30_000 }
247
- * );
248
- * ```
249
- */
250
- declare function withCache<TData>(fn: () => Promise<TData>, {
251
- cacheKey,
252
- cacheTime
253
- }: WithCacheOptions): Promise<TData>;
254
- /**
255
- * Get a cache handle for a specific key, useful for manual invalidation.
256
- *
257
- * @example
258
- * ```ts
259
- * // Invalidate merchant info cache after a mutation
260
- * getCache("frak_getMerchantInformation").clear();
261
- * ```
262
- */
263
- declare function getCache(cacheKey: string): {
264
- /** Clear both the pending promise and the cached response */clear: () => void; /** Check if a non-expired response exists */
265
- has: (cacheTime?: number) => boolean;
266
- };
267
- /**
268
- * Clear all cached data (both pending promises and resolved responses).
269
- * Called automatically when the client is destroyed.
270
- */
271
- declare function clearAllCache(): void;
272
- //#endregion
273
- //#region src/utils/clientId.d.ts
274
- /**
275
- * Client ID utilities for anonymous tracking
276
- * Generates and persists a UUID fingerprint for referral attribution
277
- */
278
- /**
279
- * Get the client ID from localStorage, creating one if it doesn't exist
280
- * @returns The client ID (UUID format)
281
- */
282
- declare function getClientId(): string;
283
- //#endregion
284
- //#region src/utils/compression/b64.d.ts
285
- /**
286
- * Encode a buffer to a base64url encoded string
287
- * @param buffer The buffer to encode
288
- * @returns The encoded string
289
- */
290
- declare function base64urlEncode(buffer: Uint8Array): string;
291
- /**
292
- * Decode a base64url encoded string
293
- * @param value The value to decode
294
- * @returns The decoded value
295
- */
296
- declare function base64urlDecode(value: string): Uint8Array;
297
- //#endregion
298
- //#region src/utils/compression/compress.d.ts
299
- /**
300
- * Compress json data
301
- * @param data
302
- * @ignore
303
- */
304
- declare function compressJsonToB64(data: unknown): string;
305
- //#endregion
306
- //#region src/utils/compression/decompress.d.ts
307
- /**
308
- * Decompress json data
309
- * @param data
310
- * @ignore
311
- */
312
- declare function decompressJsonFromB64<T>(data: string): T | null;
313
- //#endregion
314
- //#region src/utils/constants.d.ts
315
- /**
316
- * Deep link scheme for Frak Wallet mobile app
317
- */
318
- declare const DEEP_LINK_SCHEME = "frakwallet://";
319
- //#endregion
320
- //#region src/utils/deepLinkWithFallback.d.ts
321
- /**
322
- * Options for deep link with fallback
323
- */
324
- type DeepLinkFallbackOptions = {
325
- /** Timeout in ms before triggering fallback (default: 2500ms) */timeout?: number; /** Callback invoked when fallback is triggered (app not installed) */
326
- onFallback?: () => void;
327
- };
328
- /**
329
- * Check if running on a Chromium-based Android browser.
330
- *
331
- * On Chrome Android, custom scheme deep links (e.g. frakwallet://) trigger
332
- * a confirmation bar ("Continue to Frak Wallet?"). Using intent:// URLs
333
- * instead bypasses this for Chromium browsers while keeping custom scheme
334
- * fallback for non-Chromium browsers (e.g. Firefox) where it works fine.
335
- */
336
- declare function isChromiumAndroid(): boolean;
337
- /**
338
- * Convert a frakwallet:// deep link to an Android intent:// URL.
339
- *
340
- * Intent URLs let Chromium browsers open the app directly without
341
- * showing the "Continue to app?" confirmation bar.
342
- *
343
- * Note: We intentionally omit the `package` parameter. Including it
344
- * causes Chrome to redirect to the Play Store when the app is not
345
- * installed, which breaks the visibility-based fallback detection.
346
- * Without `package`, Chrome simply does nothing when the app is
347
- * missing, allowing the fallback mechanism to fire correctly.
348
- *
349
- * Format: intent://path#Intent;scheme=frakwallet;end
350
- */
351
- declare function toAndroidIntentUrl(deepLink: string): string;
352
- /**
353
- * Trigger a deep link with visibility-based fallback detection.
354
- *
355
- * Uses the Page Visibility API to detect if the app opened (page goes hidden).
356
- * If the page remains visible after the timeout, assumes app is not installed
357
- * and invokes the onFallback callback.
358
- *
359
- * On Chromium Android, converts custom scheme to intent:// URL to avoid
360
- * the "Continue to app?" confirmation bar.
361
- *
362
- * @param deepLink - The deep link URL to trigger (e.g., "frakwallet://wallet")
363
- * @param options - Optional configuration (timeout, onFallback callback)
364
- */
365
- declare function triggerDeepLinkWithFallback(deepLink: string, options?: DeepLinkFallbackOptions): void;
366
- /**
367
- * Check if a URL is a Frak deep link
368
- */
369
- declare function isFrakDeepLink(url: string): boolean;
370
- //#endregion
371
- //#region src/utils/FrakContext.d.ts
372
- /**
373
- * Compress a Frak context into a URL-safe string.
374
- *
375
- * - V2 contexts are encoded using a compact binary layout (see
376
- * {@link encodeFrakContextV2}) then base64url-encoded.
377
- * - V1 contexts encode the wallet address as raw bytes (base64url).
378
- *
379
- * @param context - The context to compress (V1 or V2)
380
- * @returns A compressed base64url string, or undefined on failure
381
- */
382
- declare function compress(context?: FrakContextV1 | FrakContextV2): string | undefined;
383
- /**
384
- * Decompress a base64url string back into a Frak context.
385
- *
386
- * V1 (exactly 20 bytes) and V2 (37, 41, or 57 bytes) are distinguished by
387
- * their decoded byte length, so there is no ambiguity.
388
- *
389
- * @param context - The compressed context string
390
- * @returns The decompressed FrakContext, or undefined on failure
391
- */
392
- declare function decompress(context?: string): FrakContext | undefined;
393
- /**
394
- * Parse a URL to extract the Frak referral context from the `fCtx` query parameter.
395
- *
396
- * @param args
397
- * @param args.url - The URL to parse
398
- * @returns The parsed FrakContext, or null if absent
399
- */
400
- declare function parse({
401
- url
402
- }: {
403
- url: string;
404
- }): FrakContext | null | undefined;
405
- /**
406
- * Add or replace the `fCtx` query parameter in a URL with the given context.
407
- *
408
- * Standard affiliation params (`utm_source`, `utm_medium`, `utm_campaign`,
409
- * `ref`, `via`, ...) are always appended using gap-fill semantics: pre-existing
410
- * params on the URL are preserved, defaults are derived from the context when
411
- * applicable, and `attribution` overrides take precedence when provided.
412
- *
413
- * @param args
414
- * @param args.url - The URL to update
415
- * @param args.context - The context to embed (V1 or V2)
416
- * @param args.attribution - Optional attribution overrides. Defaults are applied even when omitted.
417
- * @returns The updated URL string, or null on failure
418
- */
419
- declare function update({
420
- url,
421
- context,
422
- attribution
423
- }: {
424
- url?: string;
425
- context: FrakContextV1 | FrakContextV2;
426
- attribution?: AttributionParams;
427
- }): string | null;
428
- /**
429
- * Remove the `fCtx` query parameter from a URL.
430
- *
431
- * @param url - The URL to strip the context from
432
- * @returns The cleaned URL string
433
- */
434
- declare function remove(url: string): string;
435
- /**
436
- * Replace the current browser URL with an updated Frak context.
437
- *
438
- * - If `context` is non-null, embeds it via {@link update}.
439
- * - If `context` is null, strips the context via {@link remove}.
440
- *
441
- * @param args
442
- * @param args.url - Base URL (defaults to `window.location.href`)
443
- * @param args.context - Context to set, or null to remove
444
- */
445
- declare function replaceUrl({
446
- url: baseUrl,
447
- context
448
- }: {
449
- url?: string;
450
- context: FrakContextV1 | FrakContextV2 | null;
451
- }): void;
452
- /**
453
- * Manager for Frak referral context in URLs.
454
- *
455
- * Handles compression, decompression, URL parsing, and browser history updates
456
- * for both V1 (wallet address) and V2 (anonymous clientId) referral contexts.
457
- */
458
- declare const FrakContextManager: {
459
- compress: typeof compress;
460
- decompress: typeof decompress;
461
- parse: typeof parse;
462
- update: typeof update;
463
- remove: typeof remove;
464
- replaceUrl: typeof replaceUrl;
465
- };
466
- //#endregion
467
- //#region src/utils/formatAmount.d.ts
468
- /**
469
- * Format a numeric amount as a localized currency string
470
- * @param amount - The raw numeric amount to format
471
- * @param currency - Optional currency config; defaults to EUR/fr-FR when omitted
472
- * @returns Localized currency string (e.g. "1 500 €", "$1,500")
473
- */
474
- declare function formatAmount(amount: number, currency?: Currency): string;
475
- //#endregion
476
- //#region src/utils/getCurrencyAmountKey.d.ts
477
- /**
478
- * Get the currency amount key for a given currency
479
- * @param currency - The currency to use
480
- * @returns The currency amount key
481
- */
482
- declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
483
- //#endregion
484
- //#region src/utils/getSupportedCurrency.d.ts
485
- /**
486
- * Get the supported currency for a given currency
487
- * @param currency - The currency to use
488
- * @returns The supported currency
489
- */
490
- declare function getSupportedCurrency(currency?: Currency): Currency;
491
- //#endregion
492
- //#region src/utils/getSupportedLocale.d.ts
493
- /**
494
- * Get the supported locale for a given currency
495
- * @param currency - The currency to use
496
- * @returns The supported locale
497
- */
498
- declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
499
- //#endregion
500
- //#region src/utils/iframeHelper.d.ts
501
- /**
502
- * Base props for the iframe
503
- * @ignore
504
- */
505
- declare const baseIframeProps: {
506
- id: string;
507
- name: string;
508
- title: string;
509
- allow: string;
510
- style: {
511
- width: string;
512
- height: string;
513
- border: string;
514
- position: string;
515
- zIndex: number;
516
- top: string;
517
- left: string;
518
- colorScheme: string;
519
- };
520
- };
521
- /**
522
- * Create the Frak iframe
523
- * @param args
524
- * @param args.walletBaseUrl - Use `config.walletUrl` instead. Will be removed in future versions.
525
- * @param args.config - The configuration object containing iframe options, including the replacement for `walletBaseUrl`.
526
- */
527
- declare function createIframe({
528
- walletBaseUrl,
529
- config
530
- }: {
531
- walletBaseUrl?: string;
532
- config?: FrakWalletSdkConfig;
533
- }): Promise<HTMLIFrameElement | undefined>;
534
- /**
535
- * Find an iframe within window.opener by pathname
536
- *
537
- * When a popup is opened via window.open from an iframe, window.opener points to
538
- * the parent window, not the iframe itself. This utility searches through all frames
539
- * in window.opener to find an iframe matching the specified pathname.
540
- *
541
- * @param pathname - The pathname to search for (default: "/listener")
542
- * @returns The matching iframe window, or null if not found
543
- *
544
- * @example
545
- * ```typescript
546
- * // Find the default /listener iframe
547
- * const listenerIframe = findIframeInOpener();
548
- *
549
- * // Find a custom iframe
550
- * const customIframe = findIframeInOpener("/my-custom-iframe");
551
- * ```
552
- */
553
- declare function findIframeInOpener(pathname?: string): Window | null;
554
- //#endregion
555
- //#region src/utils/inAppBrowser.d.ts
556
- /**
557
- * Whether the current device runs iOS (including iPadOS 13+).
558
- */
559
- declare const isIOS: boolean;
560
- /**
561
- * Whether the current browser is a social media in-app browser
562
- * (Instagram, Facebook).
563
- */
564
- declare const isInAppBrowser: boolean;
565
- /**
566
- * Redirect to external browser from in-app WebView.
567
- *
568
- * - **iOS**: Uses `x-safari-https://` scheme — server-side 302 redirects
569
- * to custom URL schemes are silently swallowed by WKWebView.
570
- * Direct `window.location.href` assignment works (confirmed iOS 17+).
571
- *
572
- * - **Android**: Uses backend `/common/social` endpoint which returns a PDF
573
- * Content-Type response, forcing the WebView to hand off to the default browser.
574
- *
575
- * @param targetUrl - The URL to open in the external browser
576
- */
577
- declare function redirectToExternalBrowser(targetUrl: string): void;
578
- //#endregion
579
- //#region src/utils/mergeAttribution.d.ts
580
- /**
581
- * Inputs for {@link mergeAttribution}.
582
- */
583
- type MergeAttributionInput = {
584
- /**
585
- * Per-call attribution override passed to actions like `displaySharingPage`.
586
- *
587
- * - `null` explicitly disables attribution (no UTM/ref/via params are added).
588
- * - `undefined` means "no per-call override" — defaults apply if present.
589
- * - An object (including `{}`) merges field-by-field with defaults.
590
- */
591
- perCall: AttributionParams | null | undefined;
592
- /**
593
- * Pre-merged merchant-level defaults (backend config > SDK static config).
594
- * `utm_content` is intentionally absent from this shape.
595
- */
596
- defaults?: AttributionDefaults;
597
- /**
598
- * Per-product `utm_content` override (from the currently selected
599
- * `SharingPageProduct`). Takes precedence over `perCall.utmContent`.
600
- */
601
- productUtmContent?: string;
602
- };
603
- /**
604
- * Merge the three attribution layers into a single {@link AttributionParams}
605
- * value suitable for `FrakContextManager.update`.
606
- *
607
- * Priority per field:
608
- * 1. `perCall` (wins)
609
- * 2. `defaults` (merchant-level, backend > SDK static, already pre-merged)
610
- * 3. Hardcoded fallbacks resolved later by `FrakContextManager`
611
- *
612
- * Special rules:
613
- * - `perCall === null` returns `undefined` (explicit disable: no UTM/ref/via).
614
- * - `perCall === undefined` (no opinion) yields at least `{}` so `FrakContextManager`
615
- * applies its hardcoded defaults (utm_source=frak, utm_medium=referral,
616
- * utm_campaign=<merchantId>, ref=<clientId>, via=frak).
617
- * - `utm_content` never comes from `defaults`; only `productUtmContent` or
618
- * `perCall.utmContent` can populate it.
619
- */
620
- declare function mergeAttribution({
621
- perCall,
622
- defaults,
623
- productUtmContent
624
- }: MergeAttributionInput): AttributionParams | undefined;
625
- //#endregion
626
- //#region src/utils/sdkConfigStore.d.ts
627
- declare const GLOBAL_KEY = "__frakSdkConfig";
628
- declare global {
629
- interface Window {
630
- [GLOBAL_KEY]?: SdkResolvedConfig;
631
- }
632
- interface WindowEventMap {
633
- "frak:config": CustomEvent<SdkResolvedConfig>;
634
- }
635
- }
636
- declare function getConfig(): SdkResolvedConfig;
637
- declare const sdkConfigStore: {
638
- getConfig: typeof getConfig;
639
- readonly isResolved: boolean;
640
- readonly isCacheFresh: boolean;
641
- setCacheScope(domain: string, lang?: string): void;
642
- setConfig(config: SdkResolvedConfig): void;
643
- reset(): void;
644
- clearCache(): void;
645
- resolve(domain?: string, walletUrl?: string, lang?: Language): Promise<MerchantConfigResponse | undefined>;
646
- getMerchantId(): string | undefined;
647
- resolveMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
648
- };
649
- //#endregion
650
- //#region src/utils/sso.d.ts
651
- type AppSpecificSsoMetadata = SsoMetadata & {
652
- name?: string;
653
- css?: string;
654
- };
655
- /**
656
- * The full SSO params that will be used for compression
657
- */
658
- type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
659
- metadata: AppSpecificSsoMetadata;
660
- merchantId: string;
661
- clientId: string;
662
- };
663
- /**
664
- * Generate SSO URL with compressed parameters
665
- * This mirrors the wallet's getOpenSsoLink() function
666
- *
667
- * @param walletUrl - Base wallet URL (e.g., "https://wallet.frak.id")
668
- * @param params - SSO parameters
669
- * @param merchantId - Merchant identifier
670
- * @param name - Application name
671
- * @param clientId - Client identifier for identity tracking
672
- * @param css - Optional custom CSS
673
- * @returns Complete SSO URL ready to open in popup or redirect
674
- *
675
- * @example
676
- * ```ts
677
- * const ssoUrl = generateSsoUrl(
678
- * "https://wallet.frak.id",
679
- * { metadata: { logoUrl: "..." }, directExit: true },
680
- * "0x123...",
681
- * "My App"
682
- * );
683
- * // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
684
- * ```
685
- */
686
- declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string | undefined, clientId: string, css?: string): string;
687
- /**
688
- * Type of compressed the sso data
689
- */
690
- type CompressedSsoData = {
691
- id?: Hex;
692
- cId: string;
693
- r?: string;
694
- d?: boolean;
695
- l?: "en" | "fr";
696
- m: string;
697
- md: {
698
- n?: string;
699
- css?: string;
700
- l?: string;
701
- h?: string;
702
- };
703
- };
704
- //#endregion
705
- //#region src/utils/computeLegacyProductId.d.ts
706
- /**
707
- * Compute the legacy product id from a domain
708
- * @ignore
709
- */
710
- declare function computeLegacyProductId({
711
- domain
712
- }?: {
713
- domain?: string;
714
- }): `0x${string}`;
715
- //#endregion
716
- export { getClientId as A, setupClient as B, toAndroidIntentUrl as C, compressJsonToB64 as D, decompressJsonFromB64 as E, trackEvent as F, KeyProvider as G, createIFrameFrakClient as H, SdkEventMap as I, SdkHandshakeFailureReason as L, getCache as M, withCache as N, base64urlDecode as O, getBackendUrl as P, LocalesKey as R, isFrakDeepLink as S, DEEP_LINK_SCHEME as T, CompressedData as U, DebugInfoGatherer as V, HashProtectedData as W, getCurrencyAmountKey as _, generateSsoUrl as a, DeepLinkFallbackOptions as b, mergeAttribution as c, redirectToExternalBrowser as d, baseIframeProps as f, getSupportedCurrency as g, getSupportedLocale as h, FullSsoParams as i, clearAllCache as j, base64urlEncode as k, isIOS as l, findIframeInOpener as m, AppSpecificSsoMetadata as n, sdkConfigStore as o, createIframe as p, CompressedSsoData as r, MergeAttributionInput as s, computeLegacyProductId as t, isInAppBrowser as u, formatAmount as v, triggerDeepLinkWithFallback as w, isChromiumAndroid as x, FrakContextManager as y, locales as z };