@frak-labs/nexus-sdk 0.0.10 → 0.0.11

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 (37) hide show
  1. package/dist/chunk-5CFD5FM2.js +86 -0
  2. package/dist/chunk-7MVQQ2X6.js +381 -0
  3. package/dist/{chunk-72IEHEQX.js → chunk-GUDT2W6I.js} +32 -10
  4. package/dist/{chunk-NIFJZD3M.cjs → chunk-IQQTTKJL.cjs} +30 -8
  5. package/dist/chunk-S5FVCA2E.cjs +86 -0
  6. package/dist/chunk-V3S6RBRJ.cjs +381 -0
  7. package/dist/{client-6_BJp7Ub.d.ts → client-C7u9zGwC.d.cts} +135 -142
  8. package/dist/{client--U_6SK0l.d.cts → client-gE3fYzkD.d.ts} +135 -142
  9. package/dist/core/actions/index.cjs +2 -7
  10. package/dist/core/actions/index.d.cts +16 -35
  11. package/dist/core/actions/index.d.ts +16 -35
  12. package/dist/core/actions/index.js +5 -10
  13. package/dist/core/index.cjs +2 -4
  14. package/dist/core/index.d.cts +3 -3
  15. package/dist/core/index.d.ts +3 -3
  16. package/dist/core/index.js +2 -4
  17. package/dist/core/interactions/index.cjs +6 -2
  18. package/dist/core/interactions/index.d.cts +20 -6
  19. package/dist/core/interactions/index.d.ts +20 -6
  20. package/dist/core/interactions/index.js +7 -3
  21. package/dist/{interaction-D_CzyqRE.d.cts → interaction-D3-M3nBh.d.cts} +2 -2
  22. package/dist/{interaction-D_CzyqRE.d.ts → interaction-D3-M3nBh.d.ts} +2 -2
  23. package/dist/react/index.cjs +146 -158
  24. package/dist/react/index.d.cts +44 -51
  25. package/dist/react/index.d.ts +44 -51
  26. package/dist/react/index.js +152 -164
  27. package/dist/sendTransaction-BZW627cT.d.cts +30 -0
  28. package/dist/sendTransaction-DpJTfGJc.d.ts +30 -0
  29. package/package.json +8 -5
  30. package/dist/chunk-3T2FNW6E.cjs +0 -100
  31. package/dist/chunk-BPFJZRJ6.cjs +0 -152
  32. package/dist/chunk-HOX3RRO6.js +0 -199
  33. package/dist/chunk-SGLR6RFA.cjs +0 -199
  34. package/dist/chunk-T54VMWHQ.js +0 -100
  35. package/dist/chunk-TPC5PMRC.js +0 -152
  36. package/dist/watchUnlockStatus-CxnibdQx.d.cts +0 -43
  37. package/dist/watchUnlockStatus-g8wIxpeM.d.ts +0 -43
@@ -0,0 +1,86 @@
1
+ // src/core/actions/watchWalletStatus.ts
2
+ function watchWalletStatus(client, callback) {
3
+ return client.listenerRequest(
4
+ {
5
+ method: "frak_listenToWalletStatus"
6
+ },
7
+ callback
8
+ );
9
+ }
10
+
11
+ // src/core/utils/computeContentId.ts
12
+ import { keccak256, toHex } from "viem";
13
+ function computeContentId({ domain }) {
14
+ return keccak256(toHex(domain));
15
+ }
16
+
17
+ // src/core/actions/sendInteraction.ts
18
+ async function sendInteraction(client, { contentId, interaction, validation }) {
19
+ const cId = contentId ?? computeContentId(client.config);
20
+ return await client.request({
21
+ method: "frak_sendInteraction",
22
+ params: [cId, interaction, validation]
23
+ });
24
+ }
25
+
26
+ // src/core/actions/displayModal.ts
27
+ async function displayModal(client, { steps, metadata }) {
28
+ return await client.request({
29
+ method: "frak_displayModal",
30
+ params: [steps, client.config.metadata.name, metadata]
31
+ });
32
+ }
33
+
34
+ // src/core/actions/openSso.ts
35
+ async function openSso(client, args) {
36
+ const { metadata } = client.config;
37
+ await client.request({
38
+ method: "frak_sso",
39
+ params: [args, metadata.name, metadata.css]
40
+ });
41
+ }
42
+
43
+ // src/core/actions/wrapper/siweAuthenticate.ts
44
+ import { generateSiweNonce } from "viem/siwe";
45
+ async function siweAuthenticate(client, { siwe, metadata }) {
46
+ const realStatement = siwe?.statement ?? `I confirm that I want to use my Nexus wallet on: ${client.config.metadata.name}`;
47
+ const builtSiwe = {
48
+ ...siwe,
49
+ statement: realStatement,
50
+ nonce: siwe?.nonce ?? generateSiweNonce(),
51
+ uri: siwe?.uri ?? `https://${client.config.domain}`,
52
+ version: siwe?.version ?? "1",
53
+ domain: client.config.domain
54
+ };
55
+ const result = await displayModal(client, {
56
+ metadata,
57
+ steps: {
58
+ login: {},
59
+ siweAuthenticate: {
60
+ siwe: builtSiwe
61
+ }
62
+ }
63
+ });
64
+ return result.siweAuthenticate;
65
+ }
66
+
67
+ // src/core/actions/wrapper/sendTransaction.ts
68
+ async function sendTransaction(client, { tx, metadata }) {
69
+ const result = await displayModal(client, {
70
+ metadata,
71
+ steps: {
72
+ login: {},
73
+ sendTransaction: { tx }
74
+ }
75
+ });
76
+ return result.sendTransaction;
77
+ }
78
+
79
+ export {
80
+ watchWalletStatus,
81
+ sendInteraction,
82
+ displayModal,
83
+ openSso,
84
+ siweAuthenticate,
85
+ sendTransaction
86
+ };
@@ -0,0 +1,381 @@
1
+ import {
2
+ __publicField
3
+ } from "./chunk-PKBMQBKP.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 ClientNotFound = class extends FrakRpcError {
14
+ constructor() {
15
+ super(RpcErrorCodes.clientNotConnected, "Client not found");
16
+ }
17
+ };
18
+ var RpcErrorCodes = {
19
+ // Standard JSON-RPC 2.0 errors
20
+ parseError: -32700,
21
+ invalidRequest: -32600,
22
+ methodNotFound: -32601,
23
+ invalidParams: -32602,
24
+ internalError: -32603,
25
+ serverError: -32e3,
26
+ // Frak specific errors (from -32001 to -32099)
27
+ clientNotConnected: -32001,
28
+ configError: -32002,
29
+ corruptedResponse: -32003,
30
+ clientAborted: -32004,
31
+ walletNotConnected: -32005,
32
+ noInteractionSession: -32006
33
+ };
34
+
35
+ // src/core/utils/Deferred.ts
36
+ var Deferred = class {
37
+ constructor() {
38
+ __publicField(this, "_promise");
39
+ __publicField(this, "_resolve");
40
+ __publicField(this, "_reject");
41
+ __publicField(this, "resolve", (value) => {
42
+ this._resolve?.(value);
43
+ });
44
+ __publicField(this, "reject", (reason) => {
45
+ this._reject?.(reason);
46
+ });
47
+ this._promise = new Promise((resolve, reject) => {
48
+ this._resolve = resolve;
49
+ this._reject = reject;
50
+ });
51
+ }
52
+ get promise() {
53
+ return this._promise;
54
+ }
55
+ };
56
+
57
+ // src/core/utils/compression/compress.ts
58
+ import { compressToBase64 } from "async-lz-string";
59
+ import { sha256 } from "js-sha256";
60
+ async function hashAndCompressData(data) {
61
+ const validationHash = sha256(JSON.stringify(data));
62
+ const hashProtectedData = {
63
+ ...data,
64
+ validationHash
65
+ };
66
+ const compressed = await compressJson(hashProtectedData);
67
+ const compressedHash = sha256(compressed);
68
+ return {
69
+ compressed,
70
+ compressedHash
71
+ };
72
+ }
73
+ async function compressJson(data) {
74
+ return compressToBase64(JSON.stringify(data));
75
+ }
76
+
77
+ // src/core/utils/compression/decompress.ts
78
+ import { decompressFromBase64 } from "async-lz-string";
79
+ import { sha256 as sha2562 } from "js-sha256";
80
+ async function decompressDataAndCheckHash(compressedData) {
81
+ if (!(compressedData?.compressed && compressedData?.compressedHash)) {
82
+ throw new FrakRpcError(
83
+ RpcErrorCodes.corruptedResponse,
84
+ "Missing compressed data"
85
+ );
86
+ }
87
+ const parsedData = await decompressJson(
88
+ compressedData.compressed
89
+ );
90
+ if (!parsedData) {
91
+ throw new FrakRpcError(
92
+ RpcErrorCodes.corruptedResponse,
93
+ "Invalid compressed data"
94
+ );
95
+ }
96
+ if (!parsedData?.validationHash) {
97
+ throw new FrakRpcError(
98
+ RpcErrorCodes.corruptedResponse,
99
+ "Missing validation hash"
100
+ );
101
+ }
102
+ const expectedCompressedHash = sha2562(compressedData.compressed);
103
+ if (expectedCompressedHash !== compressedData.compressedHash) {
104
+ throw new FrakRpcError(
105
+ RpcErrorCodes.corruptedResponse,
106
+ "Invalid compressed hash"
107
+ );
108
+ }
109
+ const { validationHash: _, ...rawResultData } = parsedData;
110
+ const expectedValidationHash = sha2562(JSON.stringify(rawResultData));
111
+ if (expectedValidationHash !== parsedData.validationHash) {
112
+ throw new FrakRpcError(
113
+ RpcErrorCodes.corruptedResponse,
114
+ "Invalid data validation hash"
115
+ );
116
+ }
117
+ return parsedData;
118
+ }
119
+ async function decompressJson(data) {
120
+ const decompressed = await decompressFromBase64(data);
121
+ try {
122
+ return JSON.parse(decompressed);
123
+ } catch (e) {
124
+ console.error("Invalid compressed data", e);
125
+ return null;
126
+ }
127
+ }
128
+
129
+ // src/core/clients/transports/iframeChannelManager.ts
130
+ function createIFrameChannelManager() {
131
+ const channels = /* @__PURE__ */ new Map();
132
+ return {
133
+ // TODO: Better id system?? uid stuff?
134
+ createChannel: (resolver) => {
135
+ const id = Math.random().toString(36).substring(7);
136
+ channels.set(id, resolver);
137
+ return id;
138
+ },
139
+ getRpcResolver: (id) => channels.get(id),
140
+ removeChannel: (id) => channels.delete(id),
141
+ destroy: () => channels.clear()
142
+ };
143
+ }
144
+
145
+ // src/core/utils/iframeHelper.ts
146
+ var baseIframeProps = {
147
+ id: "nexus-wallet",
148
+ name: "nexus-wallet",
149
+ allow: "publickey-credentials-get *; clipboard-write; web-share *",
150
+ style: {
151
+ width: "0",
152
+ height: "0",
153
+ border: "0",
154
+ position: "absolute",
155
+ zIndex: 1e3,
156
+ top: "-1000px",
157
+ left: "-1000px"
158
+ }
159
+ };
160
+ function createIframe({
161
+ walletBaseUrl
162
+ }) {
163
+ const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
164
+ if (alreadyCreatedIFrame) {
165
+ return Promise.resolve(void 0);
166
+ }
167
+ const iframe = document.createElement("iframe");
168
+ iframe.id = baseIframeProps.id;
169
+ iframe.name = baseIframeProps.name;
170
+ iframe.allow = baseIframeProps.allow;
171
+ iframe.style.zIndex = baseIframeProps.style.zIndex.toString();
172
+ changeIframeVisibility({ iframe, isVisible: false });
173
+ document.body.appendChild(iframe);
174
+ return new Promise((resolve) => {
175
+ iframe?.addEventListener("load", () => resolve(iframe));
176
+ iframe.src = `${walletBaseUrl}/listener`;
177
+ });
178
+ }
179
+ function changeIframeVisibility({
180
+ iframe,
181
+ isVisible
182
+ }) {
183
+ if (!isVisible) {
184
+ iframe.style.width = "0";
185
+ iframe.style.height = "0";
186
+ iframe.style.border = "0";
187
+ iframe.style.position = "fixed";
188
+ iframe.style.top = "-1000px";
189
+ iframe.style.left = "-1000px";
190
+ return;
191
+ }
192
+ iframe.style.position = "fixed";
193
+ iframe.style.top = "0";
194
+ iframe.style.left = "0";
195
+ iframe.style.width = "100%";
196
+ iframe.style.height = "100%";
197
+ iframe.style.pointerEvents = "auto";
198
+ }
199
+
200
+ // src/core/clients/transports/iframeMessageHandler.ts
201
+ function createIFrameMessageHandler({
202
+ nexusWalletUrl,
203
+ metadata,
204
+ iframe,
205
+ channelManager
206
+ }) {
207
+ if (typeof window === "undefined") {
208
+ throw new FrakRpcError(
209
+ RpcErrorCodes.configError,
210
+ "iframe client should be used in the browser"
211
+ );
212
+ }
213
+ if (!iframe.contentWindow) {
214
+ throw new FrakRpcError(
215
+ RpcErrorCodes.configError,
216
+ "The iframe does not have a content window"
217
+ );
218
+ }
219
+ const contentWindow = iframe.contentWindow;
220
+ const isConnectedDeferred = new Deferred();
221
+ const msgHandler = async (event) => {
222
+ if (!event.origin) {
223
+ return;
224
+ }
225
+ if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
226
+ return;
227
+ }
228
+ if ("lifecycle" in event.data) {
229
+ switch (event.data.lifecycle) {
230
+ case "connected":
231
+ isConnectedDeferred.resolve(true);
232
+ break;
233
+ case "show":
234
+ case "hide":
235
+ changeIframeVisibility({
236
+ iframe,
237
+ isVisible: event.data.lifecycle === "show"
238
+ });
239
+ break;
240
+ }
241
+ return;
242
+ }
243
+ const channel = event.data.id;
244
+ const resolver = channelManager.getRpcResolver(channel);
245
+ if (!resolver) {
246
+ return;
247
+ }
248
+ await resolver(event.data);
249
+ };
250
+ window.addEventListener("message", msgHandler);
251
+ const sendEvent = (message) => {
252
+ contentWindow.postMessage(message, {
253
+ targetOrigin: nexusWalletUrl
254
+ });
255
+ };
256
+ const cleanup = () => {
257
+ window.removeEventListener("message", msgHandler);
258
+ };
259
+ const isConnected = injectCssOnConnect({
260
+ isConnected: isConnectedDeferred.promise,
261
+ metadata,
262
+ sendEvent
263
+ });
264
+ return {
265
+ isConnected,
266
+ sendEvent,
267
+ cleanup
268
+ };
269
+ }
270
+ function injectCssOnConnect({
271
+ isConnected,
272
+ metadata,
273
+ sendEvent
274
+ }) {
275
+ const css = metadata?.css;
276
+ if (!css) {
277
+ return isConnected;
278
+ }
279
+ return isConnected.then((connected) => {
280
+ sendEvent({
281
+ lifecycle: "modal-css",
282
+ data: css
283
+ });
284
+ return connected;
285
+ });
286
+ }
287
+
288
+ // src/core/clients/createIFrameNexusClient.ts
289
+ function createIFrameNexusClient({
290
+ config,
291
+ iframe
292
+ }) {
293
+ const channelManager = createIFrameChannelManager();
294
+ const messageHandler = createIFrameMessageHandler({
295
+ nexusWalletUrl: config.walletUrl,
296
+ metadata: config.metadata,
297
+ iframe,
298
+ channelManager
299
+ });
300
+ const request = async (args) => {
301
+ const isConnected = await messageHandler.isConnected;
302
+ if (!isConnected) {
303
+ throw new FrakRpcError(
304
+ RpcErrorCodes.clientNotConnected,
305
+ "The iframe provider isn't connected yet"
306
+ );
307
+ }
308
+ const result = new Deferred();
309
+ const channelId = channelManager.createChannel(async (message) => {
310
+ const decompressed = await decompressDataAndCheckHash(message.data);
311
+ if (decompressed.error) {
312
+ result.reject(
313
+ new FrakRpcError(
314
+ decompressed.error.code,
315
+ decompressed.error.message,
316
+ decompressed.error?.data
317
+ )
318
+ );
319
+ } else {
320
+ result.resolve(decompressed.result);
321
+ }
322
+ channelManager.removeChannel(channelId);
323
+ });
324
+ const compressedMessage = await hashAndCompressData(args);
325
+ messageHandler.sendEvent({
326
+ id: channelId,
327
+ // @ts-ignore, todo: idk why the fck it's needed
328
+ topic: args.method,
329
+ data: compressedMessage
330
+ });
331
+ return result.promise;
332
+ };
333
+ const listenerRequest = async (args, callback) => {
334
+ const isConnected = await messageHandler.isConnected;
335
+ if (!isConnected) {
336
+ throw new FrakRpcError(
337
+ RpcErrorCodes.clientNotConnected,
338
+ "The iframe provider isn't connected yet"
339
+ );
340
+ }
341
+ const channelId = channelManager.createChannel(async (message) => {
342
+ const decompressed = await decompressDataAndCheckHash(message.data);
343
+ if (decompressed.result) {
344
+ callback(decompressed.result);
345
+ } else {
346
+ }
347
+ });
348
+ const compressedMessage = await hashAndCompressData(args);
349
+ messageHandler.sendEvent({
350
+ id: channelId,
351
+ topic: args.method,
352
+ data: compressedMessage
353
+ });
354
+ };
355
+ const destroy = async () => {
356
+ channelManager.destroy();
357
+ messageHandler.cleanup();
358
+ iframe.remove();
359
+ };
360
+ return {
361
+ config,
362
+ waitForConnection: messageHandler.isConnected,
363
+ request,
364
+ listenerRequest,
365
+ destroy
366
+ };
367
+ }
368
+
369
+ export {
370
+ FrakRpcError,
371
+ ClientNotFound,
372
+ RpcErrorCodes,
373
+ Deferred,
374
+ hashAndCompressData,
375
+ compressJson,
376
+ decompressDataAndCheckHash,
377
+ decompressJson,
378
+ baseIframeProps,
379
+ createIframe,
380
+ createIFrameNexusClient
381
+ };
@@ -3,8 +3,7 @@ import { concatHex, pad } from "viem";
3
3
  var PressTypeSelector = "0x02";
4
4
  var PressActionsSelector = {
5
5
  OpenArticle: "0xc0a24ffb",
6
- ReadArticle: "0xd5bd0fbe",
7
- Referred: "0x3d1508ad"
6
+ ReadArticle: "0xd5bd0fbe"
8
7
  };
9
8
  function openArticle({ articleId }) {
10
9
  const interactionData = concatHex([
@@ -26,23 +25,46 @@ function readArticle({ articleId }) {
26
25
  interactionData
27
26
  };
28
27
  }
28
+ var PressInteractionEncoder = {
29
+ openArticle,
30
+ readArticle
31
+ };
32
+
33
+ // src/core/interactions/referralEncoder.ts
34
+ import { concatHex as concatHex2, pad as pad2 } from "viem";
35
+ var ReferralTypeSelector = "0x1E";
36
+ var ReferralActionsSelector = {
37
+ CreateLink: "0xb2c0f17c",
38
+ Referred: "0x010cc3b9"
39
+ };
40
+ function createLink() {
41
+ const interactionData = concatHex2([
42
+ ReferralActionsSelector.CreateLink,
43
+ "0x"
44
+ ]);
45
+ return {
46
+ handlerTypeDenominator: ReferralTypeSelector,
47
+ interactionData
48
+ };
49
+ }
29
50
  function referred({ referrer }) {
30
- const interactionData = concatHex([
31
- PressActionsSelector.Referred,
32
- pad(referrer, { size: 32 })
51
+ const interactionData = concatHex2([
52
+ ReferralActionsSelector.Referred,
53
+ pad2(referrer, { size: 32 })
33
54
  ]);
34
55
  return {
35
- handlerTypeDenominator: PressTypeSelector,
56
+ handlerTypeDenominator: ReferralTypeSelector,
36
57
  interactionData
37
58
  };
38
59
  }
39
- var PressInteractionEncoder = {
40
- openArticle,
41
- readArticle,
60
+ var ReferralInteractionEncoder = {
61
+ createLink,
42
62
  referred
43
63
  };
44
64
 
45
65
  export {
46
66
  PressActionsSelector,
47
- PressInteractionEncoder
67
+ PressInteractionEncoder,
68
+ ReferralActionsSelector,
69
+ ReferralInteractionEncoder
48
70
  };
@@ -3,8 +3,7 @@ var _viem = require('viem');
3
3
  var PressTypeSelector = "0x02";
4
4
  var PressActionsSelector = {
5
5
  OpenArticle: "0xc0a24ffb",
6
- ReadArticle: "0xd5bd0fbe",
7
- Referred: "0x3d1508ad"
6
+ ReadArticle: "0xd5bd0fbe"
8
7
  };
9
8
  function openArticle({ articleId }) {
10
9
  const interactionData = _viem.concatHex.call(void 0, [
@@ -26,23 +25,46 @@ function readArticle({ articleId }) {
26
25
  interactionData
27
26
  };
28
27
  }
28
+ var PressInteractionEncoder = {
29
+ openArticle,
30
+ readArticle
31
+ };
32
+
33
+ // src/core/interactions/referralEncoder.ts
34
+
35
+ var ReferralTypeSelector = "0x1E";
36
+ var ReferralActionsSelector = {
37
+ CreateLink: "0xb2c0f17c",
38
+ Referred: "0x010cc3b9"
39
+ };
40
+ function createLink() {
41
+ const interactionData = _viem.concatHex.call(void 0, [
42
+ ReferralActionsSelector.CreateLink,
43
+ "0x"
44
+ ]);
45
+ return {
46
+ handlerTypeDenominator: ReferralTypeSelector,
47
+ interactionData
48
+ };
49
+ }
29
50
  function referred({ referrer }) {
30
51
  const interactionData = _viem.concatHex.call(void 0, [
31
- PressActionsSelector.Referred,
52
+ ReferralActionsSelector.Referred,
32
53
  _viem.pad.call(void 0, referrer, { size: 32 })
33
54
  ]);
34
55
  return {
35
- handlerTypeDenominator: PressTypeSelector,
56
+ handlerTypeDenominator: ReferralTypeSelector,
36
57
  interactionData
37
58
  };
38
59
  }
39
- var PressInteractionEncoder = {
40
- openArticle,
41
- readArticle,
60
+ var ReferralInteractionEncoder = {
61
+ createLink,
42
62
  referred
43
63
  };
44
64
 
45
65
 
46
66
 
47
67
 
48
- exports.PressActionsSelector = PressActionsSelector; exports.PressInteractionEncoder = PressInteractionEncoder;
68
+
69
+
70
+ exports.PressActionsSelector = PressActionsSelector; exports.PressInteractionEncoder = PressInteractionEncoder; exports.ReferralActionsSelector = ReferralActionsSelector; exports.ReferralInteractionEncoder = ReferralInteractionEncoder;
@@ -0,0 +1,86 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }// src/core/actions/watchWalletStatus.ts
2
+ function watchWalletStatus(client, callback) {
3
+ return client.listenerRequest(
4
+ {
5
+ method: "frak_listenToWalletStatus"
6
+ },
7
+ callback
8
+ );
9
+ }
10
+
11
+ // src/core/utils/computeContentId.ts
12
+ var _viem = require('viem');
13
+ function computeContentId({ domain }) {
14
+ return _viem.keccak256.call(void 0, _viem.toHex.call(void 0, domain));
15
+ }
16
+
17
+ // src/core/actions/sendInteraction.ts
18
+ async function sendInteraction(client, { contentId, interaction, validation }) {
19
+ const cId = _nullishCoalesce(contentId, () => ( computeContentId(client.config)));
20
+ return await client.request({
21
+ method: "frak_sendInteraction",
22
+ params: [cId, interaction, validation]
23
+ });
24
+ }
25
+
26
+ // src/core/actions/displayModal.ts
27
+ async function displayModal(client, { steps, metadata }) {
28
+ return await client.request({
29
+ method: "frak_displayModal",
30
+ params: [steps, client.config.metadata.name, metadata]
31
+ });
32
+ }
33
+
34
+ // src/core/actions/openSso.ts
35
+ async function openSso(client, args) {
36
+ const { metadata } = client.config;
37
+ await client.request({
38
+ method: "frak_sso",
39
+ params: [args, metadata.name, metadata.css]
40
+ });
41
+ }
42
+
43
+ // src/core/actions/wrapper/siweAuthenticate.ts
44
+ var _siwe = require('viem/siwe');
45
+ async function siweAuthenticate(client, { siwe, metadata }) {
46
+ const realStatement = _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _ => _.statement]), () => ( `I confirm that I want to use my Nexus wallet on: ${client.config.metadata.name}`));
47
+ const builtSiwe = {
48
+ ...siwe,
49
+ statement: realStatement,
50
+ nonce: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _2 => _2.nonce]), () => ( _siwe.generateSiweNonce.call(void 0, ))),
51
+ uri: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _3 => _3.uri]), () => ( `https://${client.config.domain}`)),
52
+ version: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _4 => _4.version]), () => ( "1")),
53
+ domain: client.config.domain
54
+ };
55
+ const result = await displayModal(client, {
56
+ metadata,
57
+ steps: {
58
+ login: {},
59
+ siweAuthenticate: {
60
+ siwe: builtSiwe
61
+ }
62
+ }
63
+ });
64
+ return result.siweAuthenticate;
65
+ }
66
+
67
+ // src/core/actions/wrapper/sendTransaction.ts
68
+ async function sendTransaction(client, { tx, metadata }) {
69
+ const result = await displayModal(client, {
70
+ metadata,
71
+ steps: {
72
+ login: {},
73
+ sendTransaction: { tx }
74
+ }
75
+ });
76
+ return result.sendTransaction;
77
+ }
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+ exports.watchWalletStatus = watchWalletStatus; exports.sendInteraction = sendInteraction; exports.displayModal = displayModal; exports.openSso = openSso; exports.siweAuthenticate = siweAuthenticate; exports.sendTransaction = sendTransaction;