@frak-labs/nexus-sdk 0.0.11 → 0.0.12
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-BJ3CCN5P.cjs} +89 -46
- package/dist/{chunk-7MVQQ2X6.js → chunk-HXVDI2IY.js} +88 -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 +38 -28
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +21 -11
- 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 +1 -1
|
@@ -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,44 @@ 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
|
+
case "connected":
|
|
216
|
+
isConnectedDeferred.resolve(true);
|
|
217
|
+
break;
|
|
218
|
+
case "do-backup":
|
|
219
|
+
if (messageEvent.data.backup) {
|
|
220
|
+
localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
|
|
221
|
+
} else {
|
|
222
|
+
localStorage.removeItem(BACKUP_KEY);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "show":
|
|
226
|
+
case "hide":
|
|
227
|
+
changeIframeVisibility({
|
|
228
|
+
iframe,
|
|
229
|
+
isVisible: messageEvent.iframeLifecycle === "show"
|
|
230
|
+
});
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
handleEvent: handler,
|
|
236
|
+
isConnected: isConnectedDeferred.promise
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
200
240
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
201
241
|
function createIFrameMessageHandler({
|
|
202
242
|
nexusWalletUrl,
|
|
203
|
-
metadata,
|
|
204
243
|
iframe,
|
|
205
|
-
channelManager
|
|
244
|
+
channelManager,
|
|
245
|
+
iframeLifecycleManager
|
|
206
246
|
}) {
|
|
207
247
|
if (typeof window === "undefined") {
|
|
208
248
|
throw new FrakRpcError(
|
|
@@ -217,7 +257,6 @@ function createIFrameMessageHandler({
|
|
|
217
257
|
);
|
|
218
258
|
}
|
|
219
259
|
const contentWindow = iframe.contentWindow;
|
|
220
|
-
const isConnectedDeferred = new Deferred();
|
|
221
260
|
const msgHandler = async (event) => {
|
|
222
261
|
if (!event.origin) {
|
|
223
262
|
return;
|
|
@@ -225,19 +264,14 @@ function createIFrameMessageHandler({
|
|
|
225
264
|
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
226
265
|
return;
|
|
227
266
|
}
|
|
228
|
-
if ("
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
iframe,
|
|
237
|
-
isVisible: event.data.lifecycle === "show"
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
267
|
+
if ("iframeLifecycle" in event.data) {
|
|
268
|
+
await iframeLifecycleManager.handleEvent(event.data);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if ("clientLifecycle" in event.data) {
|
|
272
|
+
console.error(
|
|
273
|
+
"Client lifecycle event received on the client side, dismissing it"
|
|
274
|
+
);
|
|
241
275
|
return;
|
|
242
276
|
}
|
|
243
277
|
const channel = event.data.id;
|
|
@@ -256,34 +290,11 @@ function createIFrameMessageHandler({
|
|
|
256
290
|
const cleanup = () => {
|
|
257
291
|
window.removeEventListener("message", msgHandler);
|
|
258
292
|
};
|
|
259
|
-
const isConnected = injectCssOnConnect({
|
|
260
|
-
isConnected: isConnectedDeferred.promise,
|
|
261
|
-
metadata,
|
|
262
|
-
sendEvent
|
|
263
|
-
});
|
|
264
293
|
return {
|
|
265
|
-
isConnected,
|
|
266
294
|
sendEvent,
|
|
267
295
|
cleanup
|
|
268
296
|
};
|
|
269
297
|
}
|
|
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
298
|
|
|
288
299
|
// src/core/clients/createIFrameNexusClient.ts
|
|
289
300
|
function createIFrameNexusClient({
|
|
@@ -291,14 +302,15 @@ function createIFrameNexusClient({
|
|
|
291
302
|
iframe
|
|
292
303
|
}) {
|
|
293
304
|
const channelManager = createIFrameChannelManager();
|
|
305
|
+
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
294
306
|
const messageHandler = createIFrameMessageHandler({
|
|
295
307
|
nexusWalletUrl: config.walletUrl,
|
|
296
|
-
metadata: config.metadata,
|
|
297
308
|
iframe,
|
|
298
|
-
channelManager
|
|
309
|
+
channelManager,
|
|
310
|
+
iframeLifecycleManager: lifecycleManager
|
|
299
311
|
});
|
|
300
312
|
const request = async (args) => {
|
|
301
|
-
const isConnected = await
|
|
313
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
302
314
|
if (!isConnected) {
|
|
303
315
|
throw new FrakRpcError(
|
|
304
316
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -313,7 +325,7 @@ function createIFrameNexusClient({
|
|
|
313
325
|
new FrakRpcError(
|
|
314
326
|
decompressed.error.code,
|
|
315
327
|
decompressed.error.message,
|
|
316
|
-
_optionalChain([decompressed, 'access',
|
|
328
|
+
_optionalChain([decompressed, 'access', _11 => _11.error, 'optionalAccess', _12 => _12.data])
|
|
317
329
|
)
|
|
318
330
|
);
|
|
319
331
|
} else {
|
|
@@ -324,14 +336,13 @@ function createIFrameNexusClient({
|
|
|
324
336
|
const compressedMessage = await hashAndCompressData(args);
|
|
325
337
|
messageHandler.sendEvent({
|
|
326
338
|
id: channelId,
|
|
327
|
-
// @ts-ignore, todo: idk why the fck it's needed
|
|
328
339
|
topic: args.method,
|
|
329
340
|
data: compressedMessage
|
|
330
341
|
});
|
|
331
342
|
return result.promise;
|
|
332
343
|
};
|
|
333
344
|
const listenerRequest = async (args, callback) => {
|
|
334
|
-
const isConnected = await
|
|
345
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
335
346
|
if (!isConnected) {
|
|
336
347
|
throw new FrakRpcError(
|
|
337
348
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -343,6 +354,7 @@ function createIFrameNexusClient({
|
|
|
343
354
|
if (decompressed.result) {
|
|
344
355
|
callback(decompressed.result);
|
|
345
356
|
} else {
|
|
357
|
+
throw new InternalError("No valid result in the response");
|
|
346
358
|
}
|
|
347
359
|
});
|
|
348
360
|
const compressedMessage = await hashAndCompressData(args);
|
|
@@ -357,14 +369,45 @@ function createIFrameNexusClient({
|
|
|
357
369
|
messageHandler.cleanup();
|
|
358
370
|
iframe.remove();
|
|
359
371
|
};
|
|
372
|
+
const waitForSetup = postConnectionSetup({
|
|
373
|
+
config,
|
|
374
|
+
messageHandler,
|
|
375
|
+
lifecycleManager
|
|
376
|
+
});
|
|
360
377
|
return {
|
|
361
378
|
config,
|
|
362
|
-
waitForConnection:
|
|
379
|
+
waitForConnection: lifecycleManager.isConnected,
|
|
380
|
+
waitForSetup,
|
|
363
381
|
request,
|
|
364
382
|
listenerRequest,
|
|
365
383
|
destroy
|
|
366
384
|
};
|
|
367
385
|
}
|
|
386
|
+
async function postConnectionSetup({
|
|
387
|
+
config,
|
|
388
|
+
messageHandler,
|
|
389
|
+
lifecycleManager
|
|
390
|
+
}) {
|
|
391
|
+
await lifecycleManager.isConnected;
|
|
392
|
+
const pushCss = async () => {
|
|
393
|
+
const cssLink = config.metadata.css;
|
|
394
|
+
if (!cssLink) return;
|
|
395
|
+
messageHandler.sendEvent({
|
|
396
|
+
clientLifecycle: "modal-css",
|
|
397
|
+
data: { cssLink }
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
const pushBackup = async () => {
|
|
401
|
+
if (typeof window === "undefined") return;
|
|
402
|
+
const backup = window.localStorage.getItem(BACKUP_KEY);
|
|
403
|
+
if (!backup) return;
|
|
404
|
+
messageHandler.sendEvent({
|
|
405
|
+
clientLifecycle: "restore-backup",
|
|
406
|
+
data: { backup }
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
await Promise.all([pushCss(), pushBackup()]);
|
|
410
|
+
}
|
|
368
411
|
|
|
369
412
|
|
|
370
413
|
|
|
@@ -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,44 @@ 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
|
+
case "connected":
|
|
216
|
+
isConnectedDeferred.resolve(true);
|
|
217
|
+
break;
|
|
218
|
+
case "do-backup":
|
|
219
|
+
if (messageEvent.data.backup) {
|
|
220
|
+
localStorage.setItem(BACKUP_KEY, messageEvent.data.backup);
|
|
221
|
+
} else {
|
|
222
|
+
localStorage.removeItem(BACKUP_KEY);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "show":
|
|
226
|
+
case "hide":
|
|
227
|
+
changeIframeVisibility({
|
|
228
|
+
iframe,
|
|
229
|
+
isVisible: messageEvent.iframeLifecycle === "show"
|
|
230
|
+
});
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
handleEvent: handler,
|
|
236
|
+
isConnected: isConnectedDeferred.promise
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
200
240
|
// src/core/clients/transports/iframeMessageHandler.ts
|
|
201
241
|
function createIFrameMessageHandler({
|
|
202
242
|
nexusWalletUrl,
|
|
203
|
-
metadata,
|
|
204
243
|
iframe,
|
|
205
|
-
channelManager
|
|
244
|
+
channelManager,
|
|
245
|
+
iframeLifecycleManager
|
|
206
246
|
}) {
|
|
207
247
|
if (typeof window === "undefined") {
|
|
208
248
|
throw new FrakRpcError(
|
|
@@ -217,7 +257,6 @@ function createIFrameMessageHandler({
|
|
|
217
257
|
);
|
|
218
258
|
}
|
|
219
259
|
const contentWindow = iframe.contentWindow;
|
|
220
|
-
const isConnectedDeferred = new Deferred();
|
|
221
260
|
const msgHandler = async (event) => {
|
|
222
261
|
if (!event.origin) {
|
|
223
262
|
return;
|
|
@@ -225,19 +264,14 @@ function createIFrameMessageHandler({
|
|
|
225
264
|
if (new URL(event.origin).origin.toLowerCase() !== new URL(nexusWalletUrl).origin.toLowerCase()) {
|
|
226
265
|
return;
|
|
227
266
|
}
|
|
228
|
-
if ("
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
iframe,
|
|
237
|
-
isVisible: event.data.lifecycle === "show"
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
267
|
+
if ("iframeLifecycle" in event.data) {
|
|
268
|
+
await iframeLifecycleManager.handleEvent(event.data);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if ("clientLifecycle" in event.data) {
|
|
272
|
+
console.error(
|
|
273
|
+
"Client lifecycle event received on the client side, dismissing it"
|
|
274
|
+
);
|
|
241
275
|
return;
|
|
242
276
|
}
|
|
243
277
|
const channel = event.data.id;
|
|
@@ -256,34 +290,11 @@ function createIFrameMessageHandler({
|
|
|
256
290
|
const cleanup = () => {
|
|
257
291
|
window.removeEventListener("message", msgHandler);
|
|
258
292
|
};
|
|
259
|
-
const isConnected = injectCssOnConnect({
|
|
260
|
-
isConnected: isConnectedDeferred.promise,
|
|
261
|
-
metadata,
|
|
262
|
-
sendEvent
|
|
263
|
-
});
|
|
264
293
|
return {
|
|
265
|
-
isConnected,
|
|
266
294
|
sendEvent,
|
|
267
295
|
cleanup
|
|
268
296
|
};
|
|
269
297
|
}
|
|
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
298
|
|
|
288
299
|
// src/core/clients/createIFrameNexusClient.ts
|
|
289
300
|
function createIFrameNexusClient({
|
|
@@ -291,14 +302,15 @@ function createIFrameNexusClient({
|
|
|
291
302
|
iframe
|
|
292
303
|
}) {
|
|
293
304
|
const channelManager = createIFrameChannelManager();
|
|
305
|
+
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
294
306
|
const messageHandler = createIFrameMessageHandler({
|
|
295
307
|
nexusWalletUrl: config.walletUrl,
|
|
296
|
-
metadata: config.metadata,
|
|
297
308
|
iframe,
|
|
298
|
-
channelManager
|
|
309
|
+
channelManager,
|
|
310
|
+
iframeLifecycleManager: lifecycleManager
|
|
299
311
|
});
|
|
300
312
|
const request = async (args) => {
|
|
301
|
-
const isConnected = await
|
|
313
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
302
314
|
if (!isConnected) {
|
|
303
315
|
throw new FrakRpcError(
|
|
304
316
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -324,14 +336,13 @@ function createIFrameNexusClient({
|
|
|
324
336
|
const compressedMessage = await hashAndCompressData(args);
|
|
325
337
|
messageHandler.sendEvent({
|
|
326
338
|
id: channelId,
|
|
327
|
-
// @ts-ignore, todo: idk why the fck it's needed
|
|
328
339
|
topic: args.method,
|
|
329
340
|
data: compressedMessage
|
|
330
341
|
});
|
|
331
342
|
return result.promise;
|
|
332
343
|
};
|
|
333
344
|
const listenerRequest = async (args, callback) => {
|
|
334
|
-
const isConnected = await
|
|
345
|
+
const isConnected = await lifecycleManager.isConnected;
|
|
335
346
|
if (!isConnected) {
|
|
336
347
|
throw new FrakRpcError(
|
|
337
348
|
RpcErrorCodes.clientNotConnected,
|
|
@@ -343,6 +354,7 @@ function createIFrameNexusClient({
|
|
|
343
354
|
if (decompressed.result) {
|
|
344
355
|
callback(decompressed.result);
|
|
345
356
|
} else {
|
|
357
|
+
throw new InternalError("No valid result in the response");
|
|
346
358
|
}
|
|
347
359
|
});
|
|
348
360
|
const compressedMessage = await hashAndCompressData(args);
|
|
@@ -357,14 +369,45 @@ function createIFrameNexusClient({
|
|
|
357
369
|
messageHandler.cleanup();
|
|
358
370
|
iframe.remove();
|
|
359
371
|
};
|
|
372
|
+
const waitForSetup = postConnectionSetup({
|
|
373
|
+
config,
|
|
374
|
+
messageHandler,
|
|
375
|
+
lifecycleManager
|
|
376
|
+
});
|
|
360
377
|
return {
|
|
361
378
|
config,
|
|
362
|
-
waitForConnection:
|
|
379
|
+
waitForConnection: lifecycleManager.isConnected,
|
|
380
|
+
waitForSetup,
|
|
363
381
|
request,
|
|
364
382
|
listenerRequest,
|
|
365
383
|
destroy
|
|
366
384
|
};
|
|
367
385
|
}
|
|
386
|
+
async function postConnectionSetup({
|
|
387
|
+
config,
|
|
388
|
+
messageHandler,
|
|
389
|
+
lifecycleManager
|
|
390
|
+
}) {
|
|
391
|
+
await lifecycleManager.isConnected;
|
|
392
|
+
const pushCss = async () => {
|
|
393
|
+
const cssLink = config.metadata.css;
|
|
394
|
+
if (!cssLink) return;
|
|
395
|
+
messageHandler.sendEvent({
|
|
396
|
+
clientLifecycle: "modal-css",
|
|
397
|
+
data: { cssLink }
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
const pushBackup = async () => {
|
|
401
|
+
if (typeof window === "undefined") return;
|
|
402
|
+
const backup = window.localStorage.getItem(BACKUP_KEY);
|
|
403
|
+
if (!backup) return;
|
|
404
|
+
messageHandler.sendEvent({
|
|
405
|
+
clientLifecycle: "restore-backup",
|
|
406
|
+
data: { backup }
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
await Promise.all([pushCss(), pushBackup()]);
|
|
410
|
+
}
|
|
368
411
|
|
|
369
412
|
export {
|
|
370
413
|
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 _chunkBJ3CCN5Pcjs = require('../chunk-BJ3CCN5P.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 = _chunkBJ3CCN5Pcjs.FrakRpcError; exports.RpcErrorCodes = _chunkBJ3CCN5Pcjs.RpcErrorCodes; exports.createIFrameNexusClient = _chunkBJ3CCN5Pcjs.createIFrameNexusClient; exports.createIframe = _chunkBJ3CCN5Pcjs.createIframe; exports.decompressDataAndCheckHash = _chunkBJ3CCN5Pcjs.decompressDataAndCheckHash; exports.hashAndCompressData = _chunkBJ3CCN5Pcjs.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 _chunkBJ3CCN5Pcjs = require('../chunk-BJ3CCN5P.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, _chunkBJ3CCN5Pcjs.FrakRpcError)(
|
|
55
|
+
_chunkBJ3CCN5Pcjs.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, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
89
89
|
}
|
|
90
|
-
const firstResult = new (0,
|
|
90
|
+
const firstResult = new (0, _chunkBJ3CCN5Pcjs.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, _chunkBJ3CCN5Pcjs.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, _chunkBJ3CCN5Pcjs.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, _chunkBJ3CCN5Pcjs.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, _chunkBJ3CCN5Pcjs.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 _chunkBJ3CCN5Pcjs.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 _chunkBJ3CCN5Pcjs.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,20 @@ function useReferralInteraction({
|
|
|
272
272
|
});
|
|
273
273
|
const processReferral = _react.useCallback.call(void 0, async () => {
|
|
274
274
|
try {
|
|
275
|
-
|
|
275
|
+
let currentWallet = await ensureWalletConnected({
|
|
276
|
+
autoDisplay: false
|
|
277
|
+
});
|
|
276
278
|
if (!_optionalChain([nexusContext, 'optionalAccess', _10 => _10.r])) {
|
|
277
279
|
if (currentWallet) {
|
|
278
280
|
await updateContextAsync({ r: currentWallet });
|
|
279
281
|
}
|
|
280
282
|
return "no-referrer";
|
|
281
283
|
}
|
|
284
|
+
if (!currentWallet) {
|
|
285
|
+
currentWallet = await ensureWalletConnected({
|
|
286
|
+
autoDisplay: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
282
289
|
if (currentWallet && _viem.isAddressEqual.call(void 0, nexusContext.r, currentWallet)) {
|
|
283
290
|
return "self-referral";
|
|
284
291
|
}
|
|
@@ -327,23 +334,26 @@ function useEnsureWalletConnected({
|
|
|
327
334
|
walletStatus
|
|
328
335
|
}) {
|
|
329
336
|
const { mutateAsync: displayModal2 } = useDisplayModal();
|
|
330
|
-
return _react.useCallback.call(void 0,
|
|
331
|
-
|
|
332
|
-
if (!
|
|
333
|
-
|
|
337
|
+
return _react.useCallback.call(void 0,
|
|
338
|
+
async ({ autoDisplay }) => {
|
|
339
|
+
if (_optionalChain([walletStatus, 'optionalAccess', _13 => _13.key]) !== "connected" || !walletStatus.interactionSession) {
|
|
340
|
+
if (!(modalConfig && autoDisplay)) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const result = await displayModal2(modalConfig);
|
|
344
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _14 => _14.login, 'optionalAccess', _15 => _15.wallet]), () => ( void 0));
|
|
334
345
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}, [walletStatus, modalConfig, displayModal2]);
|
|
346
|
+
return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
|
|
347
|
+
},
|
|
348
|
+
[walletStatus, modalConfig, displayModal2]
|
|
349
|
+
);
|
|
340
350
|
}
|
|
341
351
|
function mapErrorToState(error) {
|
|
342
|
-
if (error instanceof
|
|
352
|
+
if (error instanceof _chunkBJ3CCN5Pcjs.FrakRpcError) {
|
|
343
353
|
switch (error.code) {
|
|
344
|
-
case
|
|
354
|
+
case _chunkBJ3CCN5Pcjs.RpcErrorCodes.walletNotConnected:
|
|
345
355
|
return "no-wallet";
|
|
346
|
-
case
|
|
356
|
+
case _chunkBJ3CCN5Pcjs.RpcErrorCodes.noInteractionSession:
|
|
347
357
|
return "no-session";
|
|
348
358
|
default:
|
|
349
359
|
return "error";
|
|
@@ -361,7 +371,7 @@ function useOpenSso({ mutations } = {}) {
|
|
|
361
371
|
mutationKey: ["nexus-sdk", "open-sso"],
|
|
362
372
|
mutationFn: async (params) => {
|
|
363
373
|
if (!client) {
|
|
364
|
-
throw new (0,
|
|
374
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
365
375
|
}
|
|
366
376
|
return _chunkS5FVCA2Ecjs.openSso.call(void 0, client, params);
|
|
367
377
|
}
|
|
@@ -379,15 +389,15 @@ function NexusIFrameClientProvider({
|
|
|
379
389
|
const config = useNexusConfig();
|
|
380
390
|
const [client, setClient] = _react.useState.call(void 0, void 0);
|
|
381
391
|
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
382
|
-
...
|
|
392
|
+
..._chunkBJ3CCN5Pcjs.baseIframeProps,
|
|
383
393
|
src: `${config.walletUrl}/listener`,
|
|
384
|
-
style: _nullishCoalesce(style, () => (
|
|
394
|
+
style: _nullishCoalesce(style, () => ( _chunkBJ3CCN5Pcjs.baseIframeProps.style)),
|
|
385
395
|
ref: (iframe) => {
|
|
386
396
|
if (!iframe || client) {
|
|
387
397
|
return;
|
|
388
398
|
}
|
|
389
399
|
setClient(
|
|
390
|
-
|
|
400
|
+
_chunkBJ3CCN5Pcjs.createIFrameNexusClient.call(void 0, {
|
|
391
401
|
iframe,
|
|
392
402
|
config
|
|
393
403
|
})
|
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-HXVDI2IY.js";
|
|
11
11
|
import {
|
|
12
12
|
displayModal,
|
|
13
13
|
openSso,
|
|
@@ -272,13 +272,20 @@ function useReferralInteraction({
|
|
|
272
272
|
});
|
|
273
273
|
const processReferral = useCallback2(async () => {
|
|
274
274
|
try {
|
|
275
|
-
|
|
275
|
+
let currentWallet = await ensureWalletConnected({
|
|
276
|
+
autoDisplay: false
|
|
277
|
+
});
|
|
276
278
|
if (!nexusContext?.r) {
|
|
277
279
|
if (currentWallet) {
|
|
278
280
|
await updateContextAsync({ r: currentWallet });
|
|
279
281
|
}
|
|
280
282
|
return "no-referrer";
|
|
281
283
|
}
|
|
284
|
+
if (!currentWallet) {
|
|
285
|
+
currentWallet = await ensureWalletConnected({
|
|
286
|
+
autoDisplay: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
282
289
|
if (currentWallet && isAddressEqual(nexusContext.r, currentWallet)) {
|
|
283
290
|
return "self-referral";
|
|
284
291
|
}
|
|
@@ -327,16 +334,19 @@ function useEnsureWalletConnected({
|
|
|
327
334
|
walletStatus
|
|
328
335
|
}) {
|
|
329
336
|
const { mutateAsync: displayModal2 } = useDisplayModal();
|
|
330
|
-
return useCallback2(
|
|
331
|
-
|
|
332
|
-
if (!
|
|
333
|
-
|
|
337
|
+
return useCallback2(
|
|
338
|
+
async ({ autoDisplay }) => {
|
|
339
|
+
if (walletStatus?.key !== "connected" || !walletStatus.interactionSession) {
|
|
340
|
+
if (!(modalConfig && autoDisplay)) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const result = await displayModal2(modalConfig);
|
|
344
|
+
return result?.login?.wallet ?? void 0;
|
|
334
345
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}, [walletStatus, modalConfig, displayModal2]);
|
|
346
|
+
return walletStatus.wallet ?? void 0;
|
|
347
|
+
},
|
|
348
|
+
[walletStatus, modalConfig, displayModal2]
|
|
349
|
+
);
|
|
340
350
|
}
|
|
341
351
|
function mapErrorToState(error) {
|
|
342
352
|
if (error instanceof FrakRpcError) {
|
|
@@ -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.12",
|
|
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",
|