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