@frak-labs/core-sdk 0.0.2 → 0.0.5
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 +65 -63
- package/dist/actions/index.d.cts +11 -13
- package/dist/actions/index.d.ts +11 -13
- package/dist/actions/index.js +42 -53
- package/dist/{chunk-QZL2KCSB.js → chunk-GDH3M5ZC.js} +7 -9
- package/dist/{chunk-NJJQPEEL.cjs → chunk-IVQL5N55.cjs} +62 -67
- package/dist/{chunk-PR3T7O5I.cjs → chunk-PO6YSB4Q.cjs} +15 -10
- package/dist/{chunk-VAINYZSV.js → chunk-RMOFMRZR.js} +48 -39
- package/dist/{chunk-K5SAPMC2.js → chunk-XDZMP74U.js} +37 -56
- package/dist/chunk-ZDGHKI3S.cjs +155 -0
- package/dist/{context-GkNATUkF.d.cts → context-C7RkT8hA.d.cts} +206 -23
- package/dist/{context-B0trlYGx.d.ts → context-CJ5ByAXa.d.ts} +206 -23
- package/dist/index.cjs +238 -68
- package/dist/index.d.cts +49 -63
- package/dist/index.d.ts +49 -63
- package/dist/index.js +164 -52
- package/dist/interactions/index.cjs +26 -13
- package/dist/interactions/index.d.cts +35 -1
- package/dist/interactions/index.d.ts +35 -1
- package/dist/interactions/index.js +1 -13
- package/package.json +14 -5
- package/dist/chunk-RAPLRHQ4.cjs +0 -140
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-CJ5ByAXa.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-CJ5ByAXa.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,43 +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
|
-
};
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
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,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
FrakRpcError,
|
|
6
|
-
InternalError,
|
|
7
|
-
RpcErrorCodes,
|
|
8
|
-
baseIframeProps,
|
|
9
|
-
changeIframeVisibility,
|
|
10
|
-
compressJson,
|
|
11
|
-
createIframe,
|
|
12
|
-
decompressDataAndCheckHash,
|
|
13
|
-
decompressJson,
|
|
14
|
-
hashAndCompressData
|
|
15
|
-
} from "./chunk-K5SAPMC2.js";
|
|
16
|
-
import {
|
|
17
|
-
interactionTypes,
|
|
18
|
-
productTypes,
|
|
19
|
-
productTypesMask
|
|
20
|
-
} from "./chunk-QZL2KCSB.js";
|
|
1
|
+
import { createIframe, FrakRpcError, Deferred, RpcErrorCodes, decompressDataAndCheckHash, hashAndCompressData, InternalError, changeIframeVisibility } from './chunk-XDZMP74U.js';
|
|
2
|
+
export { ClientNotFound, Deferred, FrakContextManager, FrakRpcError, RpcErrorCodes, baseIframeProps, compressJson, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData } from './chunk-XDZMP74U.js';
|
|
3
|
+
import { __publicField } from './chunk-GDH3M5ZC.js';
|
|
4
|
+
export { interactionTypes, productTypes, productTypesMask } from './chunk-GDH3M5ZC.js';
|
|
21
5
|
|
|
22
6
|
// src/utils/constants.ts
|
|
23
7
|
var BACKUP_KEY = "nexus-wallet-backup";
|
|
24
8
|
|
|
9
|
+
// src/clients/DebugInfo.ts
|
|
10
|
+
var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
11
|
+
constructor(config, iframe) {
|
|
12
|
+
__publicField(this, "config");
|
|
13
|
+
__publicField(this, "iframe");
|
|
14
|
+
__publicField(this, "isSetupDone", false);
|
|
15
|
+
__publicField(this, "lastResponse", null);
|
|
16
|
+
__publicField(this, "lastRequest", null);
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.iframe = iframe;
|
|
19
|
+
this.lastRequest = null;
|
|
20
|
+
this.lastResponse = null;
|
|
21
|
+
}
|
|
22
|
+
// Update communication logs
|
|
23
|
+
setLastResponse(event) {
|
|
24
|
+
this.lastResponse = {
|
|
25
|
+
event: event.data,
|
|
26
|
+
origin: event.origin,
|
|
27
|
+
timestamp: Date.now()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
setLastRequest(event, target) {
|
|
31
|
+
this.lastRequest = { event, target, timestamp: Date.now() };
|
|
32
|
+
}
|
|
33
|
+
// Update connection status
|
|
34
|
+
updateSetupStatus(status) {
|
|
35
|
+
this.isSetupDone = status;
|
|
36
|
+
}
|
|
37
|
+
base64Encode(data) {
|
|
38
|
+
try {
|
|
39
|
+
return btoa(JSON.stringify(data));
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.warn("Failed to encode debug data", err);
|
|
42
|
+
return btoa("Failed to encode data");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extract information from the iframe status
|
|
47
|
+
*/
|
|
48
|
+
getIframeStatus() {
|
|
49
|
+
var _a;
|
|
50
|
+
if (!this.iframe) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
loading: this.iframe.hasAttribute("loading"),
|
|
55
|
+
url: this.iframe.src,
|
|
56
|
+
readyState: ((_a = this.iframe.contentDocument) == null ? undefined : _a.readyState) ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
|
|
57
|
+
contentWindow: !!this.iframe.contentWindow,
|
|
58
|
+
isConnected: this.iframe.isConnected
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
getNavigatorInfo() {
|
|
62
|
+
if (!navigator) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
userAgent: navigator.userAgent,
|
|
67
|
+
language: navigator.language,
|
|
68
|
+
onLine: navigator.onLine,
|
|
69
|
+
screenWidth: window.screen.width,
|
|
70
|
+
screenHeight: window.screen.height,
|
|
71
|
+
pixelRatio: window.devicePixelRatio
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
gatherDebugInfo(error) {
|
|
75
|
+
const iframeStatus = this.getIframeStatus();
|
|
76
|
+
const navigatorInfo = this.getNavigatorInfo();
|
|
77
|
+
let formattedError = "Unknown";
|
|
78
|
+
if (error instanceof FrakRpcError) {
|
|
79
|
+
formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
|
|
80
|
+
} else if (error instanceof Error) {
|
|
81
|
+
formattedError = error.message;
|
|
82
|
+
} else if (typeof error === "string") {
|
|
83
|
+
formattedError = error;
|
|
84
|
+
}
|
|
85
|
+
const debugInfo = {
|
|
86
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
87
|
+
encodedUrl: btoa(window.location.href),
|
|
88
|
+
encodedConfig: this.config ? this.base64Encode(this.config) : "no-config",
|
|
89
|
+
navigatorInfo: navigatorInfo ? this.base64Encode(navigatorInfo) : "no-navigator",
|
|
90
|
+
iframeStatus: iframeStatus ? this.base64Encode(iframeStatus) : "not-iframe",
|
|
91
|
+
lastRequest: this.lastRequest ? this.base64Encode(this.lastRequest) : "No Frak request logged",
|
|
92
|
+
lastResponse: this.lastResponse ? this.base64Encode(this.lastResponse) : "No Frak response logged",
|
|
93
|
+
clientStatus: this.isSetupDone ? "setup" : "not-setup",
|
|
94
|
+
error: formattedError
|
|
95
|
+
};
|
|
96
|
+
return debugInfo;
|
|
97
|
+
}
|
|
98
|
+
static empty() {
|
|
99
|
+
return new _DebugInfoGatherer();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Format Frak debug information
|
|
103
|
+
*/
|
|
104
|
+
formatDebugInfo(error) {
|
|
105
|
+
const debugInfo = this.gatherDebugInfo(error);
|
|
106
|
+
return `
|
|
107
|
+
Debug Information:
|
|
108
|
+
-----------------
|
|
109
|
+
Timestamp: ${debugInfo.timestamp}
|
|
110
|
+
URL: ${debugInfo.encodedUrl}
|
|
111
|
+
Config: ${debugInfo.encodedConfig}
|
|
112
|
+
Navigator Info: ${debugInfo.navigatorInfo}
|
|
113
|
+
IFrame Status: ${debugInfo.iframeStatus}
|
|
114
|
+
Last Request: ${debugInfo.lastRequest}
|
|
115
|
+
Last Response: ${debugInfo.lastResponse}
|
|
116
|
+
Client Status: ${debugInfo.clientStatus}
|
|
117
|
+
Error: ${debugInfo.error}
|
|
118
|
+
`.trim();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
25
122
|
// src/clients/transports/iframeChannelManager.ts
|
|
26
123
|
function createIFrameChannelManager() {
|
|
27
124
|
const channels = /* @__PURE__ */ new Map();
|
|
@@ -44,6 +141,7 @@ function createIFrameLifecycleManager({
|
|
|
44
141
|
}) {
|
|
45
142
|
const isConnectedDeferred = new Deferred();
|
|
46
143
|
const handler = async (messageEvent) => {
|
|
144
|
+
var _a;
|
|
47
145
|
switch (messageEvent.iframeLifecycle) {
|
|
48
146
|
// Resolve the isConnected promise
|
|
49
147
|
case "connected":
|
|
@@ -69,6 +167,23 @@ function createIFrameLifecycleManager({
|
|
|
69
167
|
isVisible: messageEvent.iframeLifecycle === "show"
|
|
70
168
|
});
|
|
71
169
|
break;
|
|
170
|
+
// Handshake handling
|
|
171
|
+
case "handshake": {
|
|
172
|
+
console.log("Received handshake event", {
|
|
173
|
+
token: messageEvent.data.token
|
|
174
|
+
});
|
|
175
|
+
(_a = iframe.contentWindow) == null ? undefined : _a.postMessage(
|
|
176
|
+
{
|
|
177
|
+
clientLifecycle: "handshake-response",
|
|
178
|
+
data: {
|
|
179
|
+
token: messageEvent.data.token,
|
|
180
|
+
currentUrl: window.location.href
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"*"
|
|
184
|
+
);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
72
187
|
}
|
|
73
188
|
};
|
|
74
189
|
return {
|
|
@@ -82,7 +197,8 @@ function createIFrameMessageHandler({
|
|
|
82
197
|
frakWalletUrl,
|
|
83
198
|
iframe,
|
|
84
199
|
channelManager,
|
|
85
|
-
iframeLifecycleManager
|
|
200
|
+
iframeLifecycleManager,
|
|
201
|
+
debugInfo
|
|
86
202
|
}) {
|
|
87
203
|
if (typeof window === "undefined") {
|
|
88
204
|
throw new FrakRpcError(
|
|
@@ -97,16 +213,22 @@ function createIFrameMessageHandler({
|
|
|
97
213
|
);
|
|
98
214
|
}
|
|
99
215
|
const contentWindow = iframe.contentWindow;
|
|
100
|
-
|
|
101
|
-
if (!
|
|
216
|
+
async function msgHandler(event) {
|
|
217
|
+
if (!event.origin) {
|
|
102
218
|
return;
|
|
103
219
|
}
|
|
104
|
-
|
|
220
|
+
try {
|
|
221
|
+
if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
} catch (e) {
|
|
225
|
+
console.log("Unable to check frak msg origin", e);
|
|
105
226
|
return;
|
|
106
227
|
}
|
|
107
228
|
if (typeof event.data !== "object") {
|
|
108
229
|
return;
|
|
109
230
|
}
|
|
231
|
+
debugInfo.setLastResponse(event);
|
|
110
232
|
if ("iframeLifecycle" in event.data) {
|
|
111
233
|
await iframeLifecycleManager.handleEvent(event.data);
|
|
112
234
|
return;
|
|
@@ -123,16 +245,17 @@ function createIFrameMessageHandler({
|
|
|
123
245
|
return;
|
|
124
246
|
}
|
|
125
247
|
await resolver(event.data);
|
|
126
|
-
}
|
|
248
|
+
}
|
|
127
249
|
window.addEventListener("message", msgHandler);
|
|
128
|
-
|
|
250
|
+
function sendEvent(message) {
|
|
129
251
|
contentWindow.postMessage(message, {
|
|
130
252
|
targetOrigin: frakWalletUrl
|
|
131
253
|
});
|
|
132
|
-
|
|
133
|
-
|
|
254
|
+
debugInfo.setLastRequest(message, frakWalletUrl);
|
|
255
|
+
}
|
|
256
|
+
function cleanup() {
|
|
134
257
|
window.removeEventListener("message", msgHandler);
|
|
135
|
-
}
|
|
258
|
+
}
|
|
136
259
|
return {
|
|
137
260
|
sendEvent,
|
|
138
261
|
cleanup
|
|
@@ -144,13 +267,16 @@ function createIFrameFrakClient({
|
|
|
144
267
|
config,
|
|
145
268
|
iframe
|
|
146
269
|
}) {
|
|
270
|
+
var _a;
|
|
147
271
|
const channelManager = createIFrameChannelManager();
|
|
148
272
|
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
273
|
+
const debugInfo = new DebugInfoGatherer(config, iframe);
|
|
149
274
|
const messageHandler = createIFrameMessageHandler({
|
|
150
|
-
frakWalletUrl: config
|
|
275
|
+
frakWalletUrl: (_a = config == null ? undefined : config.walletUrl) != null ? _a : "https://wallet.frak.id",
|
|
151
276
|
iframe,
|
|
152
277
|
channelManager,
|
|
153
|
-
iframeLifecycleManager: lifecycleManager
|
|
278
|
+
iframeLifecycleManager: lifecycleManager,
|
|
279
|
+
debugInfo
|
|
154
280
|
});
|
|
155
281
|
const request = async (args) => {
|
|
156
282
|
const isConnected = await lifecycleManager.isConnected;
|
|
@@ -162,13 +288,14 @@ function createIFrameFrakClient({
|
|
|
162
288
|
}
|
|
163
289
|
const result = new Deferred();
|
|
164
290
|
const channelId = channelManager.createChannel(async (message) => {
|
|
291
|
+
var _a2;
|
|
165
292
|
const decompressed = await decompressDataAndCheckHash(message.data);
|
|
166
293
|
if (decompressed.error) {
|
|
167
294
|
result.reject(
|
|
168
295
|
new FrakRpcError(
|
|
169
296
|
decompressed.error.code,
|
|
170
297
|
decompressed.error.message,
|
|
171
|
-
decompressed.error
|
|
298
|
+
(_a2 = decompressed.error) == null ? undefined : _a2.data
|
|
172
299
|
)
|
|
173
300
|
);
|
|
174
301
|
} else {
|
|
@@ -218,9 +345,10 @@ function createIFrameFrakClient({
|
|
|
218
345
|
config,
|
|
219
346
|
messageHandler,
|
|
220
347
|
lifecycleManager
|
|
221
|
-
});
|
|
348
|
+
}).then(() => debugInfo.updateSetupStatus(true));
|
|
222
349
|
return {
|
|
223
350
|
config,
|
|
351
|
+
debugInfo,
|
|
224
352
|
waitForConnection: lifecycleManager.isConnected,
|
|
225
353
|
waitForSetup,
|
|
226
354
|
request,
|
|
@@ -234,7 +362,7 @@ function setupHeartbeat(messageHandler, lifecycleManager) {
|
|
|
234
362
|
let heartbeatInterval;
|
|
235
363
|
let timeoutId;
|
|
236
364
|
const sendHeartbeat = () => messageHandler.sendEvent({
|
|
237
|
-
|
|
365
|
+
clientLifecycle: "heartbeat"
|
|
238
366
|
});
|
|
239
367
|
async function startHeartbeat() {
|
|
240
368
|
sendHeartbeat();
|
|
@@ -306,21 +434,5 @@ async function setupClient({
|
|
|
306
434
|
}
|
|
307
435
|
return client;
|
|
308
436
|
}
|
|
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
|
-
};
|
|
437
|
+
|
|
438
|
+
export { DebugInfoGatherer, createIFrameFrakClient, setupClient };
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkZDGHKI3S_cjs = require('../chunk-ZDGHKI3S.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "PressInteractionEncoder", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkZDGHKI3S_cjs.PressInteractionEncoder; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "PurchaseInteractionEncoder", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkZDGHKI3S_cjs.PurchaseInteractionEncoder; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "ReferralInteractionEncoder", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkZDGHKI3S_cjs.ReferralInteractionEncoder; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "RetailInteractionEncoder", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkZDGHKI3S_cjs.RetailInteractionEncoder; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "WebShopInteractionEncoder", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkZDGHKI3S_cjs.WebShopInteractionEncoder; }
|
|
26
|
+
});
|
|
@@ -114,6 +114,14 @@ declare const PurchaseInteractionEncoder: {
|
|
|
114
114
|
purchaseId: Hex;
|
|
115
115
|
proof: Hex[];
|
|
116
116
|
}): PreparedInteraction;
|
|
117
|
+
/**
|
|
118
|
+
* Encode an unsafe complete purchase interaction (when we can't provide the proof)
|
|
119
|
+
* @param args
|
|
120
|
+
* @param args.purchaseId - The id of the purchase that is being completed.
|
|
121
|
+
*/
|
|
122
|
+
unsafeCompletedPurchase({ purchaseId, }: {
|
|
123
|
+
purchaseId: Hex;
|
|
124
|
+
}): PreparedInteraction;
|
|
117
125
|
};
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -137,4 +145,30 @@ declare const WebShopInteractionEncoder: {
|
|
|
137
145
|
open(): PreparedInteraction;
|
|
138
146
|
};
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Retail interactions allow you to track user activities on your retails products.
|
|
150
|
+
*
|
|
151
|
+
* :::info
|
|
152
|
+
* To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
|
|
153
|
+
* :::
|
|
154
|
+
*
|
|
155
|
+
* @description Encode retail related user interactions
|
|
156
|
+
*
|
|
157
|
+
* @group Interactions Encoder
|
|
158
|
+
*
|
|
159
|
+
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
|
|
160
|
+
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
|
|
161
|
+
*/
|
|
162
|
+
declare const RetailInteractionEncoder: {
|
|
163
|
+
/**
|
|
164
|
+
* Encode a customer meeting retail interaction
|
|
165
|
+
* @param args
|
|
166
|
+
* @param args.agencyId - The id of the agency that the customer is meeting with
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
169
|
+
customerMeeting({ agencyId }: {
|
|
170
|
+
agencyId: Hex;
|
|
171
|
+
}): PreparedInteraction;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
|
|
@@ -114,6 +114,14 @@ declare const PurchaseInteractionEncoder: {
|
|
|
114
114
|
purchaseId: Hex;
|
|
115
115
|
proof: Hex[];
|
|
116
116
|
}): PreparedInteraction;
|
|
117
|
+
/**
|
|
118
|
+
* Encode an unsafe complete purchase interaction (when we can't provide the proof)
|
|
119
|
+
* @param args
|
|
120
|
+
* @param args.purchaseId - The id of the purchase that is being completed.
|
|
121
|
+
*/
|
|
122
|
+
unsafeCompletedPurchase({ purchaseId, }: {
|
|
123
|
+
purchaseId: Hex;
|
|
124
|
+
}): PreparedInteraction;
|
|
117
125
|
};
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -137,4 +145,30 @@ declare const WebShopInteractionEncoder: {
|
|
|
137
145
|
open(): PreparedInteraction;
|
|
138
146
|
};
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Retail interactions allow you to track user activities on your retails products.
|
|
150
|
+
*
|
|
151
|
+
* :::info
|
|
152
|
+
* To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
|
|
153
|
+
* :::
|
|
154
|
+
*
|
|
155
|
+
* @description Encode retail related user interactions
|
|
156
|
+
*
|
|
157
|
+
* @group Interactions Encoder
|
|
158
|
+
*
|
|
159
|
+
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
|
|
160
|
+
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
|
|
161
|
+
*/
|
|
162
|
+
declare const RetailInteractionEncoder: {
|
|
163
|
+
/**
|
|
164
|
+
* Encode a customer meeting retail interaction
|
|
165
|
+
* @param args
|
|
166
|
+
* @param args.agencyId - The id of the agency that the customer is meeting with
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
169
|
+
customerMeeting({ agencyId }: {
|
|
170
|
+
agencyId: Hex;
|
|
171
|
+
}): PreparedInteraction;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
PressInteractionEncoder,
|
|
3
|
-
PurchaseInteractionEncoder,
|
|
4
|
-
ReferralInteractionEncoder,
|
|
5
|
-
WebShopInteractionEncoder
|
|
6
|
-
} from "../chunk-VAINYZSV.js";
|
|
7
|
-
import "../chunk-QZL2KCSB.js";
|
|
8
|
-
export {
|
|
9
|
-
PressInteractionEncoder,
|
|
10
|
-
PurchaseInteractionEncoder,
|
|
11
|
-
ReferralInteractionEncoder,
|
|
12
|
-
WebShopInteractionEncoder
|
|
13
|
-
};
|
|
1
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder } from '../chunk-RMOFMRZR.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.5",
|
|
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",
|
|
@@ -77,7 +77,9 @@
|
|
|
77
77
|
"build": "tsup && bun run check-exports",
|
|
78
78
|
"build:watch": "tsup --watch",
|
|
79
79
|
"check-exports": "attw --pack --profile node16 .",
|
|
80
|
-
"typecheck": "tsc --noEmit"
|
|
80
|
+
"typecheck": "tsc --noEmit",
|
|
81
|
+
"prepublish": "bun run lint && bun run build",
|
|
82
|
+
"publish": "bun publish"
|
|
81
83
|
},
|
|
82
84
|
"peerDependencies": {
|
|
83
85
|
"viem": "^2.x"
|
|
@@ -87,9 +89,16 @@
|
|
|
87
89
|
"js-sha256": "^0.11.0"
|
|
88
90
|
},
|
|
89
91
|
"devDependencies": {
|
|
90
|
-
"@arethetypeswrong/cli": "^0.17.
|
|
92
|
+
"@arethetypeswrong/cli": "^0.17.3",
|
|
91
93
|
"@types/node": "^22",
|
|
92
94
|
"tsup": "^8.3.5",
|
|
93
95
|
"typescript": "^5"
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
+
},
|
|
97
|
+
"browserslist": [
|
|
98
|
+
"chrome 67",
|
|
99
|
+
"edge 79",
|
|
100
|
+
"firefox 68",
|
|
101
|
+
"opera 54",
|
|
102
|
+
"safari 14"
|
|
103
|
+
]
|
|
104
|
+
}
|