@frak-labs/nexus-sdk 0.0.11 → 0.0.13
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/dist/{chunk-V3S6RBRJ.cjs → chunk-2SGRLI7T.cjs} +92 -46
- package/dist/{chunk-7MVQQ2X6.js → chunk-FF32LTPI.js} +91 -45
- package/dist/{client-gE3fYzkD.d.ts → client-B6_BIGc3.d.ts} +39 -14
- package/dist/{client-C7u9zGwC.d.cts → client-Oily5ph8.d.cts} +39 -14
- package/dist/core/actions/index.d.cts +2 -2
- package/dist/core/actions/index.d.ts +2 -2
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.d.cts +18 -18
- package/dist/core/index.d.ts +18 -18
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +29 -25
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +7 -3
- package/dist/{sendTransaction-DpJTfGJc.d.ts → sendTransaction-BHqCq_9X.d.ts} +1 -1
- package/dist/{sendTransaction-BZW627cT.d.cts → sendTransaction-BKKYEt8p.d.cts} +1 -1
- package/package.json +3 -3
|
@@ -10,6 +10,11 @@ var FrakRpcError = class extends Error {
|
|
|
10
10
|
this.data = data;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
var InternalError = class extends FrakRpcError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(RpcErrorCodes.internalError, message);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
13
18
|
var ClientNotFound = class extends FrakRpcError {
|
|
14
19
|
constructor() {
|
|
15
20
|
super(RpcErrorCodes.clientNotConnected, "Client not found");
|
|
@@ -126,6 +131,9 @@ async function decompressJson(data) {
|
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
|
|
134
|
+
// src/core/utils/constants.ts
|
|
135
|
+
var BACKUP_KEY = "nexus-wallet-backup";
|
|
136
|
+
|
|
129
137
|
// src/core/clients/transports/iframeChannelManager.ts
|
|
130
138
|
function createIFrameChannelManager() {
|
|
131
139
|
const channels = /* @__PURE__ */ new Map();
|
|
@@ -197,12 +205,47 @@ function changeIframeVisibility({
|
|
|
197
205
|
iframe.style.pointerEvents = "auto";
|
|
198
206
|
}
|
|
199
207
|
|
|
208
|
+
// src/core/clients/transports/iframeLifecycleManager.ts
|
|
209
|
+
function createIFrameLifecycleManager({
|
|
210
|
+
iframe
|
|
211
|
+
}) {
|
|
212
|
+
const isConnectedDeferred = new Deferred();
|
|
213
|
+
const handler = async (messageEvent) => {
|
|
214
|
+
switch (messageEvent.iframeLifecycle) {
|
|
215
|
+
// Resolve the isConnected promise
|
|
216
|
+
case "connected":
|
|
217
|
+
isConnectedDeferred.resolve(true);
|
|
218
|
+
break;
|
|
219
|
+
// Perform a nexus backup
|
|
220
|
+
case "do-backup":
|
|
221
|
+
if (messageEvent.data.backup) {
|
|
222
|
+
localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
|
|
223
|
+
} else {
|
|
224
|
+
localStorage.removeItem(BACKUP_KEY);
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
// Change iframe visibility
|
|
228
|
+
case "show":
|
|
229
|
+
case "hide":
|
|
230
|
+
changeIframeVisibility({
|
|
231
|
+
iframe,
|
|
232
|
+
isVisible: messageEvent.iframeLifecycle === "show"
|
|
233
|
+
});
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
return {
|
|
238
|
+
handleEvent: handler,
|
|
239
|
+
isConnected: isConnectedDeferred.promise
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
200
243
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
201
244
|
function createIFrameMessageHandler({
|
|
202
245
|
nexusWalletUrl,
|
|
203
|
-
metadata,
|
|
204
246
|
iframe,
|
|
205
|
-
channelManager
|
|
247
|
+
channelManager,
|
|
248
|
+
iframeLifecycleManager
|
|
206
249
|
}) {
|
|
207
250
|
if (typeof window === "undefined") {
|
|
208
251
|
throw new FrakRpcError(
|
|
@@ -217,7 +260,6 @@ function createIFrameMessageHandler({
|
|
|
217
260
|
);
|
|
218
261
|
}
|
|
219
262
|
const contentWindow = iframe.contentWindow;
|
|
220
|
-
const isConnectedDeferred = new Deferred();
|
|
221
263
|
const msgHandler = async (event) => {
|
|
222
264
|
if (!event.origin) {
|
|
223
265
|
return;
|
|
@@ -225,19 +267,14 @@ function createIFrameMessageHandler({
|
|
|
225
267
|
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
226
268
|
return;
|
|
227
269
|
}
|
|
228
|
-
if ("
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
iframe,
|
|
237
|
-
isVisible: event.data.lifecycle === "show"
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
270
|
+
if ("iframeLifecycle" in event.data) {
|
|
271
|
+
await iframeLifecycleManager.handleEvent(event.data);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if ("clientLifecycle" in event.data) {
|
|
275
|
+
console.error(
|
|
276
|
+
"Client lifecycle event received on the client side, dismissing it"
|
|
277
|
+
);
|
|
241
278
|
return;
|
|
242
279
|
}
|
|
243
280
|
const channel = event.data.id;
|
|
@@ -256,34 +293,11 @@ function createIFrameMessageHandler({
|
|
|
256
293
|
const cleanup = () => {
|
|
257
294
|
window.removeEventListener("message", msgHandler);
|
|
258
295
|
};
|
|
259
|
-
const isConnected = injectCssOnConnect({
|
|
260
|
-
isConnected: isConnectedDeferred.promise,
|
|
261
|
-
metadata,
|
|
262
|
-
sendEvent
|
|
263
|
-
});
|
|
264
296
|
return {
|
|
265
|
-
isConnected,
|
|
266
297
|
sendEvent,
|
|
267
298
|
cleanup
|
|
268
299
|
};
|
|
269
300
|
}
|
|
270
|
-
function injectCssOnConnect({
|
|
271
|
-
isConnected,
|
|
272
|
-
metadata,
|
|
273
|
-
sendEvent
|
|
274
|
-
}) {
|
|
275
|
-
const css = _optionalChain([metadata, 'optionalAccess', _11 => _11.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
301
|
|
|
288
302
|
// src/core/clients/createIFrameNexusClient.ts
|
|
289
303
|
function createIFrameNexusClient({
|
|
@@ -291,14 +305,15 @@ function createIFrameNexusClient({
|
|
|
291
305
|
iframe
|
|
292
306
|
}) {
|
|
293
307
|
const channelManager = createIFrameChannelManager();
|
|
308
|
+
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
294
309
|
const messageHandler = createIFrameMessageHandler({
|
|
295
310
|
nexusWalletUrl: config.walletUrl,
|
|
296
|
-
metadata: config.metadata,
|
|
297
311
|
iframe,
|
|
298
|
-
channelManager
|
|
312
|
+
channelManager,
|
|
313
|
+
iframeLifecycleManager: lifecycleManager
|
|
299
314
|
});
|
|
300
315
|
const request = async (args) => {
|
|
301
|
-
const isConnected = await
|
|
316
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
302
317
|
if (!isConnected) {
|
|
303
318
|
throw new FrakRpcError(
|
|
304
319
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -313,7 +328,7 @@ function createIFrameNexusClient({
|
|
|
313
328
|
new FrakRpcError(
|
|
314
329
|
decompressed.error.code,
|
|
315
330
|
decompressed.error.message,
|
|
316
|
-
_optionalChain([decompressed, 'access',
|
|
331
|
+
_optionalChain([decompressed, 'access', _11 => _11.error, 'optionalAccess', _12 => _12.data])
|
|
317
332
|
)
|
|
318
333
|
);
|
|
319
334
|
} else {
|
|
@@ -324,14 +339,13 @@ function createIFrameNexusClient({
|
|
|
324
339
|
const compressedMessage = await hashAndCompressData(args);
|
|
325
340
|
messageHandler.sendEvent({
|
|
326
341
|
id: channelId,
|
|
327
|
-
// @ts-ignore, todo: idk why the fck it's needed
|
|
328
342
|
topic: args.method,
|
|
329
343
|
data: compressedMessage
|
|
330
344
|
});
|
|
331
345
|
return result.promise;
|
|
332
346
|
};
|
|
333
347
|
const listenerRequest = async (args, callback) => {
|
|
334
|
-
const isConnected = await
|
|
348
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
335
349
|
if (!isConnected) {
|
|
336
350
|
throw new FrakRpcError(
|
|
337
351
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -343,6 +357,7 @@ function createIFrameNexusClient({
|
|
|
343
357
|
if (decompressed.result) {
|
|
344
358
|
callback(decompressed.result);
|
|
345
359
|
} else {
|
|
360
|
+
throw new InternalError("No valid result in the response");
|
|
346
361
|
}
|
|
347
362
|
});
|
|
348
363
|
const compressedMessage = await hashAndCompressData(args);
|
|
@@ -357,14 +372,45 @@ function createIFrameNexusClient({
|
|
|
357
372
|
messageHandler.cleanup();
|
|
358
373
|
iframe.remove();
|
|
359
374
|
};
|
|
375
|
+
const waitForSetup = postConnectionSetup({
|
|
376
|
+
config,
|
|
377
|
+
messageHandler,
|
|
378
|
+
lifecycleManager
|
|
379
|
+
});
|
|
360
380
|
return {
|
|
361
381
|
config,
|
|
362
|
-
waitForConnection:
|
|
382
|
+
waitForConnection: lifecycleManager.isConnected,
|
|
383
|
+
waitForSetup,
|
|
363
384
|
request,
|
|
364
385
|
listenerRequest,
|
|
365
386
|
destroy
|
|
366
387
|
};
|
|
367
388
|
}
|
|
389
|
+
async function postConnectionSetup({
|
|
390
|
+
config,
|
|
391
|
+
messageHandler,
|
|
392
|
+
lifecycleManager
|
|
393
|
+
}) {
|
|
394
|
+
await lifecycleManager.isConnected;
|
|
395
|
+
const pushCss = async () => {
|
|
396
|
+
const cssLink = config.metadata.css;
|
|
397
|
+
if (!cssLink) return;
|
|
398
|
+
messageHandler.sendEvent({
|
|
399
|
+
clientLifecycle: "modal-css",
|
|
400
|
+
data: { cssLink }
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
const pushBackup = async () => {
|
|
404
|
+
if (typeof window === "undefined") return;
|
|
405
|
+
const backup = window.localStorage.getItem(BACKUP_KEY);
|
|
406
|
+
if (!backup) return;
|
|
407
|
+
messageHandler.sendEvent({
|
|
408
|
+
clientLifecycle: "restore-backup",
|
|
409
|
+
data: { backup }
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
await Promise.all([pushCss(), pushBackup()]);
|
|
413
|
+
}
|
|
368
414
|
|
|
369
415
|
|
|
370
416
|
|
|
@@ -10,6 +10,11 @@ var FrakRpcError = class extends Error {
|
|
|
10
10
|
this.data = data;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
var InternalError = class extends FrakRpcError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(RpcErrorCodes.internalError, message);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
13
18
|
var ClientNotFound = class extends FrakRpcError {
|
|
14
19
|
constructor() {
|
|
15
20
|
super(RpcErrorCodes.clientNotConnected, "Client not found");
|
|
@@ -126,6 +131,9 @@ async function decompressJson(data) {
|
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
|
|
134
|
+
// src/core/utils/constants.ts
|
|
135
|
+
var BACKUP_KEY = "nexus-wallet-backup";
|
|
136
|
+
|
|
129
137
|
// src/core/clients/transports/iframeChannelManager.ts
|
|
130
138
|
function createIFrameChannelManager() {
|
|
131
139
|
const channels = /* @__PURE__ */ new Map();
|
|
@@ -197,12 +205,47 @@ function changeIframeVisibility({
|
|
|
197
205
|
iframe.style.pointerEvents = "auto";
|
|
198
206
|
}
|
|
199
207
|
|
|
208
|
+
// src/core/clients/transports/iframeLifecycleManager.ts
|
|
209
|
+
function createIFrameLifecycleManager({
|
|
210
|
+
iframe
|
|
211
|
+
}) {
|
|
212
|
+
const isConnectedDeferred = new Deferred();
|
|
213
|
+
const handler = async (messageEvent) => {
|
|
214
|
+
switch (messageEvent.iframeLifecycle) {
|
|
215
|
+
// Resolve the isConnected promise
|
|
216
|
+
case "connected":
|
|
217
|
+
isConnectedDeferred.resolve(true);
|
|
218
|
+
break;
|
|
219
|
+
// Perform a nexus backup
|
|
220
|
+
case "do-backup":
|
|
221
|
+
if (messageEvent.data.backup) {
|
|
222
|
+
localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
|
|
223
|
+
} else {
|
|
224
|
+
localStorage.removeItem(BACKUP_KEY);
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
// Change iframe visibility
|
|
228
|
+
case "show":
|
|
229
|
+
case "hide":
|
|
230
|
+
changeIframeVisibility({
|
|
231
|
+
iframe,
|
|
232
|
+
isVisible: messageEvent.iframeLifecycle === "show"
|
|
233
|
+
});
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
return {
|
|
238
|
+
handleEvent: handler,
|
|
239
|
+
isConnected: isConnectedDeferred.promise
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
200
243
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
201
244
|
function createIFrameMessageHandler({
|
|
202
245
|
nexusWalletUrl,
|
|
203
|
-
metadata,
|
|
204
246
|
iframe,
|
|
205
|
-
channelManager
|
|
247
|
+
channelManager,
|
|
248
|
+
iframeLifecycleManager
|
|
206
249
|
}) {
|
|
207
250
|
if (typeof window === "undefined") {
|
|
208
251
|
throw new FrakRpcError(
|
|
@@ -217,7 +260,6 @@ function createIFrameMessageHandler({
|
|
|
217
260
|
);
|
|
218
261
|
}
|
|
219
262
|
const contentWindow = iframe.contentWindow;
|
|
220
|
-
const isConnectedDeferred = new Deferred();
|
|
221
263
|
const msgHandler = async (event) => {
|
|
222
264
|
if (!event.origin) {
|
|
223
265
|
return;
|
|
@@ -225,19 +267,14 @@ function createIFrameMessageHandler({
|
|
|
225
267
|
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
226
268
|
return;
|
|
227
269
|
}
|
|
228
|
-
if ("
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
iframe,
|
|
237
|
-
isVisible: event.data.lifecycle === "show"
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
270
|
+
if ("iframeLifecycle" in event.data) {
|
|
271
|
+
await iframeLifecycleManager.handleEvent(event.data);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if ("clientLifecycle" in event.data) {
|
|
275
|
+
console.error(
|
|
276
|
+
"Client lifecycle event received on the client side, dismissing it"
|
|
277
|
+
);
|
|
241
278
|
return;
|
|
242
279
|
}
|
|
243
280
|
const channel = event.data.id;
|
|
@@ -256,34 +293,11 @@ function createIFrameMessageHandler({
|
|
|
256
293
|
const cleanup = () => {
|
|
257
294
|
window.removeEventListener("message", msgHandler);
|
|
258
295
|
};
|
|
259
|
-
const isConnected = injectCssOnConnect({
|
|
260
|
-
isConnected: isConnectedDeferred.promise,
|
|
261
|
-
metadata,
|
|
262
|
-
sendEvent
|
|
263
|
-
});
|
|
264
296
|
return {
|
|
265
|
-
isConnected,
|
|
266
297
|
sendEvent,
|
|
267
298
|
cleanup
|
|
268
299
|
};
|
|
269
300
|
}
|
|
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
301
|
|
|
288
302
|
// src/core/clients/createIFrameNexusClient.ts
|
|
289
303
|
function createIFrameNexusClient({
|
|
@@ -291,14 +305,15 @@ function createIFrameNexusClient({
|
|
|
291
305
|
iframe
|
|
292
306
|
}) {
|
|
293
307
|
const channelManager = createIFrameChannelManager();
|
|
308
|
+
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
294
309
|
const messageHandler = createIFrameMessageHandler({
|
|
295
310
|
nexusWalletUrl: config.walletUrl,
|
|
296
|
-
metadata: config.metadata,
|
|
297
311
|
iframe,
|
|
298
|
-
channelManager
|
|
312
|
+
channelManager,
|
|
313
|
+
iframeLifecycleManager: lifecycleManager
|
|
299
314
|
});
|
|
300
315
|
const request = async (args) => {
|
|
301
|
-
const isConnected = await
|
|
316
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
302
317
|
if (!isConnected) {
|
|
303
318
|
throw new FrakRpcError(
|
|
304
319
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -324,14 +339,13 @@ function createIFrameNexusClient({
|
|
|
324
339
|
const compressedMessage = await hashAndCompressData(args);
|
|
325
340
|
messageHandler.sendEvent({
|
|
326
341
|
id: channelId,
|
|
327
|
-
// @ts-ignore, todo: idk why the fck it's needed
|
|
328
342
|
topic: args.method,
|
|
329
343
|
data: compressedMessage
|
|
330
344
|
});
|
|
331
345
|
return result.promise;
|
|
332
346
|
};
|
|
333
347
|
const listenerRequest = async (args, callback) => {
|
|
334
|
-
const isConnected = await
|
|
348
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
335
349
|
if (!isConnected) {
|
|
336
350
|
throw new FrakRpcError(
|
|
337
351
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -343,6 +357,7 @@ function createIFrameNexusClient({
|
|
|
343
357
|
if (decompressed.result) {
|
|
344
358
|
callback(decompressed.result);
|
|
345
359
|
} else {
|
|
360
|
+
throw new InternalError("No valid result in the response");
|
|
346
361
|
}
|
|
347
362
|
});
|
|
348
363
|
const compressedMessage = await hashAndCompressData(args);
|
|
@@ -357,14 +372,45 @@ function createIFrameNexusClient({
|
|
|
357
372
|
messageHandler.cleanup();
|
|
358
373
|
iframe.remove();
|
|
359
374
|
};
|
|
375
|
+
const waitForSetup = postConnectionSetup({
|
|
376
|
+
config,
|
|
377
|
+
messageHandler,
|
|
378
|
+
lifecycleManager
|
|
379
|
+
});
|
|
360
380
|
return {
|
|
361
381
|
config,
|
|
362
|
-
waitForConnection:
|
|
382
|
+
waitForConnection: lifecycleManager.isConnected,
|
|
383
|
+
waitForSetup,
|
|
363
384
|
request,
|
|
364
385
|
listenerRequest,
|
|
365
386
|
destroy
|
|
366
387
|
};
|
|
367
388
|
}
|
|
389
|
+
async function postConnectionSetup({
|
|
390
|
+
config,
|
|
391
|
+
messageHandler,
|
|
392
|
+
lifecycleManager
|
|
393
|
+
}) {
|
|
394
|
+
await lifecycleManager.isConnected;
|
|
395
|
+
const pushCss = async () => {
|
|
396
|
+
const cssLink = config.metadata.css;
|
|
397
|
+
if (!cssLink) return;
|
|
398
|
+
messageHandler.sendEvent({
|
|
399
|
+
clientLifecycle: "modal-css",
|
|
400
|
+
data: { cssLink }
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
const pushBackup = async () => {
|
|
404
|
+
if (typeof window === "undefined") return;
|
|
405
|
+
const backup = window.localStorage.getItem(BACKUP_KEY);
|
|
406
|
+
if (!backup) return;
|
|
407
|
+
messageHandler.sendEvent({
|
|
408
|
+
clientLifecycle: "restore-backup",
|
|
409
|
+
data: { backup }
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
await Promise.all([pushCss(), pushBackup()]);
|
|
413
|
+
}
|
|
368
414
|
|
|
369
415
|
export {
|
|
370
416
|
FrakRpcError,
|
|
@@ -15,6 +15,37 @@ type NexusWalletSdkConfig = Readonly<{
|
|
|
15
15
|
domain: string;
|
|
16
16
|
}>;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Event related to the iframe lifecycle
|
|
20
|
+
*/
|
|
21
|
+
type IFrameLifecycleEvent = {
|
|
22
|
+
iframeLifecycle: "connected" | "show" | "hide";
|
|
23
|
+
data?: never;
|
|
24
|
+
} | DoBackupEvent;
|
|
25
|
+
type DoBackupEvent = {
|
|
26
|
+
iframeLifecycle: "do-backup";
|
|
27
|
+
data: {
|
|
28
|
+
backup?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Event related to the iframe lifecycle
|
|
34
|
+
*/
|
|
35
|
+
type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent;
|
|
36
|
+
type CustomCssEvent = {
|
|
37
|
+
clientLifecycle: "modal-css";
|
|
38
|
+
data: {
|
|
39
|
+
cssLink: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type RestoreBackupEvent = {
|
|
43
|
+
clientLifecycle: "restore-backup";
|
|
44
|
+
data: {
|
|
45
|
+
backup: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
18
49
|
/**
|
|
19
50
|
* SSO Metadata
|
|
20
51
|
*/
|
|
@@ -64,9 +95,7 @@ type LoginWithoutSso = {
|
|
|
64
95
|
/**
|
|
65
96
|
* Generic type of modal we will display to the end user
|
|
66
97
|
*/
|
|
67
|
-
type LoginModalStepType = GenericModalStepType<"login", {
|
|
68
|
-
articleUrl?: string;
|
|
69
|
-
} & (LoginWithSso | LoginWithoutSso), {
|
|
98
|
+
type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
70
99
|
wallet: Address;
|
|
71
100
|
}>;
|
|
72
101
|
|
|
@@ -276,7 +305,7 @@ type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedPar
|
|
|
276
305
|
/**
|
|
277
306
|
* Type used for a one shot request function
|
|
278
307
|
*/
|
|
279
|
-
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>>(args: TParameters, callback: (result:
|
|
308
|
+
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
280
309
|
/**
|
|
281
310
|
* IFrame transport interface
|
|
282
311
|
*/
|
|
@@ -285,6 +314,10 @@ type IFrameTransport = {
|
|
|
285
314
|
* Wait for the connection to be established
|
|
286
315
|
*/
|
|
287
316
|
waitForConnection: Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Wait for the setup to be done
|
|
319
|
+
*/
|
|
320
|
+
waitForSetup: Promise<void>;
|
|
288
321
|
/**
|
|
289
322
|
* Function used to perform a single request via the iframe transport
|
|
290
323
|
*/
|
|
@@ -301,7 +334,7 @@ type IFrameTransport = {
|
|
|
301
334
|
/**
|
|
302
335
|
* Represent an iframe event
|
|
303
336
|
*/
|
|
304
|
-
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent;
|
|
337
|
+
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
305
338
|
/**
|
|
306
339
|
* Represent an iframe rpc event
|
|
307
340
|
*/
|
|
@@ -313,14 +346,6 @@ type IFrameRpcEvent = {
|
|
|
313
346
|
compressedHash: string;
|
|
314
347
|
};
|
|
315
348
|
};
|
|
316
|
-
type IFrameLifecycleEvent = {
|
|
317
|
-
lifecycle: "connected" | "show" | "hide";
|
|
318
|
-
data: never;
|
|
319
|
-
} | LifecycleEventCSS;
|
|
320
|
-
type LifecycleEventCSS = {
|
|
321
|
-
lifecycle: "modal-css";
|
|
322
|
-
data: string;
|
|
323
|
-
};
|
|
324
349
|
|
|
325
350
|
/**
|
|
326
351
|
* Representing a Nexus client
|
|
@@ -329,4 +354,4 @@ type NexusClient = {
|
|
|
329
354
|
config: NexusWalletSdkConfig;
|
|
330
355
|
} & IFrameTransport;
|
|
331
356
|
|
|
332
|
-
export type { DisplayModalParamsType as D, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, LoginModalStepType as L, ModalRpcMetadata as M, NexusClient as N, OpenSsoParamsType as O, RpcResponse as R, SiweAuthenticationParams as S, WalletStatusReturnType as W, SiweAuthenticateReturnType as a, SendTransactionModalStepType as b, SendTransactionReturnType as c, ModalStepTypes as d, ModalRpcStepsResultType as e, NexusWalletSdkConfig as f, SuccessModalStepType as g, SsoMetadata as h, ModalRpcStepsInput as i, ModalStepMetadata as j, SiweAuthenticateModalStepType as k, SendTransactionTxType as l, OpenInteractionSessionReturnType as m, OpenInteractionSessionModalStepType as n, IFrameTransport as o, IFrameRpcEvent as p, IFrameEvent as q,
|
|
357
|
+
export type { ClientLifecycleEvent as C, DisplayModalParamsType as D, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, LoginModalStepType as L, ModalRpcMetadata as M, NexusClient as N, OpenSsoParamsType as O, RpcResponse as R, SiweAuthenticationParams as S, WalletStatusReturnType as W, SiweAuthenticateReturnType as a, SendTransactionModalStepType as b, SendTransactionReturnType as c, ModalStepTypes as d, ModalRpcStepsResultType as e, NexusWalletSdkConfig as f, SuccessModalStepType as g, SsoMetadata as h, ModalRpcStepsInput as i, ModalStepMetadata as j, SiweAuthenticateModalStepType as k, SendTransactionTxType as l, OpenInteractionSessionReturnType as m, OpenInteractionSessionModalStepType as n, IFrameTransport as o, IFrameRpcEvent as p, IFrameEvent as q, IFrameLifecycleEvent as r, ExtractedReturnTypeFromRpc as s };
|
|
@@ -15,6 +15,37 @@ type NexusWalletSdkConfig = Readonly<{
|
|
|
15
15
|
domain: string;
|
|
16
16
|
}>;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Event related to the iframe lifecycle
|
|
20
|
+
*/
|
|
21
|
+
type IFrameLifecycleEvent = {
|
|
22
|
+
iframeLifecycle: "connected" | "show" | "hide";
|
|
23
|
+
data?: never;
|
|
24
|
+
} | DoBackupEvent;
|
|
25
|
+
type DoBackupEvent = {
|
|
26
|
+
iframeLifecycle: "do-backup";
|
|
27
|
+
data: {
|
|
28
|
+
backup?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Event related to the iframe lifecycle
|
|
34
|
+
*/
|
|
35
|
+
type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent;
|
|
36
|
+
type CustomCssEvent = {
|
|
37
|
+
clientLifecycle: "modal-css";
|
|
38
|
+
data: {
|
|
39
|
+
cssLink: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type RestoreBackupEvent = {
|
|
43
|
+
clientLifecycle: "restore-backup";
|
|
44
|
+
data: {
|
|
45
|
+
backup: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
18
49
|
/**
|
|
19
50
|
* SSO Metadata
|
|
20
51
|
*/
|
|
@@ -64,9 +95,7 @@ type LoginWithoutSso = {
|
|
|
64
95
|
/**
|
|
65
96
|
* Generic type of modal we will display to the end user
|
|
66
97
|
*/
|
|
67
|
-
type LoginModalStepType = GenericModalStepType<"login", {
|
|
68
|
-
articleUrl?: string;
|
|
69
|
-
} & (LoginWithSso | LoginWithoutSso), {
|
|
98
|
+
type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
70
99
|
wallet: Address;
|
|
71
100
|
}>;
|
|
72
101
|
|
|
@@ -276,7 +305,7 @@ type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedPar
|
|
|
276
305
|
/**
|
|
277
306
|
* Type used for a one shot request function
|
|
278
307
|
*/
|
|
279
|
-
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>>(args: TParameters, callback: (result:
|
|
308
|
+
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
280
309
|
/**
|
|
281
310
|
* IFrame transport interface
|
|
282
311
|
*/
|
|
@@ -285,6 +314,10 @@ type IFrameTransport = {
|
|
|
285
314
|
* Wait for the connection to be established
|
|
286
315
|
*/
|
|
287
316
|
waitForConnection: Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Wait for the setup to be done
|
|
319
|
+
*/
|
|
320
|
+
waitForSetup: Promise<void>;
|
|
288
321
|
/**
|
|
289
322
|
* Function used to perform a single request via the iframe transport
|
|
290
323
|
*/
|
|
@@ -301,7 +334,7 @@ type IFrameTransport = {
|
|
|
301
334
|
/**
|
|
302
335
|
* Represent an iframe event
|
|
303
336
|
*/
|
|
304
|
-
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent;
|
|
337
|
+
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
305
338
|
/**
|
|
306
339
|
* Represent an iframe rpc event
|
|
307
340
|
*/
|
|
@@ -313,14 +346,6 @@ type IFrameRpcEvent = {
|
|
|
313
346
|
compressedHash: string;
|
|
314
347
|
};
|
|
315
348
|
};
|
|
316
|
-
type IFrameLifecycleEvent = {
|
|
317
|
-
lifecycle: "connected" | "show" | "hide";
|
|
318
|
-
data: never;
|
|
319
|
-
} | LifecycleEventCSS;
|
|
320
|
-
type LifecycleEventCSS = {
|
|
321
|
-
lifecycle: "modal-css";
|
|
322
|
-
data: string;
|
|
323
|
-
};
|
|
324
349
|
|
|
325
350
|
/**
|
|
326
351
|
* Representing a Nexus client
|
|
@@ -329,4 +354,4 @@ type NexusClient = {
|
|
|
329
354
|
config: NexusWalletSdkConfig;
|
|
330
355
|
} & IFrameTransport;
|
|
331
356
|
|
|
332
|
-
export type { DisplayModalParamsType as D, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, LoginModalStepType as L, ModalRpcMetadata as M, NexusClient as N, OpenSsoParamsType as O, RpcResponse as R, SiweAuthenticationParams as S, WalletStatusReturnType as W, SiweAuthenticateReturnType as a, SendTransactionModalStepType as b, SendTransactionReturnType as c, ModalStepTypes as d, ModalRpcStepsResultType as e, NexusWalletSdkConfig as f, SuccessModalStepType as g, SsoMetadata as h, ModalRpcStepsInput as i, ModalStepMetadata as j, SiweAuthenticateModalStepType as k, SendTransactionTxType as l, OpenInteractionSessionReturnType as m, OpenInteractionSessionModalStepType as n, IFrameTransport as o, IFrameRpcEvent as p, IFrameEvent as q,
|
|
357
|
+
export type { ClientLifecycleEvent as C, DisplayModalParamsType as D, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, LoginModalStepType as L, ModalRpcMetadata as M, NexusClient as N, OpenSsoParamsType as O, RpcResponse as R, SiweAuthenticationParams as S, WalletStatusReturnType as W, SiweAuthenticateReturnType as a, SendTransactionModalStepType as b, SendTransactionReturnType as c, ModalStepTypes as d, ModalRpcStepsResultType as e, NexusWalletSdkConfig as f, SuccessModalStepType as g, SsoMetadata as h, ModalRpcStepsInput as i, ModalStepMetadata as j, SiweAuthenticateModalStepType as k, SendTransactionTxType as l, OpenInteractionSessionReturnType as m, OpenInteractionSessionModalStepType as n, IFrameTransport as o, IFrameRpcEvent as p, IFrameEvent as q, IFrameLifecycleEvent as r, ExtractedReturnTypeFromRpc as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { N as NexusClient, W as WalletStatusReturnType, d as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-
|
|
1
|
+
import { N as NexusClient, W as WalletStatusReturnType, d as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-Oily5ph8.cjs';
|
|
2
2
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-D3-M3nBh.cjs';
|
|
3
|
-
export { b as SendTransactionParams, S as SiweAuthenticateModalParams, a as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-
|
|
3
|
+
export { b as SendTransactionParams, S as SiweAuthenticateModalParams, a as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-BKKYEt8p.cjs';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import 'viem/chains';
|
|
6
6
|
import 'viem/siwe';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { N as NexusClient, W as WalletStatusReturnType, d as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-
|
|
1
|
+
import { N as NexusClient, W as WalletStatusReturnType, d as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-B6_BIGc3.js';
|
|
2
2
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-D3-M3nBh.js';
|
|
3
|
-
export { b as SendTransactionParams, S as SiweAuthenticateModalParams, a as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-
|
|
3
|
+
export { b as SendTransactionParams, S as SiweAuthenticateModalParams, a as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-BHqCq_9X.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import 'viem/chains';
|
|
6
6
|
import 'viem/siwe';
|
package/dist/core/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk2SGRLI7Tcjs = require('../chunk-2SGRLI7T.cjs');
|
|
9
9
|
require('../chunk-ETV4XYOV.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
@@ -14,4 +14,4 @@ require('../chunk-ETV4XYOV.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
exports.FrakRpcError =
|
|
17
|
+
exports.FrakRpcError = _chunk2SGRLI7Tcjs.FrakRpcError; exports.RpcErrorCodes = _chunk2SGRLI7Tcjs.RpcErrorCodes; exports.createIFrameNexusClient = _chunk2SGRLI7Tcjs.createIFrameNexusClient; exports.createIframe = _chunk2SGRLI7Tcjs.createIframe; exports.decompressDataAndCheckHash = _chunk2SGRLI7Tcjs.decompressDataAndCheckHash; exports.hashAndCompressData = _chunk2SGRLI7Tcjs.hashAndCompressData;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import { f as NexusWalletSdkConfig, N as NexusClient } from '../client-
|
|
2
|
-
export { D as DisplayModalParamsType, E as ExtractedParametersFromRpc,
|
|
1
|
+
import { f as NexusWalletSdkConfig, N as NexusClient } from '../client-Oily5ph8.cjs';
|
|
2
|
+
export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, s as ExtractedReturnTypeFromRpc, q as IFrameEvent, r as IFrameLifecycleEvent, p as IFrameRpcEvent, I as IFrameRpcSchema, o as IFrameTransport, L as LoginModalStepType, M as ModalRpcMetadata, i as ModalRpcStepsInput, e as ModalRpcStepsResultType, j as ModalStepMetadata, d as ModalStepTypes, n as OpenInteractionSessionModalStepType, m as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, b as SendTransactionModalStepType, c as SendTransactionReturnType, l as SendTransactionTxType, k as SiweAuthenticateModalStepType, a as SiweAuthenticateReturnType, S as SiweAuthenticationParams, h as SsoMetadata, g as SuccessModalStepType, W as WalletStatusReturnType } from '../client-Oily5ph8.cjs';
|
|
3
3
|
export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.cjs';
|
|
4
4
|
export { F as FrakRpcError, R as RpcErrorCodes } from '../error-C4Zm5nQe.cjs';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'viem/chains';
|
|
7
7
|
import 'viem/siwe';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Create a new iframe Nexus client
|
|
11
|
-
*/
|
|
12
|
-
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
13
|
-
config: NexusWalletSdkConfig;
|
|
14
|
-
iframe: HTMLIFrameElement;
|
|
15
|
-
}): NexusClient;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Create the given iframe
|
|
19
|
-
* @param walletBaseUrl
|
|
20
|
-
*/
|
|
21
|
-
declare function createIframe({ walletBaseUrl, }: {
|
|
22
|
-
walletBaseUrl: string;
|
|
23
|
-
}): Promise<HTMLIFrameElement | undefined>;
|
|
24
|
-
|
|
25
9
|
/**
|
|
26
10
|
* The received encoded data from a client
|
|
27
11
|
* -> The encoded should contain a HashProtectedData once decoded
|
|
@@ -41,6 +25,22 @@ type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
41
25
|
*/
|
|
42
26
|
type KeyProvider<DataType> = (value: DataType) => string[];
|
|
43
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Create a new iframe Nexus client
|
|
30
|
+
*/
|
|
31
|
+
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
32
|
+
config: NexusWalletSdkConfig;
|
|
33
|
+
iframe: HTMLIFrameElement;
|
|
34
|
+
}): NexusClient;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create the given iframe
|
|
38
|
+
* @param walletBaseUrl
|
|
39
|
+
*/
|
|
40
|
+
declare function createIframe({ walletBaseUrl, }: {
|
|
41
|
+
walletBaseUrl: string;
|
|
42
|
+
}): Promise<HTMLIFrameElement | undefined>;
|
|
43
|
+
|
|
44
44
|
/**
|
|
45
45
|
* Compress the given params, and add hash protection to (rapidly) prevent interception modification
|
|
46
46
|
* @param data The params to encode
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import { f as NexusWalletSdkConfig, N as NexusClient } from '../client-
|
|
2
|
-
export { D as DisplayModalParamsType, E as ExtractedParametersFromRpc,
|
|
1
|
+
import { f as NexusWalletSdkConfig, N as NexusClient } from '../client-B6_BIGc3.js';
|
|
2
|
+
export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, s as ExtractedReturnTypeFromRpc, q as IFrameEvent, r as IFrameLifecycleEvent, p as IFrameRpcEvent, I as IFrameRpcSchema, o as IFrameTransport, L as LoginModalStepType, M as ModalRpcMetadata, i as ModalRpcStepsInput, e as ModalRpcStepsResultType, j as ModalStepMetadata, d as ModalStepTypes, n as OpenInteractionSessionModalStepType, m as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, b as SendTransactionModalStepType, c as SendTransactionReturnType, l as SendTransactionTxType, k as SiweAuthenticateModalStepType, a as SiweAuthenticateReturnType, S as SiweAuthenticationParams, h as SsoMetadata, g as SuccessModalStepType, W as WalletStatusReturnType } from '../client-B6_BIGc3.js';
|
|
3
3
|
export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.js';
|
|
4
4
|
export { F as FrakRpcError, R as RpcErrorCodes } from '../error-C4Zm5nQe.js';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'viem/chains';
|
|
7
7
|
import 'viem/siwe';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Create a new iframe Nexus client
|
|
11
|
-
*/
|
|
12
|
-
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
13
|
-
config: NexusWalletSdkConfig;
|
|
14
|
-
iframe: HTMLIFrameElement;
|
|
15
|
-
}): NexusClient;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Create the given iframe
|
|
19
|
-
* @param walletBaseUrl
|
|
20
|
-
*/
|
|
21
|
-
declare function createIframe({ walletBaseUrl, }: {
|
|
22
|
-
walletBaseUrl: string;
|
|
23
|
-
}): Promise<HTMLIFrameElement | undefined>;
|
|
24
|
-
|
|
25
9
|
/**
|
|
26
10
|
* The received encoded data from a client
|
|
27
11
|
* -> The encoded should contain a HashProtectedData once decoded
|
|
@@ -41,6 +25,22 @@ type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
41
25
|
*/
|
|
42
26
|
type KeyProvider<DataType> = (value: DataType) => string[];
|
|
43
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Create a new iframe Nexus client
|
|
30
|
+
*/
|
|
31
|
+
declare function createIFrameNexusClient({ config, iframe, }: {
|
|
32
|
+
config: NexusWalletSdkConfig;
|
|
33
|
+
iframe: HTMLIFrameElement;
|
|
34
|
+
}): NexusClient;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create the given iframe
|
|
38
|
+
* @param walletBaseUrl
|
|
39
|
+
*/
|
|
40
|
+
declare function createIframe({ walletBaseUrl, }: {
|
|
41
|
+
walletBaseUrl: string;
|
|
42
|
+
}): Promise<HTMLIFrameElement | undefined>;
|
|
43
|
+
|
|
44
44
|
/**
|
|
45
45
|
* Compress the given params, and add hash protection to (rapidly) prevent interception modification
|
|
46
46
|
* @param data The params to encode
|
package/dist/core/index.js
CHANGED
package/dist/react/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk2SGRLI7Tcjs = require('../chunk-2SGRLI7T.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -51,8 +51,8 @@ function NexusConfigProvider(parameters) {
|
|
|
51
51
|
function useNexusConfig() {
|
|
52
52
|
const config = _react.useContext.call(void 0, NexusConfigContext);
|
|
53
53
|
if (!config) {
|
|
54
|
-
throw new (0,
|
|
55
|
-
|
|
54
|
+
throw new (0, _chunk2SGRLI7Tcjs.FrakRpcError)(
|
|
55
|
+
_chunk2SGRLI7Tcjs.RpcErrorCodes.configError,
|
|
56
56
|
"Nexus config not found"
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -85,9 +85,9 @@ function useWalletStatus() {
|
|
|
85
85
|
queryKey: ["nexus-sdk", "wallet-status-listener"],
|
|
86
86
|
queryFn: async () => {
|
|
87
87
|
if (!client) {
|
|
88
|
-
throw new (0,
|
|
88
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
89
89
|
}
|
|
90
|
-
const firstResult = new (0,
|
|
90
|
+
const firstResult = new (0, _chunk2SGRLI7Tcjs.Deferred)();
|
|
91
91
|
let hasResolved = false;
|
|
92
92
|
await _chunkS5FVCA2Ecjs.watchWalletStatus.call(void 0, client, (status) => {
|
|
93
93
|
newStatusUpdated(status);
|
|
@@ -113,7 +113,7 @@ function useSendTransactionAction({
|
|
|
113
113
|
mutationKey: ["nexus-sdk", "send-transaction"],
|
|
114
114
|
mutationFn: async (params) => {
|
|
115
115
|
if (!client) {
|
|
116
|
-
throw new (0,
|
|
116
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
117
117
|
}
|
|
118
118
|
return _chunkS5FVCA2Ecjs.sendTransaction.call(void 0, client, params);
|
|
119
119
|
}
|
|
@@ -135,7 +135,7 @@ function useSiweAuthenticate({
|
|
|
135
135
|
],
|
|
136
136
|
mutationFn: async (params) => {
|
|
137
137
|
if (!client) {
|
|
138
|
-
throw new (0,
|
|
138
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
139
139
|
}
|
|
140
140
|
return _chunkS5FVCA2Ecjs.siweAuthenticate.call(void 0, client, params);
|
|
141
141
|
}
|
|
@@ -158,7 +158,7 @@ function useDisplayModal({
|
|
|
158
158
|
mutationKey: ["nexus-sdk", "display-modal"],
|
|
159
159
|
mutationFn: async (args) => {
|
|
160
160
|
if (!client) {
|
|
161
|
-
throw new (0,
|
|
161
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
162
162
|
}
|
|
163
163
|
return _chunkS5FVCA2Ecjs.displayModal.call(void 0, client, args);
|
|
164
164
|
}
|
|
@@ -176,7 +176,7 @@ function useSendInteraction({
|
|
|
176
176
|
mutationKey: ["nexus-sdk", "send-interaction"],
|
|
177
177
|
mutationFn: async (params) => {
|
|
178
178
|
if (!client) {
|
|
179
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
180
180
|
}
|
|
181
181
|
return _chunkS5FVCA2Ecjs.sendInteraction.call(void 0, client, params);
|
|
182
182
|
}
|
|
@@ -233,7 +233,7 @@ function useNexusContext() {
|
|
|
233
233
|
const url = new URL(location.href);
|
|
234
234
|
const nexusContext2 = url.searchParams.get(contextKey);
|
|
235
235
|
if (!nexusContext2) return null;
|
|
236
|
-
const parsedContext = await
|
|
236
|
+
const parsedContext = await _chunk2SGRLI7Tcjs.decompressJson.call(void 0, nexusContext2);
|
|
237
237
|
if (!parsedContext) return null;
|
|
238
238
|
return parsedContext;
|
|
239
239
|
},
|
|
@@ -244,7 +244,7 @@ function useNexusContext() {
|
|
|
244
244
|
mutationFn: async (newContext) => {
|
|
245
245
|
if (!location || typeof window === "undefined") return;
|
|
246
246
|
const fullNewContext = nexusContext ? { ...nexusContext, ...newContext } : newContext;
|
|
247
|
-
const compressedContext = await
|
|
247
|
+
const compressedContext = await _chunk2SGRLI7Tcjs.compressJson.call(void 0, fullNewContext);
|
|
248
248
|
if (!compressedContext) return;
|
|
249
249
|
const url = new URL(location.href);
|
|
250
250
|
url.searchParams.set(contextKey, compressedContext);
|
|
@@ -272,13 +272,16 @@ function useReferralInteraction({
|
|
|
272
272
|
});
|
|
273
273
|
const processReferral = _react.useCallback.call(void 0, async () => {
|
|
274
274
|
try {
|
|
275
|
-
|
|
276
|
-
if (!_optionalChain([nexusContext, 'optionalAccess',
|
|
275
|
+
let currentWallet = _optionalChain([walletStatus, 'optionalAccess', _10 => _10.key]) === "connected" ? walletStatus.wallet : void 0;
|
|
276
|
+
if (!_optionalChain([nexusContext, 'optionalAccess', _11 => _11.r])) {
|
|
277
277
|
if (currentWallet) {
|
|
278
278
|
await updateContextAsync({ r: currentWallet });
|
|
279
279
|
}
|
|
280
280
|
return "no-referrer";
|
|
281
281
|
}
|
|
282
|
+
if (!currentWallet) {
|
|
283
|
+
currentWallet = await ensureWalletConnected();
|
|
284
|
+
}
|
|
282
285
|
if (currentWallet && _viem.isAddressEqual.call(void 0, nexusContext.r, currentWallet)) {
|
|
283
286
|
return "self-referral";
|
|
284
287
|
}
|
|
@@ -298,7 +301,8 @@ function useReferralInteraction({
|
|
|
298
301
|
contentId,
|
|
299
302
|
ensureWalletConnected,
|
|
300
303
|
sendInteraction2,
|
|
301
|
-
updateContextAsync
|
|
304
|
+
updateContextAsync,
|
|
305
|
+
walletStatus
|
|
302
306
|
]);
|
|
303
307
|
const {
|
|
304
308
|
data: referralState,
|
|
@@ -310,8 +314,8 @@ function useReferralInteraction({
|
|
|
310
314
|
queryKey: [
|
|
311
315
|
"nexus-sdk",
|
|
312
316
|
"auto-referral-interaction",
|
|
313
|
-
_nullishCoalesce(_optionalChain([nexusContext, 'optionalAccess',
|
|
314
|
-
_nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess',
|
|
317
|
+
_nullishCoalesce(_optionalChain([nexusContext, 'optionalAccess', _12 => _12.r]), () => ( "no-referrer")),
|
|
318
|
+
_nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess', _13 => _13.key]), () => ( "no-wallet-status"))
|
|
315
319
|
],
|
|
316
320
|
queryFn: processReferral,
|
|
317
321
|
enabled: !!walletStatus
|
|
@@ -328,22 +332,22 @@ function useEnsureWalletConnected({
|
|
|
328
332
|
}) {
|
|
329
333
|
const { mutateAsync: displayModal2 } = useDisplayModal();
|
|
330
334
|
return _react.useCallback.call(void 0, async () => {
|
|
331
|
-
if (_optionalChain([walletStatus, 'optionalAccess',
|
|
335
|
+
if (_optionalChain([walletStatus, 'optionalAccess', _14 => _14.key]) !== "connected" || !walletStatus.interactionSession) {
|
|
332
336
|
if (!modalConfig) {
|
|
333
337
|
return void 0;
|
|
334
338
|
}
|
|
335
339
|
const result = await displayModal2(modalConfig);
|
|
336
|
-
return _nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
340
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _15 => _15.login, 'optionalAccess', _16 => _16.wallet]), () => ( void 0));
|
|
337
341
|
}
|
|
338
342
|
return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
|
|
339
343
|
}, [walletStatus, modalConfig, displayModal2]);
|
|
340
344
|
}
|
|
341
345
|
function mapErrorToState(error) {
|
|
342
|
-
if (error instanceof
|
|
346
|
+
if (error instanceof _chunk2SGRLI7Tcjs.FrakRpcError) {
|
|
343
347
|
switch (error.code) {
|
|
344
|
-
case
|
|
348
|
+
case _chunk2SGRLI7Tcjs.RpcErrorCodes.walletNotConnected:
|
|
345
349
|
return "no-wallet";
|
|
346
|
-
case
|
|
350
|
+
case _chunk2SGRLI7Tcjs.RpcErrorCodes.noInteractionSession:
|
|
347
351
|
return "no-session";
|
|
348
352
|
default:
|
|
349
353
|
return "error";
|
|
@@ -361,7 +365,7 @@ function useOpenSso({ mutations } = {}) {
|
|
|
361
365
|
mutationKey: ["nexus-sdk", "open-sso"],
|
|
362
366
|
mutationFn: async (params) => {
|
|
363
367
|
if (!client) {
|
|
364
|
-
throw new (0,
|
|
368
|
+
throw new (0, _chunk2SGRLI7Tcjs.ClientNotFound)();
|
|
365
369
|
}
|
|
366
370
|
return _chunkS5FVCA2Ecjs.openSso.call(void 0, client, params);
|
|
367
371
|
}
|
|
@@ -379,15 +383,15 @@ function NexusIFrameClientProvider({
|
|
|
379
383
|
const config = useNexusConfig();
|
|
380
384
|
const [client, setClient] = _react.useState.call(void 0, void 0);
|
|
381
385
|
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
382
|
-
...
|
|
386
|
+
..._chunk2SGRLI7Tcjs.baseIframeProps,
|
|
383
387
|
src: `${config.walletUrl}/listener`,
|
|
384
|
-
style: _nullishCoalesce(style, () => (
|
|
388
|
+
style: _nullishCoalesce(style, () => ( _chunk2SGRLI7Tcjs.baseIframeProps.style)),
|
|
385
389
|
ref: (iframe) => {
|
|
386
390
|
if (!iframe || client) {
|
|
387
391
|
return;
|
|
388
392
|
}
|
|
389
393
|
setClient(
|
|
390
|
-
|
|
394
|
+
_chunk2SGRLI7Tcjs.createIFrameNexusClient.call(void 0, {
|
|
391
395
|
iframe,
|
|
392
396
|
config
|
|
393
397
|
})
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-
|
|
3
|
+
import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-Oily5ph8.cjs';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
6
6
|
import * as viem from 'viem';
|
|
7
7
|
import { Hex } from 'viem';
|
|
8
8
|
import { F as FrakRpcError } from '../error-C4Zm5nQe.cjs';
|
|
9
|
-
import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-
|
|
9
|
+
import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-BKKYEt8p.cjs';
|
|
10
10
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.cjs';
|
|
11
11
|
import 'viem/chains';
|
|
12
12
|
import 'viem/siwe';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-
|
|
3
|
+
import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-B6_BIGc3.js';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
6
6
|
import * as viem from 'viem';
|
|
7
7
|
import { Hex } from 'viem';
|
|
8
8
|
import { F as FrakRpcError } from '../error-C4Zm5nQe.js';
|
|
9
|
-
import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-
|
|
9
|
+
import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-BHqCq_9X.js';
|
|
10
10
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.js';
|
|
11
11
|
import 'viem/chains';
|
|
12
12
|
import 'viem/siwe';
|
package/dist/react/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
compressJson,
|
|
8
8
|
createIFrameNexusClient,
|
|
9
9
|
decompressJson
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-FF32LTPI.js";
|
|
11
11
|
import {
|
|
12
12
|
displayModal,
|
|
13
13
|
openSso,
|
|
@@ -272,13 +272,16 @@ function useReferralInteraction({
|
|
|
272
272
|
});
|
|
273
273
|
const processReferral = useCallback2(async () => {
|
|
274
274
|
try {
|
|
275
|
-
|
|
275
|
+
let currentWallet = walletStatus?.key === "connected" ? walletStatus.wallet : void 0;
|
|
276
276
|
if (!nexusContext?.r) {
|
|
277
277
|
if (currentWallet) {
|
|
278
278
|
await updateContextAsync({ r: currentWallet });
|
|
279
279
|
}
|
|
280
280
|
return "no-referrer";
|
|
281
281
|
}
|
|
282
|
+
if (!currentWallet) {
|
|
283
|
+
currentWallet = await ensureWalletConnected();
|
|
284
|
+
}
|
|
282
285
|
if (currentWallet && isAddressEqual(nexusContext.r, currentWallet)) {
|
|
283
286
|
return "self-referral";
|
|
284
287
|
}
|
|
@@ -298,7 +301,8 @@ function useReferralInteraction({
|
|
|
298
301
|
contentId,
|
|
299
302
|
ensureWalletConnected,
|
|
300
303
|
sendInteraction2,
|
|
301
|
-
updateContextAsync
|
|
304
|
+
updateContextAsync,
|
|
305
|
+
walletStatus
|
|
302
306
|
]);
|
|
303
307
|
const {
|
|
304
308
|
data: referralState,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SiweAuthenticationParams, M as ModalRpcMetadata, N as NexusClient, a as SiweAuthenticateReturnType, b as SendTransactionModalStepType, c as SendTransactionReturnType } from './client-
|
|
1
|
+
import { S as SiweAuthenticationParams, M as ModalRpcMetadata, N as NexusClient, a as SiweAuthenticateReturnType, b as SendTransactionModalStepType, c as SendTransactionReturnType } from './client-B6_BIGc3.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Partial SIWE params, since we can rebuild them from the SDK if they are empty
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SiweAuthenticationParams, M as ModalRpcMetadata, N as NexusClient, a as SiweAuthenticateReturnType, b as SendTransactionModalStepType, c as SendTransactionReturnType } from './client-
|
|
1
|
+
import { S as SiweAuthenticationParams, M as ModalRpcMetadata, N as NexusClient, a as SiweAuthenticateReturnType, b as SendTransactionModalStepType, c as SendTransactionReturnType } from './client-Oily5ph8.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Partial SIWE params, since we can rebuild them from the SDK if they are empty
|
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.13",
|
|
15
15
|
"description": "Nexus Wallet client SDK, helping any person to interact with the Frak wallet, and require the unlock of a premium article within the Frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"js-sha256": "^0.11.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@tanstack/react-query": ">=5.
|
|
84
|
+
"@tanstack/react-query": ">=5.52.2",
|
|
85
85
|
"@types/node": "^22",
|
|
86
|
-
"tsup": "^8.2.
|
|
86
|
+
"tsup": "^8.2.4",
|
|
87
87
|
"typescript": "^5"
|
|
88
88
|
}
|
|
89
89
|
}
|