@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,182 +0,0 @@
1
- import {
2
- FrakRpcError,
3
- type RpcMessage,
4
- type RpcResponse,
5
- } from "@frak-labs/frame-connector";
6
- import type { FrakWalletSdkConfig } from "../types";
7
-
8
- type IframeStatus = {
9
- loading: boolean;
10
- url: string | null;
11
- readyState: number;
12
- contentWindow: boolean;
13
- isConnected: boolean;
14
- };
15
-
16
- type DebugInfo = {
17
- timestamp: string;
18
- encodedUrl: string;
19
- navigatorInfo: string;
20
- encodedConfig: string;
21
- iframeStatus: string;
22
- lastRequest: string;
23
- lastResponse: string;
24
- clientStatus: string;
25
- error: string;
26
- };
27
-
28
- type NavigatorInfo = {
29
- userAgent: string;
30
- language: string;
31
- onLine: boolean;
32
- screenWidth: number;
33
- screenHeight: number;
34
- pixelRatio: number;
35
- };
36
-
37
- /** @ignore */
38
- export class DebugInfoGatherer {
39
- private config?: FrakWalletSdkConfig;
40
- private iframe?: HTMLIFrameElement;
41
- private isSetupDone = false;
42
- private lastResponse: null | {
43
- message: RpcMessage;
44
- response: RpcResponse;
45
- timestamp: number;
46
- } = null;
47
- private lastRequest: null | {
48
- event: RpcMessage;
49
- timestamp: number;
50
- } = null;
51
-
52
- constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement) {
53
- this.config = config;
54
- this.iframe = iframe;
55
- this.lastRequest = null;
56
- this.lastResponse = null;
57
- }
58
-
59
- // Update communication logs
60
- public setLastResponse(message: RpcMessage, response: RpcResponse) {
61
- this.lastResponse = {
62
- message,
63
- response,
64
- timestamp: Date.now(),
65
- };
66
- }
67
- public setLastRequest(event: RpcMessage) {
68
- this.lastRequest = { event, timestamp: Date.now() };
69
- }
70
-
71
- // Update connection status
72
- public updateSetupStatus(status: boolean) {
73
- this.isSetupDone = status;
74
- }
75
-
76
- private base64Encode(data: object): string {
77
- try {
78
- return btoa(JSON.stringify(data));
79
- } catch (err) {
80
- console.warn("Failed to encode debug data", err);
81
- return btoa("Failed to encode data");
82
- }
83
- }
84
-
85
- /**
86
- * Extract information from the iframe status
87
- */
88
- private getIframeStatus(): IframeStatus | null {
89
- if (!this.iframe) {
90
- return null;
91
- }
92
- return {
93
- loading: this.iframe.hasAttribute("loading"),
94
- url: this.iframe.src,
95
- readyState: this.iframe.contentDocument?.readyState
96
- ? this.iframe.contentDocument.readyState === "complete"
97
- ? 1
98
- : 0
99
- : -1,
100
- contentWindow: !!this.iframe.contentWindow,
101
- isConnected: this.iframe.isConnected,
102
- };
103
- }
104
-
105
- private getNavigatorInfo(): NavigatorInfo | null {
106
- if (!navigator) {
107
- return null;
108
- }
109
- return {
110
- userAgent: navigator.userAgent,
111
- language: navigator.language,
112
- onLine: navigator.onLine,
113
- screenWidth: window.screen.width,
114
- screenHeight: window.screen.height,
115
- pixelRatio: window.devicePixelRatio,
116
- };
117
- }
118
-
119
- private gatherDebugInfo(error: Error | unknown): DebugInfo {
120
- const iframeStatus = this.getIframeStatus();
121
- const navigatorInfo = this.getNavigatorInfo();
122
-
123
- // Format the error in a readable format
124
- let formattedError = "Unknown";
125
- if (error instanceof FrakRpcError) {
126
- formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
127
- } else if (error instanceof Error) {
128
- formattedError = error.message;
129
- } else if (typeof error === "string") {
130
- formattedError = error;
131
- }
132
-
133
- // Craft the debug info
134
- const debugInfo: DebugInfo = {
135
- timestamp: new Date().toISOString(),
136
- encodedUrl: btoa(window.location.href),
137
- encodedConfig: this.config
138
- ? this.base64Encode(this.config)
139
- : "no-config",
140
- navigatorInfo: navigatorInfo
141
- ? this.base64Encode(navigatorInfo)
142
- : "no-navigator",
143
- iframeStatus: iframeStatus
144
- ? this.base64Encode(iframeStatus)
145
- : "not-iframe",
146
- lastRequest: this.lastRequest
147
- ? this.base64Encode(this.lastRequest)
148
- : "No Frak request logged",
149
- lastResponse: this.lastResponse
150
- ? this.base64Encode(this.lastResponse)
151
- : "No Frak response logged",
152
- clientStatus: this.isSetupDone ? "setup" : "not-setup",
153
- error: formattedError,
154
- };
155
-
156
- return debugInfo;
157
- }
158
-
159
- public static empty(): DebugInfoGatherer {
160
- return new DebugInfoGatherer();
161
- }
162
-
163
- /**
164
- * Format Frak debug information
165
- */
166
- public formatDebugInfo(error: Error | unknown | string): string {
167
- const debugInfo = this.gatherDebugInfo(error);
168
- return `
169
- Debug Information:
170
- -----------------
171
- Timestamp: ${debugInfo.timestamp}
172
- URL: ${debugInfo.encodedUrl}
173
- Config: ${debugInfo.encodedConfig}
174
- Navigator Info: ${debugInfo.navigatorInfo}
175
- IFrame Status: ${debugInfo.iframeStatus}
176
- Last Request: ${debugInfo.lastRequest}
177
- Last Response: ${debugInfo.lastResponse}
178
- Client Status: ${debugInfo.clientStatus}
179
- Error: ${debugInfo.error}
180
- `.trim();
181
- }
182
- }
@@ -1,11 +0,0 @@
1
- import { keccak256, toHex } from "viem";
2
-
3
- /**
4
- * Compute the legacy product id from a domain
5
- * @ignore
6
- */
7
- export function computeLegacyProductId({ domain }: { domain?: string } = {}) {
8
- const effectiveDomain = domain ?? window.location.host;
9
- const normalizedDomain = effectiveDomain.replace("www.", "");
10
- return keccak256(toHex(normalizedDomain));
11
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * The backup key for client side backup if needed
3
- */
4
- export const BACKUP_KEY = "nexus-wallet-backup";
5
-
6
- /**
7
- * Deep link scheme for Frak Wallet mobile app
8
- */
9
- export const DEEP_LINK_SCHEME = "frakwallet://";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes