@frak-labs/nexus-sdk 0.0.25 → 0.0.27

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/README.md +2 -72
  2. package/dist/bundle/bundle.js +6 -6
  3. package/package.json +11 -64
  4. package/dist/FrakContext-DKSVaeVb.d.cts +0 -450
  5. package/dist/FrakContext-DjeuWC2U.d.ts +0 -450
  6. package/dist/chunk-2VNIEGOJ.js +0 -864
  7. package/dist/chunk-4MMSQL44.js +0 -351
  8. package/dist/chunk-4PVF24BB.cjs +0 -114
  9. package/dist/chunk-BOGCLEPR.js +0 -80
  10. package/dist/chunk-DE2KWQVP.cjs +0 -351
  11. package/dist/chunk-FETGS7X7.js +0 -114
  12. package/dist/chunk-H4BK3CNV.cjs +0 -864
  13. package/dist/chunk-P3J2BIUT.cjs +0 -80
  14. package/dist/chunk-QLM5NFMZ.cjs +0 -245
  15. package/dist/chunk-YPQA63LW.js +0 -245
  16. package/dist/core/actions/index.cjs +0 -29
  17. package/dist/core/actions/index.d.cts +0 -92
  18. package/dist/core/actions/index.d.ts +0 -92
  19. package/dist/core/actions/index.js +0 -29
  20. package/dist/core/index.cjs +0 -34
  21. package/dist/core/index.d.cts +0 -167
  22. package/dist/core/index.d.ts +0 -167
  23. package/dist/core/index.js +0 -34
  24. package/dist/core/interactions/index.cjs +0 -13
  25. package/dist/core/interactions/index.d.cts +0 -65
  26. package/dist/core/interactions/index.d.ts +0 -65
  27. package/dist/core/interactions/index.js +0 -13
  28. package/dist/error-Dflr3G5x.d.cts +0 -27
  29. package/dist/error-Dflr3G5x.d.ts +0 -27
  30. package/dist/interaction-BngPoHA0.d.cts +0 -22
  31. package/dist/interaction-BngPoHA0.d.ts +0 -22
  32. package/dist/processReferral-CJI_Rc4K.d.ts +0 -53
  33. package/dist/processReferral-DUP8imQV.d.cts +0 -53
  34. package/dist/react/index.cjs +0 -366
  35. package/dist/react/index.d.cts +0 -167
  36. package/dist/react/index.d.ts +0 -167
  37. package/dist/react/index.js +0 -366
@@ -1,80 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
28
-
29
- // src/core/constants/productTypes.ts
30
- var productTypes = {
31
- // content type
32
- dapp: 1,
33
- press: 2,
34
- webshop: 3,
35
- // feature type
36
- referral: 30,
37
- purchase: 31
38
- };
39
- var productTypesMask = Object.entries(
40
- productTypes
41
- ).reduce(
42
- (acc, [key, value]) => {
43
- acc[key] = BigInt(1) << BigInt(value);
44
- return acc;
45
- },
46
- {}
47
- );
48
-
49
- // src/core/constants/interactionTypes.ts
50
- var interactionTypes = {
51
- press: {
52
- openArticle: "0xc0a24ffb",
53
- readArticle: "0xd5bd0fbe"
54
- },
55
- dapp: {
56
- proofVerifiableStorageUpdate: "0x2ab2aeef",
57
- callableVerifiableStorageUpdate: "0xa07da986"
58
- },
59
- webshop: {
60
- open: "0xb311798f"
61
- },
62
- referral: {
63
- referred: "0x010cc3b9",
64
- createLink: "0xb2c0f17c"
65
- },
66
- purchase: {
67
- started: "0xd87e90c3",
68
- completed: "0x8403aeb4",
69
- unsafeCompleted: "0x4d5b14e0"
70
- }
71
- };
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
- exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.__publicField = __publicField; exports.productTypes = productTypes; exports.productTypesMask = productTypesMask; exports.interactionTypes = interactionTypes;
@@ -1,245 +0,0 @@
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; }
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
- var _chunkH4BK3CNVcjs = require('./chunk-H4BK3CNV.cjs');
11
-
12
- // src/core/utils/constants.ts
13
- var BACKUP_KEY = "nexus-wallet-backup";
14
-
15
- // src/core/clients/transports/iframeChannelManager.ts
16
- function createIFrameChannelManager() {
17
- const channels = /* @__PURE__ */ new Map();
18
- return {
19
- // TODO: Better id system?? uid stuff?
20
- createChannel: (resolver) => {
21
- const id = Math.random().toString(36).substring(7);
22
- channels.set(id, resolver);
23
- return id;
24
- },
25
- getRpcResolver: (id) => channels.get(id),
26
- removeChannel: (id) => channels.delete(id),
27
- destroy: () => channels.clear()
28
- };
29
- }
30
-
31
- // src/core/clients/transports/iframeLifecycleManager.ts
32
- function createIFrameLifecycleManager({
33
- iframe
34
- }) {
35
- const isConnectedDeferred = new (0, _chunkH4BK3CNVcjs.Deferred)();
36
- const handler = async (messageEvent) => {
37
- switch (messageEvent.iframeLifecycle) {
38
- // Resolve the isConnected promise
39
- case "connected":
40
- isConnectedDeferred.resolve(true);
41
- break;
42
- // Perform a nexus backup
43
- case "do-backup":
44
- if (messageEvent.data.backup) {
45
- localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
46
- } else {
47
- localStorage.removeItem(BACKUP_KEY);
48
- }
49
- break;
50
- // Remove nexus backup
51
- case "remove-backup":
52
- localStorage.removeItem(BACKUP_KEY);
53
- break;
54
- // Change iframe visibility
55
- case "show":
56
- case "hide":
57
- _chunkH4BK3CNVcjs.changeIframeVisibility.call(void 0, {
58
- iframe,
59
- isVisible: messageEvent.iframeLifecycle === "show"
60
- });
61
- break;
62
- }
63
- };
64
- return {
65
- handleEvent: handler,
66
- isConnected: isConnectedDeferred.promise
67
- };
68
- }
69
-
70
- // src/core/clients/transports/iframeMessageHandler.ts
71
- function createIFrameMessageHandler({
72
- nexusWalletUrl,
73
- iframe,
74
- channelManager,
75
- iframeLifecycleManager
76
- }) {
77
- if (typeof window === "undefined") {
78
- throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
79
- _chunkH4BK3CNVcjs.RpcErrorCodes.configError,
80
- "iframe client should be used in the browser"
81
- );
82
- }
83
- if (!iframe.contentWindow) {
84
- throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
85
- _chunkH4BK3CNVcjs.RpcErrorCodes.configError,
86
- "The iframe does not have a product window"
87
- );
88
- }
89
- const contentWindow = iframe.contentWindow;
90
- const msgHandler = async (event) => {
91
- if (!(event.origin && URL.canParse(event.origin))) {
92
- return;
93
- }
94
- if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
95
- return;
96
- }
97
- if ("iframeLifecycle" in event.data) {
98
- await iframeLifecycleManager.handleEvent(event.data);
99
- return;
100
- }
101
- if ("clientLifecycle" in event.data) {
102
- console.error(
103
- "Client lifecycle event received on the client side, dismissing it"
104
- );
105
- return;
106
- }
107
- const channel = event.data.id;
108
- const resolver = channelManager.getRpcResolver(channel);
109
- if (!resolver) {
110
- return;
111
- }
112
- await resolver(event.data);
113
- };
114
- window.addEventListener("message", msgHandler);
115
- const sendEvent = (message) => {
116
- contentWindow.postMessage(message, {
117
- targetOrigin: nexusWalletUrl
118
- });
119
- };
120
- const cleanup = () => {
121
- window.removeEventListener("message", msgHandler);
122
- };
123
- return {
124
- sendEvent,
125
- cleanup
126
- };
127
- }
128
-
129
- // src/core/clients/createIFrameNexusClient.ts
130
- function createIFrameNexusClient({
131
- config,
132
- iframe
133
- }) {
134
- const channelManager = createIFrameChannelManager();
135
- const lifecycleManager = createIFrameLifecycleManager({ iframe });
136
- const messageHandler = createIFrameMessageHandler({
137
- nexusWalletUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.walletUrl]), () => ( "https://wallet.frak.id")),
138
- iframe,
139
- channelManager,
140
- iframeLifecycleManager: lifecycleManager
141
- });
142
- const request = async (args) => {
143
- const isConnected = await lifecycleManager.isConnected;
144
- if (!isConnected) {
145
- throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
146
- _chunkH4BK3CNVcjs.RpcErrorCodes.clientNotConnected,
147
- "The iframe provider isn't connected yet"
148
- );
149
- }
150
- const result = new (0, _chunkH4BK3CNVcjs.Deferred)();
151
- const channelId = channelManager.createChannel(async (message) => {
152
- const decompressed = await _chunkH4BK3CNVcjs.decompressDataAndCheckHash.call(void 0, message.data);
153
- if (decompressed.error) {
154
- result.reject(
155
- new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
156
- decompressed.error.code,
157
- decompressed.error.message,
158
- _optionalChain([decompressed, 'access', _2 => _2.error, 'optionalAccess', _3 => _3.data])
159
- )
160
- );
161
- } else {
162
- result.resolve(decompressed.result);
163
- }
164
- channelManager.removeChannel(channelId);
165
- });
166
- const compressedMessage = await _chunkH4BK3CNVcjs.hashAndCompressData.call(void 0, args);
167
- messageHandler.sendEvent({
168
- id: channelId,
169
- topic: args.method,
170
- data: compressedMessage
171
- });
172
- return result.promise;
173
- };
174
- const listenerRequest = async (args, callback) => {
175
- const isConnected = await lifecycleManager.isConnected;
176
- if (!isConnected) {
177
- throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
178
- _chunkH4BK3CNVcjs.RpcErrorCodes.clientNotConnected,
179
- "The iframe provider isn't connected yet"
180
- );
181
- }
182
- const channelId = channelManager.createChannel(async (message) => {
183
- const decompressed = await _chunkH4BK3CNVcjs.decompressDataAndCheckHash.call(void 0, message.data);
184
- if (decompressed.result) {
185
- callback(decompressed.result);
186
- } else {
187
- throw new (0, _chunkH4BK3CNVcjs.InternalError)("No valid result in the response");
188
- }
189
- });
190
- const compressedMessage = await _chunkH4BK3CNVcjs.hashAndCompressData.call(void 0, args);
191
- messageHandler.sendEvent({
192
- id: channelId,
193
- topic: args.method,
194
- data: compressedMessage
195
- });
196
- };
197
- const destroy = async () => {
198
- channelManager.destroy();
199
- messageHandler.cleanup();
200
- iframe.remove();
201
- };
202
- const waitForSetup = postConnectionSetup({
203
- config,
204
- messageHandler,
205
- lifecycleManager
206
- });
207
- return {
208
- config,
209
- waitForConnection: lifecycleManager.isConnected,
210
- waitForSetup,
211
- request,
212
- listenerRequest,
213
- destroy
214
- };
215
- }
216
- async function postConnectionSetup({
217
- config,
218
- messageHandler,
219
- lifecycleManager
220
- }) {
221
- await lifecycleManager.isConnected;
222
- _chunkH4BK3CNVcjs.enableButtonShare.call(void 0, config);
223
- const pushCss = async () => {
224
- const cssLink = config.metadata.css;
225
- if (!cssLink) return;
226
- messageHandler.sendEvent({
227
- clientLifecycle: "modal-css",
228
- data: { cssLink }
229
- });
230
- };
231
- const pushBackup = async () => {
232
- if (typeof window === "undefined") return;
233
- const backup = window.localStorage.getItem(BACKUP_KEY);
234
- if (!backup) return;
235
- messageHandler.sendEvent({
236
- clientLifecycle: "restore-backup",
237
- data: { backup }
238
- });
239
- };
240
- await Promise.all([pushCss(), pushBackup()]);
241
- }
242
-
243
-
244
-
245
- exports.createIFrameNexusClient = createIFrameNexusClient;
@@ -1,245 +0,0 @@
1
- import {
2
- Deferred,
3
- FrakRpcError,
4
- InternalError,
5
- RpcErrorCodes,
6
- changeIframeVisibility,
7
- decompressDataAndCheckHash,
8
- enableButtonShare,
9
- hashAndCompressData
10
- } from "./chunk-2VNIEGOJ.js";
11
-
12
- // src/core/utils/constants.ts
13
- var BACKUP_KEY = "nexus-wallet-backup";
14
-
15
- // src/core/clients/transports/iframeChannelManager.ts
16
- function createIFrameChannelManager() {
17
- const channels = /* @__PURE__ */ new Map();
18
- return {
19
- // TODO: Better id system?? uid stuff?
20
- createChannel: (resolver) => {
21
- const id = Math.random().toString(36).substring(7);
22
- channels.set(id, resolver);
23
- return id;
24
- },
25
- getRpcResolver: (id) => channels.get(id),
26
- removeChannel: (id) => channels.delete(id),
27
- destroy: () => channels.clear()
28
- };
29
- }
30
-
31
- // src/core/clients/transports/iframeLifecycleManager.ts
32
- function createIFrameLifecycleManager({
33
- iframe
34
- }) {
35
- const isConnectedDeferred = new Deferred();
36
- const handler = async (messageEvent) => {
37
- switch (messageEvent.iframeLifecycle) {
38
- // Resolve the isConnected promise
39
- case "connected":
40
- isConnectedDeferred.resolve(true);
41
- break;
42
- // Perform a nexus backup
43
- case "do-backup":
44
- if (messageEvent.data.backup) {
45
- localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
46
- } else {
47
- localStorage.removeItem(BACKUP_KEY);
48
- }
49
- break;
50
- // Remove nexus backup
51
- case "remove-backup":
52
- localStorage.removeItem(BACKUP_KEY);
53
- break;
54
- // Change iframe visibility
55
- case "show":
56
- case "hide":
57
- changeIframeVisibility({
58
- iframe,
59
- isVisible: messageEvent.iframeLifecycle === "show"
60
- });
61
- break;
62
- }
63
- };
64
- return {
65
- handleEvent: handler,
66
- isConnected: isConnectedDeferred.promise
67
- };
68
- }
69
-
70
- // src/core/clients/transports/iframeMessageHandler.ts
71
- function createIFrameMessageHandler({
72
- nexusWalletUrl,
73
- iframe,
74
- channelManager,
75
- iframeLifecycleManager
76
- }) {
77
- if (typeof window === "undefined") {
78
- throw new FrakRpcError(
79
- RpcErrorCodes.configError,
80
- "iframe client should be used in the browser"
81
- );
82
- }
83
- if (!iframe.contentWindow) {
84
- throw new FrakRpcError(
85
- RpcErrorCodes.configError,
86
- "The iframe does not have a product window"
87
- );
88
- }
89
- const contentWindow = iframe.contentWindow;
90
- const msgHandler = async (event) => {
91
- if (!(event.origin && URL.canParse(event.origin))) {
92
- return;
93
- }
94
- if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
95
- return;
96
- }
97
- if ("iframeLifecycle" in event.data) {
98
- await iframeLifecycleManager.handleEvent(event.data);
99
- return;
100
- }
101
- if ("clientLifecycle" in event.data) {
102
- console.error(
103
- "Client lifecycle event received on the client side, dismissing it"
104
- );
105
- return;
106
- }
107
- const channel = event.data.id;
108
- const resolver = channelManager.getRpcResolver(channel);
109
- if (!resolver) {
110
- return;
111
- }
112
- await resolver(event.data);
113
- };
114
- window.addEventListener("message", msgHandler);
115
- const sendEvent = (message) => {
116
- contentWindow.postMessage(message, {
117
- targetOrigin: nexusWalletUrl
118
- });
119
- };
120
- const cleanup = () => {
121
- window.removeEventListener("message", msgHandler);
122
- };
123
- return {
124
- sendEvent,
125
- cleanup
126
- };
127
- }
128
-
129
- // src/core/clients/createIFrameNexusClient.ts
130
- function createIFrameNexusClient({
131
- config,
132
- iframe
133
- }) {
134
- const channelManager = createIFrameChannelManager();
135
- const lifecycleManager = createIFrameLifecycleManager({ iframe });
136
- const messageHandler = createIFrameMessageHandler({
137
- nexusWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
138
- iframe,
139
- channelManager,
140
- iframeLifecycleManager: lifecycleManager
141
- });
142
- const request = async (args) => {
143
- const isConnected = await lifecycleManager.isConnected;
144
- if (!isConnected) {
145
- throw new FrakRpcError(
146
- RpcErrorCodes.clientNotConnected,
147
- "The iframe provider isn't connected yet"
148
- );
149
- }
150
- const result = new Deferred();
151
- const channelId = channelManager.createChannel(async (message) => {
152
- const decompressed = await decompressDataAndCheckHash(message.data);
153
- if (decompressed.error) {
154
- result.reject(
155
- new FrakRpcError(
156
- decompressed.error.code,
157
- decompressed.error.message,
158
- decompressed.error?.data
159
- )
160
- );
161
- } else {
162
- result.resolve(decompressed.result);
163
- }
164
- channelManager.removeChannel(channelId);
165
- });
166
- const compressedMessage = await hashAndCompressData(args);
167
- messageHandler.sendEvent({
168
- id: channelId,
169
- topic: args.method,
170
- data: compressedMessage
171
- });
172
- return result.promise;
173
- };
174
- const listenerRequest = async (args, callback) => {
175
- const isConnected = await lifecycleManager.isConnected;
176
- if (!isConnected) {
177
- throw new FrakRpcError(
178
- RpcErrorCodes.clientNotConnected,
179
- "The iframe provider isn't connected yet"
180
- );
181
- }
182
- const channelId = channelManager.createChannel(async (message) => {
183
- const decompressed = await decompressDataAndCheckHash(message.data);
184
- if (decompressed.result) {
185
- callback(decompressed.result);
186
- } else {
187
- throw new InternalError("No valid result in the response");
188
- }
189
- });
190
- const compressedMessage = await hashAndCompressData(args);
191
- messageHandler.sendEvent({
192
- id: channelId,
193
- topic: args.method,
194
- data: compressedMessage
195
- });
196
- };
197
- const destroy = async () => {
198
- channelManager.destroy();
199
- messageHandler.cleanup();
200
- iframe.remove();
201
- };
202
- const waitForSetup = postConnectionSetup({
203
- config,
204
- messageHandler,
205
- lifecycleManager
206
- });
207
- return {
208
- config,
209
- waitForConnection: lifecycleManager.isConnected,
210
- waitForSetup,
211
- request,
212
- listenerRequest,
213
- destroy
214
- };
215
- }
216
- async function postConnectionSetup({
217
- config,
218
- messageHandler,
219
- lifecycleManager
220
- }) {
221
- await lifecycleManager.isConnected;
222
- enableButtonShare(config);
223
- const pushCss = async () => {
224
- const cssLink = config.metadata.css;
225
- if (!cssLink) return;
226
- messageHandler.sendEvent({
227
- clientLifecycle: "modal-css",
228
- data: { cssLink }
229
- });
230
- };
231
- const pushBackup = async () => {
232
- if (typeof window === "undefined") return;
233
- const backup = window.localStorage.getItem(BACKUP_KEY);
234
- if (!backup) return;
235
- messageHandler.sendEvent({
236
- clientLifecycle: "restore-backup",
237
- data: { backup }
238
- });
239
- };
240
- await Promise.all([pushCss(), pushBackup()]);
241
- }
242
-
243
- export {
244
- createIFrameNexusClient
245
- };
@@ -1,29 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
- var _chunkDE2KWQVPcjs = require('../../chunk-DE2KWQVP.cjs');
14
- require('../../chunk-H4BK3CNV.cjs');
15
- require('../../chunk-4PVF24BB.cjs');
16
- require('../../chunk-P3J2BIUT.cjs');
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- exports.displayModal = _chunkDE2KWQVPcjs.displayModal; exports.getProductInformation = _chunkDE2KWQVPcjs.getProductInformation; exports.modalBuilder = _chunkDE2KWQVPcjs.modalBuilder; exports.openSso = _chunkDE2KWQVPcjs.openSso; exports.processReferral = _chunkDE2KWQVPcjs.processReferral; exports.referralInteraction = _chunkDE2KWQVPcjs.referralInteraction; exports.sendInteraction = _chunkDE2KWQVPcjs.sendInteraction; exports.sendTransaction = _chunkDE2KWQVPcjs.sendTransaction; exports.siweAuthenticate = _chunkDE2KWQVPcjs.siweAuthenticate; exports.trackPurchaseStatus = _chunkDE2KWQVPcjs.trackPurchaseStatus; exports.watchWalletStatus = _chunkDE2KWQVPcjs.watchWalletStatus;
@@ -1,92 +0,0 @@
1
- import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType, G as GetProductInformationReturnType, k as SendTransactionModalStepType, o as FinalModalStepType, q as FinalActionType, L as LoginModalStepType, n as OpenInteractionSessionModalStepType, c as ModalRpcMetadata } from '../../FrakContext-DKSVaeVb.cjs';
2
- import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-BngPoHA0.cjs';
3
- import { P as ProcessReferralOptions } from '../../processReferral-DUP8imQV.cjs';
4
- export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-DUP8imQV.cjs';
5
- import { Hex } from 'viem';
6
- import 'viem/chains';
7
- import 'viem/siwe';
8
-
9
- /**
10
- * Function used to watch the current nexus wallet status
11
- * @param client
12
- * @param callback
13
- */
14
- declare function watchWalletStatus(client: NexusClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
15
-
16
- /**
17
- * Function used to send an interaction
18
- * @param client
19
- * @param productId
20
- * @param interaction
21
- * @param validation
22
- */
23
- declare function sendInteraction(client: NexusClient, { productId, interaction, validation }: SendInteractionParamsType): Promise<SendInteractionReturnType>;
24
-
25
- /**
26
- * Function used to display a modal
27
- * @param client
28
- * @param args
29
- */
30
- declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: NexusClient, { steps, metadata }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
31
-
32
- /**
33
- * Function used to open the SSO
34
- * @param client
35
- * @param args
36
- */
37
- declare function openSso(client: NexusClient, args: OpenSsoParamsType): Promise<void>;
38
-
39
- /**
40
- * Function used to get the current product information
41
- * @param client
42
- */
43
- declare function getProductInformation(client: NexusClient): Promise<GetProductInformationReturnType>;
44
-
45
- /**
46
- * Function used to track the status of a purchase
47
- */
48
- declare function trackPurchaseStatus(args: {
49
- customerId: string | number;
50
- orderId: string | number;
51
- token: string;
52
- }): Promise<void>;
53
-
54
- /**
55
- * Represent the type of the modal step builder
56
- */
57
- type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
58
- params: DisplayModalParamsType<Steps>;
59
- sendTx: (options: SendTransactionModalStepType["params"]) => ModalStepBuilder<[...Steps, SendTransactionModalStepType]>;
60
- reward: (options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
61
- sharing: (sharingOptions?: Extract<FinalActionType, {
62
- key: "sharing";
63
- }>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
64
- display: () => Promise<ModalRpcStepsResultType<Steps>>;
65
- };
66
- /**
67
- * Represent the output type of the modal builder
68
- */
69
- type ModalBuilder = ModalStepBuilder<[
70
- LoginModalStepType,
71
- OpenInteractionSessionModalStepType
72
- ]>;
73
- /**
74
- * Simple modal builder params builder
75
- * @param client
76
- * @param metadata
77
- * @param login
78
- * @param openSession
79
- */
80
- declare function modalBuilder(client: NexusClient, { metadata, login, openSession, }: {
81
- metadata?: ModalRpcMetadata;
82
- login?: LoginModalStepType["params"];
83
- openSession?: OpenInteractionSessionModalStepType["params"];
84
- }): ModalBuilder;
85
-
86
- declare function referralInteraction(client: NexusClient, { productId, modalConfig, options, }?: {
87
- productId?: Hex;
88
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
89
- options?: ProcessReferralOptions;
90
- }): Promise<unknown>;
91
-
92
- export { type ModalBuilder, type ModalStepBuilder, displayModal, getProductInformation, modalBuilder, openSso, referralInteraction, sendInteraction, trackPurchaseStatus, watchWalletStatus };