@frak-labs/nexus-sdk 0.0.14 → 0.0.16

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 (50) hide show
  1. package/README.md +4 -4
  2. package/dist/FrakContext-LbQht1ep.d.cts +10 -0
  3. package/dist/FrakContext-LbQht1ep.d.ts +10 -0
  4. package/dist/bundle/bundle.js +21 -0
  5. package/dist/chunk-A3XYA7S7.cjs +114 -0
  6. package/dist/{chunk-5LZQXBFJ.js → chunk-AHUMDUJC.js} +12 -196
  7. package/dist/chunk-D77BTQYS.js +210 -0
  8. package/dist/chunk-DAGCBEBQ.cjs +243 -0
  9. package/dist/chunk-FO2GFD5C.cjs +210 -0
  10. package/dist/chunk-FYMOOHMT.js +254 -0
  11. package/dist/chunk-HY6YATLS.js +53 -0
  12. package/dist/chunk-J655X6YR.cjs +254 -0
  13. package/dist/chunk-TIKEZMSD.js +114 -0
  14. package/dist/chunk-UFJ7W6CQ.cjs +53 -0
  15. package/dist/{client-DJd7-ajw.d.ts → client-ALy_TEwJ.d.ts} +34 -11
  16. package/dist/{client-DXITs1Kf.d.cts → client-DaEox5q4.d.cts} +34 -11
  17. package/dist/core/actions/index.cjs +11 -3
  18. package/dist/core/actions/index.d.cts +28 -5
  19. package/dist/core/actions/index.d.ts +28 -5
  20. package/dist/core/actions/index.js +10 -2
  21. package/dist/core/index.cjs +15 -4
  22. package/dist/core/index.d.cts +98 -4
  23. package/dist/core/index.d.ts +98 -4
  24. package/dist/core/index.js +15 -4
  25. package/dist/core/interactions/index.cjs +3 -4
  26. package/dist/core/interactions/index.d.cts +27 -15
  27. package/dist/core/interactions/index.d.ts +27 -15
  28. package/dist/core/interactions/index.js +8 -9
  29. package/dist/{error-C4Zm5nQe.d.cts → error-Dflr3G5x.d.cts} +1 -1
  30. package/dist/{error-C4Zm5nQe.d.ts → error-Dflr3G5x.d.ts} +1 -1
  31. package/dist/react/index.cjs +79 -155
  32. package/dist/react/index.d.cts +4 -5
  33. package/dist/react/index.d.ts +4 -5
  34. package/dist/react/index.js +78 -154
  35. package/dist/{sendTransaction-fLvpfqaQ.d.ts → sendTransaction-BOd-pvXr.d.ts} +2 -2
  36. package/dist/{sendTransaction-C19oCc6X.d.cts → sendTransaction-MhdJPTWd.d.cts} +2 -2
  37. package/package.json +6 -6
  38. package/dist/chunk-22T2NHQK.js +0 -22
  39. package/dist/chunk-5SGDBU5S.cjs +0 -427
  40. package/dist/chunk-AANA3LEO.cjs +0 -22
  41. package/dist/chunk-ETV4XYOV.cjs +0 -7
  42. package/dist/chunk-IH3QWPWT.js +0 -72
  43. package/dist/chunk-PKBMQBKP.js +0 -7
  44. package/dist/chunk-PURWUKEM.cjs +0 -72
  45. package/dist/chunk-S223FMEJ.js +0 -86
  46. package/dist/chunk-UOEVM7TR.cjs +0 -86
  47. package/dist/index.cjs +0 -1
  48. package/dist/index.d.cts +0 -2
  49. package/dist/index.d.ts +0 -2
  50. package/dist/index.js +0 -0
@@ -0,0 +1,254 @@
1
+ import {
2
+ __publicField
3
+ } from "./chunk-HY6YATLS.js";
4
+
5
+ // src/core/types/rpc/error.ts
6
+ var FrakRpcError = class extends Error {
7
+ constructor(code, message, data) {
8
+ super(message);
9
+ this.code = code;
10
+ this.data = data;
11
+ }
12
+ };
13
+ var InternalError = class extends FrakRpcError {
14
+ constructor(message) {
15
+ super(RpcErrorCodes.internalError, message);
16
+ }
17
+ };
18
+ var ClientNotFound = class extends FrakRpcError {
19
+ constructor() {
20
+ super(RpcErrorCodes.clientNotConnected, "Client not found");
21
+ }
22
+ };
23
+ var RpcErrorCodes = {
24
+ // Standard JSON-RPC 2.0 errors
25
+ parseError: -32700,
26
+ invalidRequest: -32600,
27
+ methodNotFound: -32601,
28
+ invalidParams: -32602,
29
+ internalError: -32603,
30
+ serverError: -32e3,
31
+ // Frak specific errors (from -32001 to -32099)
32
+ clientNotConnected: -32001,
33
+ configError: -32002,
34
+ corruptedResponse: -32003,
35
+ clientAborted: -32004,
36
+ walletNotConnected: -32005,
37
+ serverErrorForInteractionDelegation: -32006
38
+ };
39
+
40
+ // src/core/utils/Deferred.ts
41
+ var Deferred = class {
42
+ constructor() {
43
+ __publicField(this, "_promise");
44
+ __publicField(this, "_resolve");
45
+ __publicField(this, "_reject");
46
+ __publicField(this, "resolve", (value) => {
47
+ this._resolve?.(value);
48
+ });
49
+ __publicField(this, "reject", (reason) => {
50
+ this._reject?.(reason);
51
+ });
52
+ this._promise = new Promise((resolve, reject) => {
53
+ this._resolve = resolve;
54
+ this._reject = reject;
55
+ });
56
+ }
57
+ get promise() {
58
+ return this._promise;
59
+ }
60
+ };
61
+
62
+ // src/core/utils/compression/compress.ts
63
+ import { compressToBase64 } from "async-lz-string";
64
+ import { sha256 } from "js-sha256";
65
+ async function hashAndCompressData(data) {
66
+ const validationHash = sha256(JSON.stringify(data));
67
+ const hashProtectedData = {
68
+ ...data,
69
+ validationHash
70
+ };
71
+ const compressed = await compressJson(hashProtectedData);
72
+ const compressedHash = sha256(compressed);
73
+ return {
74
+ compressed,
75
+ compressedHash
76
+ };
77
+ }
78
+ async function compressJson(data) {
79
+ return compressToBase64(JSON.stringify(data));
80
+ }
81
+
82
+ // src/core/utils/compression/decompress.ts
83
+ import { decompressFromBase64 } from "async-lz-string";
84
+ import { sha256 as sha2562 } from "js-sha256";
85
+ async function decompressDataAndCheckHash(compressedData) {
86
+ if (!(compressedData?.compressed && compressedData?.compressedHash)) {
87
+ throw new FrakRpcError(
88
+ RpcErrorCodes.corruptedResponse,
89
+ "Missing compressed data"
90
+ );
91
+ }
92
+ const parsedData = await decompressJson(
93
+ compressedData.compressed
94
+ );
95
+ if (!parsedData) {
96
+ throw new FrakRpcError(
97
+ RpcErrorCodes.corruptedResponse,
98
+ "Invalid compressed data"
99
+ );
100
+ }
101
+ if (!parsedData?.validationHash) {
102
+ throw new FrakRpcError(
103
+ RpcErrorCodes.corruptedResponse,
104
+ "Missing validation hash"
105
+ );
106
+ }
107
+ const expectedCompressedHash = sha2562(compressedData.compressed);
108
+ if (expectedCompressedHash !== compressedData.compressedHash) {
109
+ throw new FrakRpcError(
110
+ RpcErrorCodes.corruptedResponse,
111
+ "Invalid compressed hash"
112
+ );
113
+ }
114
+ const { validationHash: _, ...rawResultData } = parsedData;
115
+ const expectedValidationHash = sha2562(JSON.stringify(rawResultData));
116
+ if (expectedValidationHash !== parsedData.validationHash) {
117
+ throw new FrakRpcError(
118
+ RpcErrorCodes.corruptedResponse,
119
+ "Invalid data validation hash"
120
+ );
121
+ }
122
+ return parsedData;
123
+ }
124
+ async function decompressJson(data) {
125
+ const decompressed = await decompressFromBase64(data);
126
+ try {
127
+ return JSON.parse(decompressed);
128
+ } catch (e) {
129
+ console.error("Invalid compressed data", e);
130
+ return null;
131
+ }
132
+ }
133
+
134
+ // src/core/utils/iframeHelper.ts
135
+ var baseIframeProps = {
136
+ id: "nexus-wallet",
137
+ name: "nexus-wallet",
138
+ allow: "publickey-credentials-get *; clipboard-write; web-share *",
139
+ style: {
140
+ width: "0",
141
+ height: "0",
142
+ border: "0",
143
+ position: "absolute",
144
+ zIndex: 1e3,
145
+ top: "-1000px",
146
+ left: "-1000px"
147
+ }
148
+ };
149
+ function createIframe({
150
+ walletBaseUrl
151
+ }) {
152
+ const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
153
+ if (alreadyCreatedIFrame) {
154
+ return Promise.resolve(alreadyCreatedIFrame);
155
+ }
156
+ const iframe = document.createElement("iframe");
157
+ iframe.id = baseIframeProps.id;
158
+ iframe.name = baseIframeProps.name;
159
+ iframe.allow = baseIframeProps.allow;
160
+ iframe.style.zIndex = baseIframeProps.style.zIndex.toString();
161
+ changeIframeVisibility({ iframe, isVisible: false });
162
+ document.body.appendChild(iframe);
163
+ return new Promise((resolve) => {
164
+ iframe?.addEventListener("load", () => resolve(iframe));
165
+ iframe.src = `${walletBaseUrl}/listener`;
166
+ });
167
+ }
168
+ function changeIframeVisibility({
169
+ iframe,
170
+ isVisible
171
+ }) {
172
+ if (!isVisible) {
173
+ iframe.style.width = "0";
174
+ iframe.style.height = "0";
175
+ iframe.style.border = "0";
176
+ iframe.style.position = "fixed";
177
+ iframe.style.top = "-1000px";
178
+ iframe.style.left = "-1000px";
179
+ return;
180
+ }
181
+ iframe.style.position = "fixed";
182
+ iframe.style.top = "0";
183
+ iframe.style.left = "0";
184
+ iframe.style.width = "100%";
185
+ iframe.style.height = "100%";
186
+ iframe.style.pointerEvents = "auto";
187
+ }
188
+
189
+ // src/core/utils/FrakContext.ts
190
+ var contextKey = "fCtx";
191
+ async function parse({ url }) {
192
+ if (!url) return null;
193
+ const urlObj = new URL(url);
194
+ const nexusContext = urlObj.searchParams.get(contextKey);
195
+ if (!nexusContext) return null;
196
+ const parsedContext = await decompressJson(nexusContext);
197
+ if (!parsedContext) return null;
198
+ return parsedContext;
199
+ }
200
+ async function update({
201
+ url,
202
+ context
203
+ }) {
204
+ if (!url) return null;
205
+ const currentContext = await parse({ url });
206
+ const mergedContext = currentContext ? { ...currentContext, ...context } : context;
207
+ const compressedContext = await compressJson(mergedContext);
208
+ if (!compressedContext) return;
209
+ const urlObj = new URL(url);
210
+ urlObj.searchParams.set(contextKey, compressedContext);
211
+ return urlObj.toString();
212
+ }
213
+ function remove(url) {
214
+ const urlObj = new URL(url);
215
+ urlObj.searchParams.delete(contextKey);
216
+ return urlObj.toString();
217
+ }
218
+ async function replaceUrl({
219
+ url,
220
+ context
221
+ }) {
222
+ if (!window.location?.href || typeof window === "undefined") {
223
+ console.error("No window found, can't update context");
224
+ return;
225
+ }
226
+ const newUrl = await update({
227
+ url,
228
+ context
229
+ });
230
+ if (!newUrl) return;
231
+ window.history.replaceState(null, "", newUrl.toString());
232
+ }
233
+ var FrakContextManager = {
234
+ parse,
235
+ update,
236
+ remove,
237
+ replaceUrl
238
+ };
239
+
240
+ export {
241
+ FrakRpcError,
242
+ InternalError,
243
+ ClientNotFound,
244
+ RpcErrorCodes,
245
+ Deferred,
246
+ hashAndCompressData,
247
+ compressJson,
248
+ decompressDataAndCheckHash,
249
+ decompressJson,
250
+ baseIframeProps,
251
+ createIframe,
252
+ changeIframeVisibility,
253
+ FrakContextManager
254
+ };
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/core/constants/productTypes.ts
6
+ var productTypes = {
7
+ // content type
8
+ dapp: 1,
9
+ press: 2,
10
+ webshop: 3,
11
+ // feature type
12
+ referral: 30,
13
+ purchase: 31
14
+ };
15
+ var productTypesMask = Object.entries(
16
+ productTypes
17
+ ).reduce(
18
+ (acc, [key, value]) => {
19
+ acc[key] = BigInt(1) << BigInt(value);
20
+ return acc;
21
+ },
22
+ {}
23
+ );
24
+
25
+ // src/core/constants/interactionTypes.ts
26
+ var interactionTypes = {
27
+ press: {
28
+ openArticle: "0xc0a24ffb",
29
+ readArticle: "0xd5bd0fbe"
30
+ },
31
+ dapp: {
32
+ proofVerifiableStorageUpdate: "0x2ab2aeef",
33
+ callableVerifiableStorageUpdate: "0xa07da986"
34
+ },
35
+ webshop: {
36
+ open: "0xb311798f"
37
+ },
38
+ referral: {
39
+ referred: "0x010cc3b9",
40
+ createLink: "0xb2c0f17c"
41
+ },
42
+ purchase: {
43
+ started: "0xd87e90c3",
44
+ completed: "0x8403aeb4"
45
+ }
46
+ };
47
+
48
+ export {
49
+ __publicField,
50
+ productTypes,
51
+ productTypesMask,
52
+ interactionTypes
53
+ };
@@ -0,0 +1,254 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkUFJ7W6CQcjs = require('./chunk-UFJ7W6CQ.cjs');
4
+
5
+ // src/core/types/rpc/error.ts
6
+ var FrakRpcError = class extends Error {
7
+ constructor(code, message, data) {
8
+ super(message);
9
+ this.code = code;
10
+ this.data = data;
11
+ }
12
+ };
13
+ var InternalError = class extends FrakRpcError {
14
+ constructor(message) {
15
+ super(RpcErrorCodes.internalError, message);
16
+ }
17
+ };
18
+ var ClientNotFound = class extends FrakRpcError {
19
+ constructor() {
20
+ super(RpcErrorCodes.clientNotConnected, "Client not found");
21
+ }
22
+ };
23
+ var RpcErrorCodes = {
24
+ // Standard JSON-RPC 2.0 errors
25
+ parseError: -32700,
26
+ invalidRequest: -32600,
27
+ methodNotFound: -32601,
28
+ invalidParams: -32602,
29
+ internalError: -32603,
30
+ serverError: -32e3,
31
+ // Frak specific errors (from -32001 to -32099)
32
+ clientNotConnected: -32001,
33
+ configError: -32002,
34
+ corruptedResponse: -32003,
35
+ clientAborted: -32004,
36
+ walletNotConnected: -32005,
37
+ serverErrorForInteractionDelegation: -32006
38
+ };
39
+
40
+ // src/core/utils/Deferred.ts
41
+ var Deferred = class {
42
+ constructor() {
43
+ _chunkUFJ7W6CQcjs.__publicField.call(void 0, this, "_promise");
44
+ _chunkUFJ7W6CQcjs.__publicField.call(void 0, this, "_resolve");
45
+ _chunkUFJ7W6CQcjs.__publicField.call(void 0, this, "_reject");
46
+ _chunkUFJ7W6CQcjs.__publicField.call(void 0, this, "resolve", (value) => {
47
+ _optionalChain([this, 'access', _2 => _2._resolve, 'optionalCall', _3 => _3(value)]);
48
+ });
49
+ _chunkUFJ7W6CQcjs.__publicField.call(void 0, this, "reject", (reason) => {
50
+ _optionalChain([this, 'access', _4 => _4._reject, 'optionalCall', _5 => _5(reason)]);
51
+ });
52
+ this._promise = new Promise((resolve, reject) => {
53
+ this._resolve = resolve;
54
+ this._reject = reject;
55
+ });
56
+ }
57
+ get promise() {
58
+ return this._promise;
59
+ }
60
+ };
61
+
62
+ // src/core/utils/compression/compress.ts
63
+ var _asynclzstring = require('async-lz-string');
64
+ var _jssha256 = require('js-sha256');
65
+ async function hashAndCompressData(data) {
66
+ const validationHash = _jssha256.sha256.call(void 0, JSON.stringify(data));
67
+ const hashProtectedData = {
68
+ ...data,
69
+ validationHash
70
+ };
71
+ const compressed = await compressJson(hashProtectedData);
72
+ const compressedHash = _jssha256.sha256.call(void 0, compressed);
73
+ return {
74
+ compressed,
75
+ compressedHash
76
+ };
77
+ }
78
+ async function compressJson(data) {
79
+ return _asynclzstring.compressToBase64.call(void 0, JSON.stringify(data));
80
+ }
81
+
82
+ // src/core/utils/compression/decompress.ts
83
+
84
+
85
+ async function decompressDataAndCheckHash(compressedData) {
86
+ if (!(_optionalChain([compressedData, 'optionalAccess', _6 => _6.compressed]) && _optionalChain([compressedData, 'optionalAccess', _7 => _7.compressedHash]))) {
87
+ throw new FrakRpcError(
88
+ RpcErrorCodes.corruptedResponse,
89
+ "Missing compressed data"
90
+ );
91
+ }
92
+ const parsedData = await decompressJson(
93
+ compressedData.compressed
94
+ );
95
+ if (!parsedData) {
96
+ throw new FrakRpcError(
97
+ RpcErrorCodes.corruptedResponse,
98
+ "Invalid compressed data"
99
+ );
100
+ }
101
+ if (!_optionalChain([parsedData, 'optionalAccess', _8 => _8.validationHash])) {
102
+ throw new FrakRpcError(
103
+ RpcErrorCodes.corruptedResponse,
104
+ "Missing validation hash"
105
+ );
106
+ }
107
+ const expectedCompressedHash = _jssha256.sha256.call(void 0, compressedData.compressed);
108
+ if (expectedCompressedHash !== compressedData.compressedHash) {
109
+ throw new FrakRpcError(
110
+ RpcErrorCodes.corruptedResponse,
111
+ "Invalid compressed hash"
112
+ );
113
+ }
114
+ const { validationHash: _, ...rawResultData } = parsedData;
115
+ const expectedValidationHash = _jssha256.sha256.call(void 0, JSON.stringify(rawResultData));
116
+ if (expectedValidationHash !== parsedData.validationHash) {
117
+ throw new FrakRpcError(
118
+ RpcErrorCodes.corruptedResponse,
119
+ "Invalid data validation hash"
120
+ );
121
+ }
122
+ return parsedData;
123
+ }
124
+ async function decompressJson(data) {
125
+ const decompressed = await _asynclzstring.decompressFromBase64.call(void 0, data);
126
+ try {
127
+ return JSON.parse(decompressed);
128
+ } catch (e) {
129
+ console.error("Invalid compressed data", e);
130
+ return null;
131
+ }
132
+ }
133
+
134
+ // src/core/utils/iframeHelper.ts
135
+ var baseIframeProps = {
136
+ id: "nexus-wallet",
137
+ name: "nexus-wallet",
138
+ allow: "publickey-credentials-get *; clipboard-write; web-share *",
139
+ style: {
140
+ width: "0",
141
+ height: "0",
142
+ border: "0",
143
+ position: "absolute",
144
+ zIndex: 1e3,
145
+ top: "-1000px",
146
+ left: "-1000px"
147
+ }
148
+ };
149
+ function createIframe({
150
+ walletBaseUrl
151
+ }) {
152
+ const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
153
+ if (alreadyCreatedIFrame) {
154
+ return Promise.resolve(alreadyCreatedIFrame);
155
+ }
156
+ const iframe = document.createElement("iframe");
157
+ iframe.id = baseIframeProps.id;
158
+ iframe.name = baseIframeProps.name;
159
+ iframe.allow = baseIframeProps.allow;
160
+ iframe.style.zIndex = baseIframeProps.style.zIndex.toString();
161
+ changeIframeVisibility({ iframe, isVisible: false });
162
+ document.body.appendChild(iframe);
163
+ return new Promise((resolve) => {
164
+ _optionalChain([iframe, 'optionalAccess', _9 => _9.addEventListener, 'call', _10 => _10("load", () => resolve(iframe))]);
165
+ iframe.src = `${walletBaseUrl}/listener`;
166
+ });
167
+ }
168
+ function changeIframeVisibility({
169
+ iframe,
170
+ isVisible
171
+ }) {
172
+ if (!isVisible) {
173
+ iframe.style.width = "0";
174
+ iframe.style.height = "0";
175
+ iframe.style.border = "0";
176
+ iframe.style.position = "fixed";
177
+ iframe.style.top = "-1000px";
178
+ iframe.style.left = "-1000px";
179
+ return;
180
+ }
181
+ iframe.style.position = "fixed";
182
+ iframe.style.top = "0";
183
+ iframe.style.left = "0";
184
+ iframe.style.width = "100%";
185
+ iframe.style.height = "100%";
186
+ iframe.style.pointerEvents = "auto";
187
+ }
188
+
189
+ // src/core/utils/FrakContext.ts
190
+ var contextKey = "fCtx";
191
+ async function parse({ url }) {
192
+ if (!url) return null;
193
+ const urlObj = new URL(url);
194
+ const nexusContext = urlObj.searchParams.get(contextKey);
195
+ if (!nexusContext) return null;
196
+ const parsedContext = await decompressJson(nexusContext);
197
+ if (!parsedContext) return null;
198
+ return parsedContext;
199
+ }
200
+ async function update({
201
+ url,
202
+ context
203
+ }) {
204
+ if (!url) return null;
205
+ const currentContext = await parse({ url });
206
+ const mergedContext = currentContext ? { ...currentContext, ...context } : context;
207
+ const compressedContext = await compressJson(mergedContext);
208
+ if (!compressedContext) return;
209
+ const urlObj = new URL(url);
210
+ urlObj.searchParams.set(contextKey, compressedContext);
211
+ return urlObj.toString();
212
+ }
213
+ function remove(url) {
214
+ const urlObj = new URL(url);
215
+ urlObj.searchParams.delete(contextKey);
216
+ return urlObj.toString();
217
+ }
218
+ async function replaceUrl({
219
+ url,
220
+ context
221
+ }) {
222
+ if (!_optionalChain([window, 'access', _11 => _11.location, 'optionalAccess', _12 => _12.href]) || typeof window === "undefined") {
223
+ console.error("No window found, can't update context");
224
+ return;
225
+ }
226
+ const newUrl = await update({
227
+ url,
228
+ context
229
+ });
230
+ if (!newUrl) return;
231
+ window.history.replaceState(null, "", newUrl.toString());
232
+ }
233
+ var FrakContextManager = {
234
+ parse,
235
+ update,
236
+ remove,
237
+ replaceUrl
238
+ };
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+ exports.FrakRpcError = FrakRpcError; exports.InternalError = InternalError; exports.ClientNotFound = ClientNotFound; exports.RpcErrorCodes = RpcErrorCodes; exports.Deferred = Deferred; exports.hashAndCompressData = hashAndCompressData; exports.compressJson = compressJson; exports.decompressDataAndCheckHash = decompressDataAndCheckHash; exports.decompressJson = decompressJson; exports.baseIframeProps = baseIframeProps; exports.createIframe = createIframe; exports.changeIframeVisibility = changeIframeVisibility; exports.FrakContextManager = FrakContextManager;
@@ -0,0 +1,114 @@
1
+ import {
2
+ interactionTypes,
3
+ productTypes
4
+ } from "./chunk-HY6YATLS.js";
5
+
6
+ // src/core/interactions/pressEncoder.ts
7
+ import { concatHex, pad, toHex } from "viem";
8
+ function openArticle({ articleId }) {
9
+ const interactionData = concatHex([
10
+ interactionTypes.press.openArticle,
11
+ pad(articleId, { size: 32 })
12
+ ]);
13
+ return {
14
+ handlerTypeDenominator: toHex(productTypes.press),
15
+ interactionData
16
+ };
17
+ }
18
+ function readArticle({ articleId }) {
19
+ const interactionData = concatHex([
20
+ interactionTypes.press.readArticle,
21
+ pad(articleId, { size: 32 })
22
+ ]);
23
+ return {
24
+ handlerTypeDenominator: toHex(productTypes.press),
25
+ interactionData
26
+ };
27
+ }
28
+ var PressInteractionEncoder = {
29
+ openArticle,
30
+ readArticle
31
+ };
32
+
33
+ // src/core/interactions/referralEncoder.ts
34
+ import { concatHex as concatHex2, pad as pad2, toHex as toHex2 } from "viem";
35
+ function createLink() {
36
+ const interactionData = concatHex2([
37
+ interactionTypes.referral.createLink,
38
+ "0x"
39
+ ]);
40
+ return {
41
+ handlerTypeDenominator: toHex2(productTypes.referral),
42
+ interactionData
43
+ };
44
+ }
45
+ function referred({ referrer }) {
46
+ const interactionData = concatHex2([
47
+ interactionTypes.referral.referred,
48
+ pad2(referrer, { size: 32 })
49
+ ]);
50
+ return {
51
+ handlerTypeDenominator: toHex2(productTypes.referral),
52
+ interactionData
53
+ };
54
+ }
55
+ var ReferralInteractionEncoder = {
56
+ createLink,
57
+ referred
58
+ };
59
+
60
+ // src/core/interactions/purchaseEncoder.ts
61
+ import { concatHex as concatHex3, encodeAbiParameters, pad as pad3, toHex as toHex3 } from "viem";
62
+ function startPurchase({
63
+ purchaseId
64
+ }) {
65
+ const interactionData = concatHex3([
66
+ interactionTypes.purchase.started,
67
+ pad3(purchaseId, { size: 32 })
68
+ ]);
69
+ return {
70
+ handlerTypeDenominator: toHex3(productTypes.purchase),
71
+ interactionData
72
+ };
73
+ }
74
+ function completedPurchase({
75
+ purchaseId,
76
+ proof
77
+ }) {
78
+ const innerData = encodeAbiParameters(
79
+ [{ type: "uint256" }, { type: "bytes32[]" }],
80
+ [BigInt(purchaseId), proof]
81
+ );
82
+ const interactionData = concatHex3([
83
+ interactionTypes.purchase.completed,
84
+ innerData
85
+ ]);
86
+ return {
87
+ handlerTypeDenominator: toHex3(productTypes.purchase),
88
+ interactionData
89
+ };
90
+ }
91
+ var PurchaseInteractionEncoder = {
92
+ startPurchase,
93
+ completedPurchase
94
+ };
95
+
96
+ // src/core/interactions/webshopEncoder.ts
97
+ import { concatHex as concatHex4, toHex as toHex4 } from "viem";
98
+ function open() {
99
+ const interactionData = concatHex4([interactionTypes.webshop.open, "0x"]);
100
+ return {
101
+ handlerTypeDenominator: toHex4(productTypes.webshop),
102
+ interactionData
103
+ };
104
+ }
105
+ var WebShopInteractionEncoder = {
106
+ open
107
+ };
108
+
109
+ export {
110
+ PressInteractionEncoder,
111
+ ReferralInteractionEncoder,
112
+ PurchaseInteractionEncoder,
113
+ WebShopInteractionEncoder
114
+ };