@frak-labs/core-sdk 0.0.4 → 0.0.6
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 +18 -6
- package/dist/actions/index.cjs +61 -63
- package/dist/actions/index.d.cts +11 -13
- package/dist/actions/index.d.ts +11 -13
- package/dist/actions/index.js +21 -36
- package/dist/{chunk-GDH3M5ZC.js → chunk-665P7NO4.cjs} +7 -10
- package/dist/{chunk-HDFNBQ4E.cjs → chunk-7YDJDVXY.cjs} +61 -70
- package/dist/{chunk-AFLVOY5H.js → chunk-GTBCSNLF.js} +34 -57
- package/dist/chunk-PHVGCFDX.cjs +155 -0
- package/dist/{chunk-PO6YSB4Q.cjs → chunk-U2NTN5QZ.js} +2 -11
- package/dist/{chunk-RMOFMRZR.js → chunk-VE6URIIJ.js} +19 -41
- package/dist/{context-BjKowynW.d.cts → context-D7aZDKLT.d.cts} +209 -23
- package/dist/{context-DjVVznrf.d.ts → context-rDsQbSgB.d.ts} +209 -23
- package/dist/index.cjs +231 -68
- package/dist/index.d.cts +49 -67
- package/dist/index.d.ts +49 -67
- package/dist/index.js +154 -50
- package/dist/interactions/index.cjs +26 -15
- package/dist/interactions/index.js +1 -15
- package/package.json +9 -4
- package/dist/chunk-ZDGHKI3S.cjs +0 -171
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import { F as FrakWalletSdkConfig, a as FrakClient, b as FrakContext } from './context-
|
|
2
|
-
export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc,
|
|
1
|
+
import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-rDsQbSgB.js';
|
|
2
|
+
export { C as ClientLifecycleEvent, D as DisplayEmbededWalletParamsType, j as DisplayModalParamsType, E as EmbededViewAction, H as ExtractedParametersFromRpc, J as ExtractedReturnTypeFromRpc, y as FinalActionType, x as FinalModalStepType, e as FullInteractionTypesKey, G as GetProductInformationReturnType, B as IFrameLifecycleEvent, A as IFrameRpcEvent, f as IFrameRpcSchema, z as IFrameTransport, d as InteractionTypesKey, g as LoggedInEmbededView, L as LoggedOutEmbededView, n as LoginModalStepType, h as ModalRpcMetadata, k as ModalRpcStepsInput, l as ModalRpcStepsResultType, m as ModalStepMetadata, M as ModalStepTypes, w as OpenInteractionSessionModalStepType, v as OpenInteractionSessionReturnType, O as OpenSsoParamsType, P as ProductTypesKey, R as RpcResponse, t as SendTransactionModalStepType, u as SendTransactionReturnType, s as SendTransactionTxType, o as SiweAuthenticateModalStepType, r as SiweAuthenticateReturnType, q as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType, i as interactionTypes, p as productTypes, c as productTypesMask } from './context-rDsQbSgB.js';
|
|
3
3
|
export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from './interaction-CTQ5-kqe.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import 'viem/chains';
|
|
6
6
|
import 'viem/siwe';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Create a new iframe Frak client
|
|
10
|
+
* @param args
|
|
11
|
+
* @param args.config - The configuration to use for the Frak Wallet SDK
|
|
12
|
+
* @param args.iframe - The iframe to use for the communication
|
|
13
|
+
* @returns The created Frak Client
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const frakConfig: FrakWalletSdkConfig = {
|
|
17
|
+
* metadata: {
|
|
18
|
+
* name: "My app title",
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
* const iframe = await createIframe({ config: frakConfig });
|
|
22
|
+
* const client = createIFrameFrakClient({ config: frakConfig, iframe });
|
|
23
|
+
*/
|
|
24
|
+
declare function createIFrameFrakClient({ config, iframe, }: {
|
|
25
|
+
config: FrakWalletSdkConfig;
|
|
26
|
+
iframe: HTMLIFrameElement;
|
|
27
|
+
}): FrakClient;
|
|
28
|
+
|
|
8
29
|
/**
|
|
9
30
|
* Generic Frak RPC error
|
|
10
31
|
* @ignore
|
|
@@ -58,27 +79,6 @@ type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
58
79
|
*/
|
|
59
80
|
type KeyProvider<DataType> = (value: DataType) => string[];
|
|
60
81
|
|
|
61
|
-
/**
|
|
62
|
-
* Create a new iframe Frak client
|
|
63
|
-
* @param args
|
|
64
|
-
* @param args.config - The configuration to use for the Frak Wallet SDK
|
|
65
|
-
* @param args.iframe - The iframe to use for the communication
|
|
66
|
-
* @returns The created Frak Client
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* const frakConfig: FrakWalletSdkConfig = {
|
|
70
|
-
* metadata: {
|
|
71
|
-
* name: "My app title",
|
|
72
|
-
* },
|
|
73
|
-
* }
|
|
74
|
-
* const iframe = await createIframe({ config: frakConfig });
|
|
75
|
-
* const client = createIFrameFrakClient({ config: frakConfig, iframe });
|
|
76
|
-
*/
|
|
77
|
-
declare function createIFrameFrakClient({ config, iframe, }: {
|
|
78
|
-
config: FrakWalletSdkConfig;
|
|
79
|
-
iframe: HTMLIFrameElement;
|
|
80
|
-
}): FrakClient;
|
|
81
|
-
|
|
82
82
|
/**
|
|
83
83
|
* Directly setup the Frak client with an iframe
|
|
84
84
|
* Return when the FrakClient is ready (setup and communication estbalished with the wallet)
|
|
@@ -98,6 +98,31 @@ declare function setupClient({ config, }: {
|
|
|
98
98
|
config: FrakWalletSdkConfig;
|
|
99
99
|
}): Promise<FrakClient | undefined>;
|
|
100
100
|
|
|
101
|
+
/** @ignore */
|
|
102
|
+
declare class DebugInfoGatherer {
|
|
103
|
+
private config?;
|
|
104
|
+
private iframe?;
|
|
105
|
+
private isSetupDone;
|
|
106
|
+
private lastResponse;
|
|
107
|
+
private lastRequest;
|
|
108
|
+
constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
|
|
109
|
+
setLastResponse(event: MessageEvent<IFrameEvent>): void;
|
|
110
|
+
setLastRequest(event: IFrameEvent, target: string): void;
|
|
111
|
+
updateSetupStatus(status: boolean): void;
|
|
112
|
+
private base64Encode;
|
|
113
|
+
/**
|
|
114
|
+
* Extract information from the iframe status
|
|
115
|
+
*/
|
|
116
|
+
private getIframeStatus;
|
|
117
|
+
private getNavigatorInfo;
|
|
118
|
+
private gatherDebugInfo;
|
|
119
|
+
static empty(): DebugInfoGatherer;
|
|
120
|
+
/**
|
|
121
|
+
* Format Frak debug information
|
|
122
|
+
*/
|
|
123
|
+
formatDebugInfo(error: Error | unknown | string): string;
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
/**
|
|
102
127
|
* Base props for the iframe
|
|
103
128
|
* @ignore
|
|
@@ -227,47 +252,4 @@ declare class Deferred<T> {
|
|
|
227
252
|
reject: (reason?: unknown) => void;
|
|
228
253
|
}
|
|
229
254
|
|
|
230
|
-
|
|
231
|
-
* The final keys for each interaction types (e.g. `openArticle`) -> interaction type
|
|
232
|
-
* @inline
|
|
233
|
-
*/
|
|
234
|
-
type InteractionTypesKey = {
|
|
235
|
-
[K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
|
|
236
|
-
}[keyof typeof interactionTypes];
|
|
237
|
-
/**
|
|
238
|
-
* The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
|
|
239
|
-
* @inline
|
|
240
|
-
*/
|
|
241
|
-
type FullInteractionTypesKey = {
|
|
242
|
-
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
243
|
-
}[keyof typeof interactionTypes];
|
|
244
|
-
/**
|
|
245
|
-
* Each interactions types according to the product types
|
|
246
|
-
*/
|
|
247
|
-
declare const interactionTypes: {
|
|
248
|
-
readonly press: {
|
|
249
|
-
readonly openArticle: "0xc0a24ffb";
|
|
250
|
-
readonly readArticle: "0xd5bd0fbe";
|
|
251
|
-
};
|
|
252
|
-
readonly dapp: {
|
|
253
|
-
readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
|
|
254
|
-
readonly callableVerifiableStorageUpdate: "0xa07da986";
|
|
255
|
-
};
|
|
256
|
-
readonly webshop: {
|
|
257
|
-
readonly open: "0xb311798f";
|
|
258
|
-
};
|
|
259
|
-
readonly referral: {
|
|
260
|
-
readonly referred: "0x010cc3b9";
|
|
261
|
-
readonly createLink: "0xb2c0f17c";
|
|
262
|
-
};
|
|
263
|
-
readonly purchase: {
|
|
264
|
-
readonly started: "0xd87e90c3";
|
|
265
|
-
readonly completed: "0x8403aeb4";
|
|
266
|
-
readonly unsafeCompleted: "0x4d5b14e0";
|
|
267
|
-
};
|
|
268
|
-
readonly retail: {
|
|
269
|
-
readonly customerMeeting: "0x74489004";
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export { ClientNotFound, type CompressedData, Deferred, FrakClient, FrakContext, FrakContextManager, FrakRpcError, FrakWalletSdkConfig, type FullInteractionTypesKey, type HashProtectedData, type InteractionTypesKey, type KeyProvider, RpcErrorCodes, baseIframeProps, compressJson, createIFrameFrakClient, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData, interactionTypes, setupClient };
|
|
255
|
+
export { ClientNotFound, type CompressedData, DebugInfoGatherer, Deferred, FrakClient, FrakContext, FrakContextManager, FrakRpcError, FrakWalletSdkConfig, type HashProtectedData, IFrameEvent, type KeyProvider, RpcErrorCodes, baseIframeProps, compressJson, createIFrameFrakClient, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData, setupClient };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
FrakContextManager,
|
|
5
|
-
FrakRpcError,
|
|
6
|
-
InternalError,
|
|
7
|
-
RpcErrorCodes,
|
|
8
|
-
baseIframeProps,
|
|
9
|
-
changeIframeVisibility,
|
|
10
|
-
compressJson,
|
|
11
|
-
createIframe,
|
|
12
|
-
decompressDataAndCheckHash,
|
|
13
|
-
decompressJson,
|
|
14
|
-
hashAndCompressData
|
|
15
|
-
} from "./chunk-AFLVOY5H.js";
|
|
16
|
-
import {
|
|
17
|
-
interactionTypes,
|
|
18
|
-
productTypes,
|
|
19
|
-
productTypesMask
|
|
20
|
-
} from "./chunk-GDH3M5ZC.js";
|
|
1
|
+
import { createIframe, FrakRpcError, RpcErrorCodes, Deferred, decompressDataAndCheckHash, hashAndCompressData, InternalError, changeIframeVisibility } from './chunk-GTBCSNLF.js';
|
|
2
|
+
export { ClientNotFound, Deferred, FrakContextManager, FrakRpcError, RpcErrorCodes, baseIframeProps, compressJson, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData } from './chunk-GTBCSNLF.js';
|
|
3
|
+
export { interactionTypes, productTypes, productTypesMask } from './chunk-U2NTN5QZ.js';
|
|
21
4
|
|
|
22
5
|
// src/utils/constants.ts
|
|
23
6
|
var BACKUP_KEY = "nexus-wallet-backup";
|
|
24
7
|
|
|
8
|
+
// src/clients/DebugInfo.ts
|
|
9
|
+
var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
10
|
+
config;
|
|
11
|
+
iframe;
|
|
12
|
+
isSetupDone = false;
|
|
13
|
+
lastResponse = null;
|
|
14
|
+
lastRequest = null;
|
|
15
|
+
constructor(config, iframe) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.iframe = iframe;
|
|
18
|
+
this.lastRequest = null;
|
|
19
|
+
this.lastResponse = null;
|
|
20
|
+
}
|
|
21
|
+
// Update communication logs
|
|
22
|
+
setLastResponse(event) {
|
|
23
|
+
this.lastResponse = {
|
|
24
|
+
event: event.data,
|
|
25
|
+
origin: event.origin,
|
|
26
|
+
timestamp: Date.now()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
setLastRequest(event, target) {
|
|
30
|
+
this.lastRequest = { event, target, timestamp: Date.now() };
|
|
31
|
+
}
|
|
32
|
+
// Update connection status
|
|
33
|
+
updateSetupStatus(status) {
|
|
34
|
+
this.isSetupDone = status;
|
|
35
|
+
}
|
|
36
|
+
base64Encode(data) {
|
|
37
|
+
try {
|
|
38
|
+
return btoa(JSON.stringify(data));
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.warn("Failed to encode debug data", err);
|
|
41
|
+
return btoa("Failed to encode data");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Extract information from the iframe status
|
|
46
|
+
*/
|
|
47
|
+
getIframeStatus() {
|
|
48
|
+
if (!this.iframe) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
loading: this.iframe.hasAttribute("loading"),
|
|
53
|
+
url: this.iframe.src,
|
|
54
|
+
readyState: this.iframe.contentDocument?.readyState ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
|
|
55
|
+
contentWindow: !!this.iframe.contentWindow,
|
|
56
|
+
isConnected: this.iframe.isConnected
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
getNavigatorInfo() {
|
|
60
|
+
if (!navigator) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
userAgent: navigator.userAgent,
|
|
65
|
+
language: navigator.language,
|
|
66
|
+
onLine: navigator.onLine,
|
|
67
|
+
screenWidth: window.screen.width,
|
|
68
|
+
screenHeight: window.screen.height,
|
|
69
|
+
pixelRatio: window.devicePixelRatio
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
gatherDebugInfo(error) {
|
|
73
|
+
const iframeStatus = this.getIframeStatus();
|
|
74
|
+
const navigatorInfo = this.getNavigatorInfo();
|
|
75
|
+
let formattedError = "Unknown";
|
|
76
|
+
if (error instanceof FrakRpcError) {
|
|
77
|
+
formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
|
|
78
|
+
} else if (error instanceof Error) {
|
|
79
|
+
formattedError = error.message;
|
|
80
|
+
} else if (typeof error === "string") {
|
|
81
|
+
formattedError = error;
|
|
82
|
+
}
|
|
83
|
+
const debugInfo = {
|
|
84
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
85
|
+
encodedUrl: btoa(window.location.href),
|
|
86
|
+
encodedConfig: this.config ? this.base64Encode(this.config) : "no-config",
|
|
87
|
+
navigatorInfo: navigatorInfo ? this.base64Encode(navigatorInfo) : "no-navigator",
|
|
88
|
+
iframeStatus: iframeStatus ? this.base64Encode(iframeStatus) : "not-iframe",
|
|
89
|
+
lastRequest: this.lastRequest ? this.base64Encode(this.lastRequest) : "No Frak request logged",
|
|
90
|
+
lastResponse: this.lastResponse ? this.base64Encode(this.lastResponse) : "No Frak response logged",
|
|
91
|
+
clientStatus: this.isSetupDone ? "setup" : "not-setup",
|
|
92
|
+
error: formattedError
|
|
93
|
+
};
|
|
94
|
+
return debugInfo;
|
|
95
|
+
}
|
|
96
|
+
static empty() {
|
|
97
|
+
return new _DebugInfoGatherer();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Format Frak debug information
|
|
101
|
+
*/
|
|
102
|
+
formatDebugInfo(error) {
|
|
103
|
+
const debugInfo = this.gatherDebugInfo(error);
|
|
104
|
+
return `
|
|
105
|
+
Debug Information:
|
|
106
|
+
-----------------
|
|
107
|
+
Timestamp: ${debugInfo.timestamp}
|
|
108
|
+
URL: ${debugInfo.encodedUrl}
|
|
109
|
+
Config: ${debugInfo.encodedConfig}
|
|
110
|
+
Navigator Info: ${debugInfo.navigatorInfo}
|
|
111
|
+
IFrame Status: ${debugInfo.iframeStatus}
|
|
112
|
+
Last Request: ${debugInfo.lastRequest}
|
|
113
|
+
Last Response: ${debugInfo.lastResponse}
|
|
114
|
+
Client Status: ${debugInfo.clientStatus}
|
|
115
|
+
Error: ${debugInfo.error}
|
|
116
|
+
`.trim();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
25
120
|
// src/clients/transports/iframeChannelManager.ts
|
|
26
121
|
function createIFrameChannelManager() {
|
|
27
122
|
const channels = /* @__PURE__ */ new Map();
|
|
@@ -69,6 +164,20 @@ function createIFrameLifecycleManager({
|
|
|
69
164
|
isVisible: messageEvent.iframeLifecycle === "show"
|
|
70
165
|
});
|
|
71
166
|
break;
|
|
167
|
+
// Handshake handling
|
|
168
|
+
case "handshake": {
|
|
169
|
+
iframe.contentWindow?.postMessage(
|
|
170
|
+
{
|
|
171
|
+
clientLifecycle: "handshake-response",
|
|
172
|
+
data: {
|
|
173
|
+
token: messageEvent.data.token,
|
|
174
|
+
currentUrl: window.location.href
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"*"
|
|
178
|
+
);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
72
181
|
}
|
|
73
182
|
};
|
|
74
183
|
return {
|
|
@@ -82,7 +191,8 @@ function createIFrameMessageHandler({
|
|
|
82
191
|
frakWalletUrl,
|
|
83
192
|
iframe,
|
|
84
193
|
channelManager,
|
|
85
|
-
iframeLifecycleManager
|
|
194
|
+
iframeLifecycleManager,
|
|
195
|
+
debugInfo
|
|
86
196
|
}) {
|
|
87
197
|
if (typeof window === "undefined") {
|
|
88
198
|
throw new FrakRpcError(
|
|
@@ -97,16 +207,22 @@ function createIFrameMessageHandler({
|
|
|
97
207
|
);
|
|
98
208
|
}
|
|
99
209
|
const contentWindow = iframe.contentWindow;
|
|
100
|
-
|
|
101
|
-
if (!
|
|
210
|
+
async function msgHandler(event) {
|
|
211
|
+
if (!event.origin) {
|
|
102
212
|
return;
|
|
103
213
|
}
|
|
104
|
-
|
|
214
|
+
try {
|
|
215
|
+
if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
} catch (e) {
|
|
219
|
+
console.log("Unable to check frak msg origin", e);
|
|
105
220
|
return;
|
|
106
221
|
}
|
|
107
222
|
if (typeof event.data !== "object") {
|
|
108
223
|
return;
|
|
109
224
|
}
|
|
225
|
+
debugInfo.setLastResponse(event);
|
|
110
226
|
if ("iframeLifecycle" in event.data) {
|
|
111
227
|
await iframeLifecycleManager.handleEvent(event.data);
|
|
112
228
|
return;
|
|
@@ -123,16 +239,17 @@ function createIFrameMessageHandler({
|
|
|
123
239
|
return;
|
|
124
240
|
}
|
|
125
241
|
await resolver(event.data);
|
|
126
|
-
}
|
|
242
|
+
}
|
|
127
243
|
window.addEventListener("message", msgHandler);
|
|
128
|
-
|
|
244
|
+
function sendEvent(message) {
|
|
129
245
|
contentWindow.postMessage(message, {
|
|
130
246
|
targetOrigin: frakWalletUrl
|
|
131
247
|
});
|
|
132
|
-
|
|
133
|
-
|
|
248
|
+
debugInfo.setLastRequest(message, frakWalletUrl);
|
|
249
|
+
}
|
|
250
|
+
function cleanup() {
|
|
134
251
|
window.removeEventListener("message", msgHandler);
|
|
135
|
-
}
|
|
252
|
+
}
|
|
136
253
|
return {
|
|
137
254
|
sendEvent,
|
|
138
255
|
cleanup
|
|
@@ -146,11 +263,13 @@ function createIFrameFrakClient({
|
|
|
146
263
|
}) {
|
|
147
264
|
const channelManager = createIFrameChannelManager();
|
|
148
265
|
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
266
|
+
const debugInfo = new DebugInfoGatherer(config, iframe);
|
|
149
267
|
const messageHandler = createIFrameMessageHandler({
|
|
150
268
|
frakWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
|
|
151
269
|
iframe,
|
|
152
270
|
channelManager,
|
|
153
|
-
iframeLifecycleManager: lifecycleManager
|
|
271
|
+
iframeLifecycleManager: lifecycleManager,
|
|
272
|
+
debugInfo
|
|
154
273
|
});
|
|
155
274
|
const request = async (args) => {
|
|
156
275
|
const isConnected = await lifecycleManager.isConnected;
|
|
@@ -218,9 +337,10 @@ function createIFrameFrakClient({
|
|
|
218
337
|
config,
|
|
219
338
|
messageHandler,
|
|
220
339
|
lifecycleManager
|
|
221
|
-
});
|
|
340
|
+
}).then(() => debugInfo.updateSetupStatus(true));
|
|
222
341
|
return {
|
|
223
342
|
config,
|
|
343
|
+
debugInfo,
|
|
224
344
|
waitForConnection: lifecycleManager.isConnected,
|
|
225
345
|
waitForSetup,
|
|
226
346
|
request,
|
|
@@ -234,7 +354,7 @@ function setupHeartbeat(messageHandler, lifecycleManager) {
|
|
|
234
354
|
let heartbeatInterval;
|
|
235
355
|
let timeoutId;
|
|
236
356
|
const sendHeartbeat = () => messageHandler.sendEvent({
|
|
237
|
-
|
|
357
|
+
clientLifecycle: "heartbeat"
|
|
238
358
|
});
|
|
239
359
|
async function startHeartbeat() {
|
|
240
360
|
sendHeartbeat();
|
|
@@ -306,21 +426,5 @@ async function setupClient({
|
|
|
306
426
|
}
|
|
307
427
|
return client;
|
|
308
428
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
Deferred,
|
|
312
|
-
FrakContextManager,
|
|
313
|
-
FrakRpcError,
|
|
314
|
-
RpcErrorCodes,
|
|
315
|
-
baseIframeProps,
|
|
316
|
-
compressJson,
|
|
317
|
-
createIFrameFrakClient,
|
|
318
|
-
createIframe,
|
|
319
|
-
decompressDataAndCheckHash,
|
|
320
|
-
decompressJson,
|
|
321
|
-
hashAndCompressData,
|
|
322
|
-
interactionTypes,
|
|
323
|
-
productTypes,
|
|
324
|
-
productTypesMask,
|
|
325
|
-
setupClient
|
|
326
|
-
};
|
|
429
|
+
|
|
430
|
+
export { DebugInfoGatherer, createIFrameFrakClient, setupClient };
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPHVGCFDX_cjs = require('../chunk-PHVGCFDX.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "PressInteractionEncoder", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkPHVGCFDX_cjs.PressInteractionEncoder; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "PurchaseInteractionEncoder", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkPHVGCFDX_cjs.PurchaseInteractionEncoder; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "ReferralInteractionEncoder", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkPHVGCFDX_cjs.ReferralInteractionEncoder; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "RetailInteractionEncoder", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkPHVGCFDX_cjs.RetailInteractionEncoder; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "WebShopInteractionEncoder", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkPHVGCFDX_cjs.WebShopInteractionEncoder; }
|
|
26
|
+
});
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
PressInteractionEncoder,
|
|
3
|
-
PurchaseInteractionEncoder,
|
|
4
|
-
ReferralInteractionEncoder,
|
|
5
|
-
RetailInteractionEncoder,
|
|
6
|
-
WebShopInteractionEncoder
|
|
7
|
-
} from "../chunk-RMOFMRZR.js";
|
|
8
|
-
import "../chunk-GDH3M5ZC.js";
|
|
9
|
-
export {
|
|
10
|
-
PressInteractionEncoder,
|
|
11
|
-
PurchaseInteractionEncoder,
|
|
12
|
-
ReferralInteractionEncoder,
|
|
13
|
-
RetailInteractionEncoder,
|
|
14
|
-
WebShopInteractionEncoder
|
|
15
|
-
};
|
|
1
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder } from '../chunk-VE6URIIJ.js';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.6",
|
|
15
15
|
"description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -89,9 +89,14 @@
|
|
|
89
89
|
"js-sha256": "^0.11.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@arethetypeswrong/cli": "^0.17.
|
|
92
|
+
"@arethetypeswrong/cli": "^0.17.3",
|
|
93
93
|
"@types/node": "^22",
|
|
94
|
-
"
|
|
94
|
+
"browserslist": "^4.24.4",
|
|
95
|
+
"browserslist-to-esbuild": "^2.1.1",
|
|
96
|
+
"tsup": "^8.3.6",
|
|
95
97
|
"typescript": "^5"
|
|
96
|
-
}
|
|
98
|
+
},
|
|
99
|
+
"browserslist": [
|
|
100
|
+
"extends @frak-labs/browserslist-config"
|
|
101
|
+
]
|
|
97
102
|
}
|
package/dist/chunk-ZDGHKI3S.cjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkPO6YSB4Qcjs = require('./chunk-PO6YSB4Q.cjs');
|
|
5
|
-
|
|
6
|
-
// src/interactions/pressEncoder.ts
|
|
7
|
-
var _viem = require('viem');
|
|
8
|
-
var PressInteractionEncoder = {
|
|
9
|
-
/**
|
|
10
|
-
* Encode an open article interaction
|
|
11
|
-
* @param args
|
|
12
|
-
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
|
|
13
|
-
*/
|
|
14
|
-
openArticle({ articleId }) {
|
|
15
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
16
|
-
_chunkPO6YSB4Qcjs.interactionTypes.press.openArticle,
|
|
17
|
-
_viem.pad.call(void 0, articleId, { size: 32 })
|
|
18
|
-
]);
|
|
19
|
-
return {
|
|
20
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.press),
|
|
21
|
-
interactionData
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Encode a read article interaction
|
|
26
|
-
* @param args
|
|
27
|
-
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
|
|
28
|
-
*/
|
|
29
|
-
readArticle({ articleId }) {
|
|
30
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
31
|
-
_chunkPO6YSB4Qcjs.interactionTypes.press.readArticle,
|
|
32
|
-
_viem.pad.call(void 0, articleId, { size: 32 })
|
|
33
|
-
]);
|
|
34
|
-
return {
|
|
35
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.press),
|
|
36
|
-
interactionData
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/interactions/referralEncoder.ts
|
|
42
|
-
|
|
43
|
-
var ReferralInteractionEncoder = {
|
|
44
|
-
/**
|
|
45
|
-
* Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
|
|
46
|
-
*/
|
|
47
|
-
createLink() {
|
|
48
|
-
return {
|
|
49
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.referral),
|
|
50
|
-
interactionData: _chunkPO6YSB4Qcjs.interactionTypes.referral.createLink
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Encode a referred interaction
|
|
55
|
-
* @param args
|
|
56
|
-
* @param args.referrer - The Ethereum address of the user who made the referral
|
|
57
|
-
*/
|
|
58
|
-
referred({ referrer }) {
|
|
59
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
60
|
-
_chunkPO6YSB4Qcjs.interactionTypes.referral.referred,
|
|
61
|
-
_viem.pad.call(void 0, referrer, { size: 32 })
|
|
62
|
-
]);
|
|
63
|
-
return {
|
|
64
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.referral),
|
|
65
|
-
interactionData
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// src/interactions/purchaseEncoder.ts
|
|
71
|
-
|
|
72
|
-
var PurchaseInteractionEncoder = {
|
|
73
|
-
/**
|
|
74
|
-
* Encode a start purchase interaction
|
|
75
|
-
* @param args
|
|
76
|
-
* @param args.purchaseId - The id of the purchase that is being started.
|
|
77
|
-
*/
|
|
78
|
-
startPurchase({ purchaseId }) {
|
|
79
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
80
|
-
_chunkPO6YSB4Qcjs.interactionTypes.purchase.started,
|
|
81
|
-
_viem.pad.call(void 0, purchaseId, { size: 32 })
|
|
82
|
-
]);
|
|
83
|
-
return {
|
|
84
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.purchase),
|
|
85
|
-
interactionData
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Encode a complete purchase interaction
|
|
90
|
-
* @param args
|
|
91
|
-
* @param args.purchaseId - The id of the purchase that is being completed.
|
|
92
|
-
* @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
|
|
93
|
-
*/
|
|
94
|
-
completedPurchase({
|
|
95
|
-
purchaseId,
|
|
96
|
-
proof
|
|
97
|
-
}) {
|
|
98
|
-
const innerData = _viem.encodeAbiParameters.call(void 0,
|
|
99
|
-
[{ type: "uint256" }, { type: "bytes32[]" }],
|
|
100
|
-
[BigInt(purchaseId), proof]
|
|
101
|
-
);
|
|
102
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
103
|
-
_chunkPO6YSB4Qcjs.interactionTypes.purchase.completed,
|
|
104
|
-
innerData
|
|
105
|
-
]);
|
|
106
|
-
return {
|
|
107
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.purchase),
|
|
108
|
-
interactionData
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
/**
|
|
112
|
-
* Encode an unsafe complete purchase interaction (when we can't provide the proof)
|
|
113
|
-
* @param args
|
|
114
|
-
* @param args.purchaseId - The id of the purchase that is being completed.
|
|
115
|
-
*/
|
|
116
|
-
unsafeCompletedPurchase({
|
|
117
|
-
purchaseId
|
|
118
|
-
}) {
|
|
119
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
120
|
-
_chunkPO6YSB4Qcjs.interactionTypes.purchase.unsafeCompleted,
|
|
121
|
-
_viem.pad.call(void 0, purchaseId, { size: 32 })
|
|
122
|
-
]);
|
|
123
|
-
return {
|
|
124
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.purchase),
|
|
125
|
-
interactionData
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/interactions/webshopEncoder.ts
|
|
131
|
-
|
|
132
|
-
var WebShopInteractionEncoder = {
|
|
133
|
-
/**
|
|
134
|
-
* Encode an open webshop interaction
|
|
135
|
-
*/
|
|
136
|
-
open() {
|
|
137
|
-
return {
|
|
138
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.webshop),
|
|
139
|
-
interactionData: _chunkPO6YSB4Qcjs.interactionTypes.webshop.open
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// src/interactions/retailEncoder.ts
|
|
145
|
-
|
|
146
|
-
var RetailInteractionEncoder = {
|
|
147
|
-
/**
|
|
148
|
-
* Encode a customer meeting retail interaction
|
|
149
|
-
* @param args
|
|
150
|
-
* @param args.agencyId - The id of the agency that the customer is meeting with
|
|
151
|
-
*
|
|
152
|
-
*/
|
|
153
|
-
customerMeeting({ agencyId }) {
|
|
154
|
-
const interactionData = _viem.concatHex.call(void 0, [
|
|
155
|
-
_chunkPO6YSB4Qcjs.interactionTypes.retail.customerMeeting,
|
|
156
|
-
_viem.pad.call(void 0, agencyId, { size: 32 })
|
|
157
|
-
]);
|
|
158
|
-
return {
|
|
159
|
-
handlerTypeDenominator: _viem.toHex.call(void 0, _chunkPO6YSB4Qcjs.productTypes.retail),
|
|
160
|
-
interactionData
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
exports.PressInteractionEncoder = PressInteractionEncoder; exports.ReferralInteractionEncoder = ReferralInteractionEncoder; exports.PurchaseInteractionEncoder = PurchaseInteractionEncoder; exports.WebShopInteractionEncoder = WebShopInteractionEncoder; exports.RetailInteractionEncoder = RetailInteractionEncoder;
|