@frak-labs/core-sdk 1.0.2-beta.64c76510 → 1.0.2-beta.75bb63ae

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 (88) 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/context/address.ts +76 -0
  22. package/src/{utils/FrakContext.test.ts → context/frakContext.test.ts} +4 -2
  23. package/src/{utils/FrakContext.ts → context/frakContext.ts} +4 -4
  24. package/src/{utils → context}/frakContextV2Codec.test.ts +1 -1
  25. package/src/{utils → context}/frakContextV2Codec.ts +6 -6
  26. package/src/context/index.ts +6 -0
  27. package/src/index.ts +17 -22
  28. package/src/stubs/rrweb.ts +8 -4
  29. package/src/types/client.ts +0 -3
  30. package/src/types/config.ts +11 -0
  31. package/src/types/index.ts +1 -0
  32. package/src/utils/{deepLinkWithFallback.ts → browser/deepLinkWithFallback.ts} +1 -1
  33. package/src/utils/{inAppBrowser.ts → browser/inAppBrowser.ts} +13 -0
  34. package/src/utils/browser/index.ts +13 -0
  35. package/src/utils/{formatAmount.test.ts → format/formatAmount.test.ts} +1 -1
  36. package/src/utils/{formatAmount.ts → format/formatAmount.ts} +1 -1
  37. package/src/utils/{getCurrencyAmountKey.test.ts → format/getCurrencyAmountKey.test.ts} +2 -2
  38. package/src/utils/{getCurrencyAmountKey.ts → format/getCurrencyAmountKey.ts} +1 -1
  39. package/src/utils/{getSupportedCurrency.test.ts → format/getSupportedCurrency.test.ts} +2 -2
  40. package/src/utils/{getSupportedCurrency.ts → format/getSupportedCurrency.ts} +2 -2
  41. package/src/utils/{getSupportedLocale.test.ts → format/getSupportedLocale.test.ts} +3 -3
  42. package/src/utils/{getSupportedLocale.ts → format/getSupportedLocale.ts} +2 -2
  43. package/src/utils/format/index.ts +4 -0
  44. package/src/utils/{iframeHelper.test.ts → iframe/iframeHelper.test.ts} +3 -3
  45. package/src/utils/{iframeHelper.ts → iframe/iframeHelper.ts} +3 -3
  46. package/src/utils/iframe/index.ts +6 -0
  47. package/src/utils/index.ts +31 -24
  48. package/src/utils/sso/index.ts +6 -0
  49. package/src/utils/{sso.ts → sso/sso.ts} +2 -2
  50. package/cdn/bundle.js +0 -14
  51. package/dist/actions-DihYM-OG.js +0 -1
  52. package/dist/actions-cYbmqewX.cjs +0 -1
  53. package/dist/actions.cjs +0 -1
  54. package/dist/actions.d.cts +0 -3
  55. package/dist/actions.d.ts +0 -3
  56. package/dist/actions.js +0 -1
  57. package/dist/bundle.cjs +0 -1
  58. package/dist/bundle.d.cts +0 -4
  59. package/dist/bundle.d.ts +0 -4
  60. package/dist/bundle.js +0 -1
  61. package/dist/index-BhBuaCRl.d.cts +0 -707
  62. package/dist/index-BsBbSMxk.d.cts +0 -646
  63. package/dist/index-CeX1Tl7W.d.ts +0 -707
  64. package/dist/index-quaxtKRh.d.ts +0 -646
  65. package/dist/index.cjs +0 -1
  66. package/dist/index.d.cts +0 -3
  67. package/dist/index.d.ts +0 -3
  68. package/dist/index.js +0 -1
  69. package/dist/openSso-DyUQew2K.d.ts +0 -1392
  70. package/dist/openSso-rQhLhPbq.d.cts +0 -1392
  71. package/dist/sdkConfigStore-BXzz5PlK.js +0 -1
  72. package/dist/sdkConfigStore-DDL_fjYX.cjs +0 -1
  73. package/dist/src-CMaRNkkJ.cjs +0 -13
  74. package/dist/src-DMFOQMm6.js +0 -13
  75. package/src/clients/DebugInfo.test.ts +0 -418
  76. package/src/clients/DebugInfo.ts +0 -182
  77. package/src/utils/computeLegacyProductId.ts +0 -11
  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/constants.ts → constants.ts} +0 -0
  86. /package/src/{utils → context}/mergeAttribution.test.ts +0 -0
  87. /package/src/{utils → context}/mergeAttribution.ts +0 -0
  88. /package/src/utils/{deepLinkWithFallback.test.ts → browser/deepLinkWithFallback.test.ts} +0 -0
@@ -1,707 +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-rQhLhPbq.cjs";
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
- * Replaced at build time via tsdown/Vite `define`. Defaults to the prod scheme;
319
- * in-monorepo dev builds (listener at wallet-dev.frak.id) override this with
320
- * `frakwallet-dev://` so deep links open the dev wallet variant (id.frak.wallet.dev).
321
- * External integrators consuming the published NPM/CDN bundle always see the prod scheme.
322
- */
323
- declare const DEEP_LINK_SCHEME: string;
324
- //#endregion
325
- //#region src/utils/deepLinkWithFallback.d.ts
326
- /**
327
- * Options for deep link with fallback
328
- */
329
- type DeepLinkFallbackOptions = {
330
- /** Timeout in ms before triggering fallback (default: 2500ms) */timeout?: number; /** Callback invoked when fallback is triggered (app not installed) */
331
- onFallback?: () => void;
332
- };
333
- /**
334
- * Check if running on a Chromium-based Android browser.
335
- *
336
- * On Chrome Android, custom scheme deep links (e.g. frakwallet://) trigger
337
- * a confirmation bar ("Continue to Frak Wallet?"). Using intent:// URLs
338
- * instead bypasses this for Chromium browsers while keeping custom scheme
339
- * fallback for non-Chromium browsers (e.g. Firefox) where it works fine.
340
- */
341
- declare function isChromiumAndroid(): boolean;
342
- declare function toAndroidIntentUrl(deepLink: string): string;
343
- /**
344
- * Trigger a deep link with visibility-based fallback detection.
345
- *
346
- * Uses the Page Visibility API to detect if the app opened (page goes hidden).
347
- * If the page remains visible after the timeout, assumes app is not installed
348
- * and invokes the onFallback callback.
349
- *
350
- * On Chromium Android, converts custom scheme to intent:// URL to avoid
351
- * the "Continue to app?" confirmation bar.
352
- *
353
- * @param deepLink - The deep link URL to trigger (e.g., "frakwallet://wallet")
354
- * @param options - Optional configuration (timeout, onFallback callback)
355
- */
356
- declare function triggerDeepLinkWithFallback(deepLink: string, options?: DeepLinkFallbackOptions): void;
357
- /**
358
- * Check if a URL is a Frak deep link
359
- */
360
- declare function isFrakDeepLink(url: string): boolean;
361
- //#endregion
362
- //#region src/utils/FrakContext.d.ts
363
- /**
364
- * Compress a Frak context into a URL-safe string.
365
- *
366
- * - V2 contexts are encoded using a compact binary layout (see
367
- * {@link encodeFrakContextV2}) then base64url-encoded.
368
- * - V1 contexts encode the wallet address as raw bytes (base64url).
369
- *
370
- * @param context - The context to compress (V1 or V2)
371
- * @returns A compressed base64url string, or undefined on failure
372
- */
373
- declare function compress(context?: FrakContextV1 | FrakContextV2): string | undefined;
374
- /**
375
- * Decompress a base64url string back into a Frak context.
376
- *
377
- * V1 (exactly 20 bytes) and V2 (37, 41, or 57 bytes) are distinguished by
378
- * their decoded byte length, so there is no ambiguity.
379
- *
380
- * @param context - The compressed context string
381
- * @returns The decompressed FrakContext, or undefined on failure
382
- */
383
- declare function decompress(context?: string): FrakContext | undefined;
384
- /**
385
- * Parse a URL to extract the Frak referral context from the `fCtx` query parameter.
386
- *
387
- * @param args
388
- * @param args.url - The URL to parse
389
- * @returns The parsed FrakContext, or null if absent
390
- */
391
- declare function parse({
392
- url
393
- }: {
394
- url: string;
395
- }): FrakContext | null | undefined;
396
- /**
397
- * Add or replace the `fCtx` query parameter in a URL with the given context.
398
- *
399
- * Standard affiliation params (`utm_source`, `utm_medium`, `utm_campaign`,
400
- * `ref`, `via`, ...) are always appended using gap-fill semantics: pre-existing
401
- * params on the URL are preserved, defaults are derived from the context when
402
- * applicable, and `attribution` overrides take precedence when provided.
403
- *
404
- * @param args
405
- * @param args.url - The URL to update
406
- * @param args.context - The context to embed (V1 or V2)
407
- * @param args.attribution - Optional attribution overrides. Defaults are applied even when omitted.
408
- * @returns The updated URL string, or null on failure
409
- */
410
- declare function update({
411
- url,
412
- context,
413
- attribution
414
- }: {
415
- url?: string;
416
- context: FrakContextV1 | FrakContextV2;
417
- attribution?: AttributionParams;
418
- }): string | null;
419
- /**
420
- * Remove the `fCtx` query parameter from a URL.
421
- *
422
- * @param url - The URL to strip the context from
423
- * @returns The cleaned URL string
424
- */
425
- declare function remove(url: string): string;
426
- /**
427
- * Replace the current browser URL with an updated Frak context.
428
- *
429
- * - If `context` is non-null, embeds it via {@link update}.
430
- * - If `context` is null, strips the context via {@link remove}.
431
- *
432
- * @param args
433
- * @param args.url - Base URL (defaults to `window.location.href`)
434
- * @param args.context - Context to set, or null to remove
435
- */
436
- declare function replaceUrl({
437
- url: baseUrl,
438
- context
439
- }: {
440
- url?: string;
441
- context: FrakContextV1 | FrakContextV2 | null;
442
- }): void;
443
- /**
444
- * Manager for Frak referral context in URLs.
445
- *
446
- * Handles compression, decompression, URL parsing, and browser history updates
447
- * for both V1 (wallet address) and V2 (anonymous clientId) referral contexts.
448
- */
449
- declare const FrakContextManager: {
450
- compress: typeof compress;
451
- decompress: typeof decompress;
452
- parse: typeof parse;
453
- update: typeof update;
454
- remove: typeof remove;
455
- replaceUrl: typeof replaceUrl;
456
- };
457
- //#endregion
458
- //#region src/utils/formatAmount.d.ts
459
- /**
460
- * Format a numeric amount as a localized currency string
461
- * @param amount - The raw numeric amount to format
462
- * @param currency - Optional currency config; defaults to EUR/fr-FR when omitted
463
- * @returns Localized currency string (e.g. "1 500 €", "$1,500")
464
- */
465
- declare function formatAmount(amount: number, currency?: Currency): string;
466
- //#endregion
467
- //#region src/utils/getCurrencyAmountKey.d.ts
468
- /**
469
- * Get the currency amount key for a given currency
470
- * @param currency - The currency to use
471
- * @returns The currency amount key
472
- */
473
- declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
474
- //#endregion
475
- //#region src/utils/getSupportedCurrency.d.ts
476
- /**
477
- * Get the supported currency for a given currency
478
- * @param currency - The currency to use
479
- * @returns The supported currency
480
- */
481
- declare function getSupportedCurrency(currency?: Currency): Currency;
482
- //#endregion
483
- //#region src/utils/getSupportedLocale.d.ts
484
- /**
485
- * Get the supported locale for a given currency
486
- * @param currency - The currency to use
487
- * @returns The supported locale
488
- */
489
- declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
490
- //#endregion
491
- //#region src/utils/iframeHelper.d.ts
492
- /**
493
- * Base props for the iframe
494
- * @ignore
495
- */
496
- declare const baseIframeProps: {
497
- id: string;
498
- name: string;
499
- title: string;
500
- allow: string;
501
- style: {
502
- width: string;
503
- height: string;
504
- border: string;
505
- position: string;
506
- zIndex: number;
507
- top: string;
508
- left: string;
509
- colorScheme: string;
510
- };
511
- };
512
- /**
513
- * Create the Frak iframe
514
- * @param args
515
- * @param args.walletBaseUrl - Use `config.walletUrl` instead. Will be removed in future versions.
516
- * @param args.config - The configuration object containing iframe options, including the replacement for `walletBaseUrl`.
517
- */
518
- declare function createIframe({
519
- walletBaseUrl,
520
- config
521
- }: {
522
- walletBaseUrl?: string;
523
- config?: FrakWalletSdkConfig;
524
- }): Promise<HTMLIFrameElement | undefined>;
525
- /**
526
- * Find an iframe within window.opener by pathname
527
- *
528
- * When a popup is opened via window.open from an iframe, window.opener points to
529
- * the parent window, not the iframe itself. This utility searches through all frames
530
- * in window.opener to find an iframe matching the specified pathname.
531
- *
532
- * @param pathname - The pathname to search for (default: "/listener")
533
- * @returns The matching iframe window, or null if not found
534
- *
535
- * @example
536
- * ```typescript
537
- * // Find the default /listener iframe
538
- * const listenerIframe = findIframeInOpener();
539
- *
540
- * // Find a custom iframe
541
- * const customIframe = findIframeInOpener("/my-custom-iframe");
542
- * ```
543
- */
544
- declare function findIframeInOpener(pathname?: string): Window | null;
545
- //#endregion
546
- //#region src/utils/inAppBrowser.d.ts
547
- /**
548
- * Whether the current device runs iOS (including iPadOS 13+).
549
- */
550
- declare const isIOS: boolean;
551
- /**
552
- * Whether the current browser is a social media in-app browser
553
- * (Instagram, Facebook).
554
- */
555
- declare const isInAppBrowser: boolean;
556
- /**
557
- * Redirect to external browser from in-app WebView.
558
- *
559
- * - **iOS**: Uses `x-safari-https://` scheme — server-side 302 redirects
560
- * to custom URL schemes are silently swallowed by WKWebView.
561
- * Direct `window.location.href` assignment works (confirmed iOS 17+).
562
- *
563
- * - **Android**: Uses backend `/common/social` endpoint which returns a PDF
564
- * Content-Type response, forcing the WebView to hand off to the default browser.
565
- *
566
- * @param targetUrl - The URL to open in the external browser
567
- */
568
- declare function redirectToExternalBrowser(targetUrl: string): void;
569
- //#endregion
570
- //#region src/utils/mergeAttribution.d.ts
571
- /**
572
- * Inputs for {@link mergeAttribution}.
573
- */
574
- type MergeAttributionInput = {
575
- /**
576
- * Per-call attribution override passed to actions like `displaySharingPage`.
577
- *
578
- * - `null` explicitly disables attribution (no UTM/ref/via params are added).
579
- * - `undefined` means "no per-call override" — defaults apply if present.
580
- * - An object (including `{}`) merges field-by-field with defaults.
581
- */
582
- perCall: AttributionParams | null | undefined;
583
- /**
584
- * Pre-merged merchant-level defaults (backend config > SDK static config).
585
- * `utm_content` is intentionally absent from this shape.
586
- */
587
- defaults?: AttributionDefaults;
588
- /**
589
- * Per-product `utm_content` override (from the currently selected
590
- * `SharingPageProduct`). Takes precedence over `perCall.utmContent`.
591
- */
592
- productUtmContent?: string;
593
- };
594
- /**
595
- * Merge the three attribution layers into a single {@link AttributionParams}
596
- * value suitable for `FrakContextManager.update`.
597
- *
598
- * Priority per field:
599
- * 1. `perCall` (wins)
600
- * 2. `defaults` (merchant-level, backend > SDK static, already pre-merged)
601
- * 3. Hardcoded fallbacks resolved later by `FrakContextManager`
602
- *
603
- * Special rules:
604
- * - `perCall === null` returns `undefined` (explicit disable: no UTM/ref/via).
605
- * - `perCall === undefined` (no opinion) yields at least `{}` so `FrakContextManager`
606
- * applies its hardcoded defaults (utm_source=frak, utm_medium=referral,
607
- * utm_campaign=<merchantId>, ref=<clientId>, via=frak).
608
- * - `utm_content` never comes from `defaults`; only `productUtmContent` or
609
- * `perCall.utmContent` can populate it.
610
- */
611
- declare function mergeAttribution({
612
- perCall,
613
- defaults,
614
- productUtmContent
615
- }: MergeAttributionInput): AttributionParams | undefined;
616
- //#endregion
617
- //#region src/utils/sdkConfigStore.d.ts
618
- declare const GLOBAL_KEY = "__frakSdkConfig";
619
- declare global {
620
- interface Window {
621
- [GLOBAL_KEY]?: SdkResolvedConfig;
622
- }
623
- interface WindowEventMap {
624
- "frak:config": CustomEvent<SdkResolvedConfig>;
625
- }
626
- }
627
- declare function getConfig(): SdkResolvedConfig;
628
- declare const sdkConfigStore: {
629
- getConfig: typeof getConfig;
630
- readonly isResolved: boolean;
631
- readonly isCacheFresh: boolean;
632
- setCacheScope(domain: string, lang?: string): void;
633
- setConfig(config: SdkResolvedConfig): void;
634
- reset(): void;
635
- clearCache(): void;
636
- resolve(domain?: string, walletUrl?: string, lang?: Language): Promise<MerchantConfigResponse | undefined>;
637
- getMerchantId(): string | undefined;
638
- resolveMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
639
- };
640
- //#endregion
641
- //#region src/utils/sso.d.ts
642
- type AppSpecificSsoMetadata = SsoMetadata & {
643
- name?: string;
644
- css?: string;
645
- };
646
- /**
647
- * The full SSO params that will be used for compression
648
- */
649
- type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
650
- metadata: AppSpecificSsoMetadata;
651
- merchantId: string;
652
- clientId: string;
653
- };
654
- /**
655
- * Generate SSO URL with compressed parameters
656
- * This mirrors the wallet's getOpenSsoLink() function
657
- *
658
- * @param walletUrl - Base wallet URL (e.g., "https://wallet.frak.id")
659
- * @param params - SSO parameters
660
- * @param merchantId - Merchant identifier
661
- * @param name - Application name
662
- * @param clientId - Client identifier for identity tracking
663
- * @param css - Optional custom CSS
664
- * @returns Complete SSO URL ready to open in popup or redirect
665
- *
666
- * @example
667
- * ```ts
668
- * const ssoUrl = generateSsoUrl(
669
- * "https://wallet.frak.id",
670
- * { metadata: { logoUrl: "..." }, directExit: true },
671
- * "0x123...",
672
- * "My App"
673
- * );
674
- * // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
675
- * ```
676
- */
677
- declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string | undefined, clientId: string, css?: string): string;
678
- /**
679
- * Type of compressed the sso data
680
- */
681
- type CompressedSsoData = {
682
- id?: Hex;
683
- cId: string;
684
- r?: string;
685
- d?: boolean;
686
- l?: "en" | "fr";
687
- m: string;
688
- md: {
689
- n?: string;
690
- css?: string;
691
- l?: string;
692
- h?: string;
693
- };
694
- };
695
- //#endregion
696
- //#region src/utils/computeLegacyProductId.d.ts
697
- /**
698
- * Compute the legacy product id from a domain
699
- * @ignore
700
- */
701
- declare function computeLegacyProductId({
702
- domain
703
- }?: {
704
- domain?: string;
705
- }): `0x${string}`;
706
- //#endregion
707
- 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 };