@notabene/javascript-sdk 2.8.0-next.4 → 2.8.0-next.5
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/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +57 -0
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +57 -0
- package/dist/esm/notabene.js +282 -137
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +57 -0
- package/dist/notabene.js +282 -137
- package/package.json +1 -1
- package/src/notabene.ts +7 -0
- package/src/utils/__tests__/connections.test.ts +284 -0
- package/src/utils/__tests__/encryption.test.ts +79 -0
- package/src/utils/connections.ts +174 -0
- package/src/utils/encryption.ts +111 -0
package/dist/esm/notabene.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var v = (t, e, n) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var a = (t, e, n) => v(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), g = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(g || {}), y = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(I || {}), C = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(C || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), L = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(L || {}), u = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(u || {}), b = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(b || {}), N = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(N || {});
|
|
5
|
+
class U {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
a(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
|
+
a(this, "port");
|
|
9
9
|
this.handleMessage = this.handleMessage.bind(this);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -16,8 +16,8 @@ class A {
|
|
|
16
16
|
*
|
|
17
17
|
* @param port - The MessagePort instance to use for communication
|
|
18
18
|
*/
|
|
19
|
-
setPort(
|
|
20
|
-
this.port =
|
|
19
|
+
setPort(e) {
|
|
20
|
+
this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Registers a callback for a specific message type.
|
|
@@ -29,8 +29,8 @@ class A {
|
|
|
29
29
|
* @param callback - The callback function to execute when matching messages are received
|
|
30
30
|
|
|
31
31
|
*/
|
|
32
|
-
on(
|
|
33
|
-
return this.listeners.has(
|
|
32
|
+
on(e, n) {
|
|
33
|
+
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(n), () => this.off(e, n);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Removes a callback for a specific message type.
|
|
@@ -41,9 +41,9 @@ class A {
|
|
|
41
41
|
* @param messageType - The type of message to remove listener from
|
|
42
42
|
* @param callback - The callback function to remove
|
|
43
43
|
*/
|
|
44
|
-
off(
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
off(e, n) {
|
|
45
|
+
const r = this.listeners.get(e);
|
|
46
|
+
r && (r.delete(n), r.size === 0 && this.listeners.delete(e));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Internal message handler for processing received messages.
|
|
@@ -53,39 +53,39 @@ class A {
|
|
|
53
53
|
*
|
|
54
54
|
* @param event - The message event containing the component message
|
|
55
55
|
*/
|
|
56
|
-
handleMessage(
|
|
57
|
-
const
|
|
58
|
-
if (typeof
|
|
59
|
-
const
|
|
60
|
-
i && i.forEach((
|
|
56
|
+
handleMessage(e) {
|
|
57
|
+
const n = e.data;
|
|
58
|
+
if (typeof n == "object" && n !== null && "type" in n) {
|
|
59
|
+
const r = n.type, i = this.listeners.get(r);
|
|
60
|
+
i && i.forEach((s) => s(n));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Sends a message through the message port
|
|
65
65
|
* @param message The host message to send
|
|
66
66
|
*/
|
|
67
|
-
send(
|
|
68
|
-
this.port && this.port.postMessage(
|
|
67
|
+
send(e) {
|
|
68
|
+
this.port && this.port.postMessage(e);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class _ {
|
|
72
72
|
/**
|
|
73
73
|
* Creates an instance of EmbeddedComponent.
|
|
74
74
|
* @param url - The URL of the embedded component
|
|
75
75
|
* @param value - The initial transaction value
|
|
76
76
|
*/
|
|
77
|
-
constructor(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this._url =
|
|
86
|
-
i.type ===
|
|
87
|
-
}), this.on(
|
|
88
|
-
i.type ===
|
|
77
|
+
constructor(e, n, r) {
|
|
78
|
+
a(this, "_url");
|
|
79
|
+
a(this, "_value");
|
|
80
|
+
a(this, "_options");
|
|
81
|
+
a(this, "_errors", []);
|
|
82
|
+
a(this, "iframe");
|
|
83
|
+
a(this, "eventManager");
|
|
84
|
+
a(this, "modal");
|
|
85
|
+
this._url = e, this._value = n, this._options = r, this.eventManager = new U(), this.on(l.INVALID, (i) => {
|
|
86
|
+
i.type === l.INVALID && (this._errors = i.errors, this._value = i.value);
|
|
87
|
+
}), this.on(l.RESIZE, (i) => {
|
|
88
|
+
i.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -119,21 +119,21 @@ class N {
|
|
|
119
119
|
* @param parentId - The ID of the parent element
|
|
120
120
|
* @throws Will throw an error if the parent element is not found
|
|
121
121
|
*/
|
|
122
|
-
mount(
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
125
|
-
this.embed(
|
|
122
|
+
mount(e) {
|
|
123
|
+
const n = document.querySelector(e);
|
|
124
|
+
if (!n) throw new Error(`parentID ${e} not found`);
|
|
125
|
+
this.embed(n);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Embeds the component into a parent element
|
|
129
129
|
* @param parent - The parent element to embed the component into
|
|
130
130
|
*/
|
|
131
|
-
embed(
|
|
132
|
-
var
|
|
133
|
-
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
}), (i = (
|
|
131
|
+
embed(e, n = !1) {
|
|
132
|
+
var r, i;
|
|
133
|
+
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (n ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write; hid; bluetooth;", this.iframe.style.width = "100%", this.iframe.style.height = "0px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", e.appendChild(this.iframe), window.addEventListener("message", (s) => {
|
|
134
|
+
var o, c;
|
|
135
|
+
s.source === ((o = this.iframe) == null ? void 0 : o.contentWindow) && ((c = this.eventManager) == null || c.setPort(s.ports[0]));
|
|
136
|
+
}), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
|
|
137
137
|
}
|
|
138
138
|
removeEmbed() {
|
|
139
139
|
this.iframe && this.iframe.remove();
|
|
@@ -142,48 +142,48 @@ class N {
|
|
|
142
142
|
* Sends a message to the embedded component
|
|
143
143
|
* @param message - The message to send
|
|
144
144
|
*/
|
|
145
|
-
send(
|
|
146
|
-
this.eventManager.send(
|
|
145
|
+
send(e) {
|
|
146
|
+
this.eventManager.send(e);
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Adds an event listener for a specific message type
|
|
150
150
|
* @param messageType - The type of message to listen for
|
|
151
151
|
* @param callback - The callback function to execute when the message is received
|
|
152
152
|
*/
|
|
153
|
-
on(
|
|
154
|
-
return this.eventManager.on(
|
|
153
|
+
on(e, n) {
|
|
154
|
+
return this.eventManager.on(e, n);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Removes an event listener for a specific message type
|
|
158
158
|
* @param messageType - The type of message to stop listening for
|
|
159
159
|
* @param callback - The callback function to remove
|
|
160
160
|
*/
|
|
161
|
-
off(
|
|
162
|
-
this.eventManager.off(
|
|
161
|
+
off(e, n) {
|
|
162
|
+
this.eventManager.off(e, n);
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
165
|
* Updates the transaction value and sends an update message to the component
|
|
166
166
|
* @param value - The new transaction value
|
|
167
167
|
*/
|
|
168
|
-
update(
|
|
169
|
-
this._value =
|
|
168
|
+
update(e, n) {
|
|
169
|
+
this._value = e, n && (this._options = n), this.send({ type: u.UPDATE, value: e, options: this._options });
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Waits for the component to complete and returns the transaction response
|
|
173
173
|
* @returns A promise that resolves with the transaction response
|
|
174
174
|
*/
|
|
175
175
|
completion() {
|
|
176
|
-
return new Promise((
|
|
177
|
-
let
|
|
178
|
-
function
|
|
179
|
-
|
|
176
|
+
return new Promise((e, n) => {
|
|
177
|
+
let r, i, s;
|
|
178
|
+
function o() {
|
|
179
|
+
r && r(), i && i(), s && s();
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}), i = this.on(
|
|
184
|
-
|
|
185
|
-
}),
|
|
186
|
-
|
|
181
|
+
r = this.on(l.COMPLETE, (c) => {
|
|
182
|
+
e(c.response), o();
|
|
183
|
+
}), i = this.on(l.CANCEL, () => {
|
|
184
|
+
n(new Error("User cancelled")), o();
|
|
185
|
+
}), s = this.on("error", (c) => {
|
|
186
|
+
n(new Error(c.message)), o();
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
}
|
|
@@ -192,15 +192,15 @@ class N {
|
|
|
192
192
|
*/
|
|
193
193
|
async openModal() {
|
|
194
194
|
this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0);
|
|
195
|
-
const
|
|
195
|
+
const e = this.on(l.CANCEL, () => {
|
|
196
196
|
this.closeModal();
|
|
197
|
-
}),
|
|
197
|
+
}), n = this.on(l.COMPLETE, () => {
|
|
198
198
|
this.closeModal();
|
|
199
199
|
});
|
|
200
200
|
return this.modal.showModal(), this.modal.addEventListener("click", () => {
|
|
201
201
|
this.closeModal();
|
|
202
202
|
}), this.completion().finally(() => {
|
|
203
|
-
|
|
203
|
+
e(), n();
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -208,8 +208,8 @@ class N {
|
|
|
208
208
|
*
|
|
209
209
|
*/
|
|
210
210
|
closeModal() {
|
|
211
|
-
var
|
|
212
|
-
this.modal && ((
|
|
211
|
+
var e;
|
|
212
|
+
this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* Opens the component in a popup window. This may be needed to support many self-hosted wallets
|
|
@@ -218,58 +218,202 @@ class N {
|
|
|
218
218
|
* @see [Cross-Origin-Opener-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy)
|
|
219
219
|
*/
|
|
220
220
|
async popup() {
|
|
221
|
-
const
|
|
221
|
+
const e = window.open(
|
|
222
222
|
this.url,
|
|
223
223
|
"_blank",
|
|
224
224
|
"popup=true,width=600,height=600"
|
|
225
225
|
);
|
|
226
226
|
window.addEventListener("message", (i) => {
|
|
227
|
-
var
|
|
228
|
-
i.source ===
|
|
227
|
+
var s;
|
|
228
|
+
i.source === e && (console.log("received message from popup", i.data), (s = this.eventManager) == null || s.setPort(i.ports[0]));
|
|
229
229
|
});
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
}),
|
|
233
|
-
|
|
230
|
+
const n = this.on(l.CANCEL, () => {
|
|
231
|
+
e == null || e.close();
|
|
232
|
+
}), r = this.on(l.COMPLETE, () => {
|
|
233
|
+
e == null || e.close();
|
|
234
234
|
});
|
|
235
235
|
return this.completion().finally(() => {
|
|
236
|
-
|
|
236
|
+
n(), r();
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
return Object.entries(
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
typeof
|
|
240
|
+
function R(t) {
|
|
241
|
+
return Object.entries(t).map(([e, n]) => {
|
|
242
|
+
if (n == null) return;
|
|
243
|
+
const r = encodeURIComponent(e), i = encodeURIComponent(
|
|
244
|
+
typeof n == "object" ? JSON.stringify(n) : String(n)
|
|
245
245
|
// Use String() to handle all primitive types
|
|
246
246
|
);
|
|
247
|
-
return `${
|
|
248
|
-
}).filter((
|
|
247
|
+
return `${r}=${i}`;
|
|
248
|
+
}).filter((e) => e !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
const
|
|
252
|
-
return
|
|
253
|
-
(
|
|
254
|
-
const [
|
|
255
|
-
return
|
|
250
|
+
function O(t) {
|
|
251
|
+
const e = t.slice(1);
|
|
252
|
+
return e ? e.split("&").filter(Boolean).reduce(
|
|
253
|
+
(r, i) => {
|
|
254
|
+
const [s, o] = i.split("=");
|
|
255
|
+
return s && (r[decodeURIComponent(s)] = o ? decodeURIComponent(o) : ""), r;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
async function d(t) {
|
|
261
|
+
const e = JSON.stringify(t), n = new TextEncoder(), r = crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
|
|
262
|
+
"raw",
|
|
263
|
+
r,
|
|
264
|
+
{ name: "AES-GCM" },
|
|
265
|
+
!1,
|
|
266
|
+
["encrypt"]
|
|
267
|
+
), s = crypto.getRandomValues(new Uint8Array(12)), o = await crypto.subtle.encrypt(
|
|
268
|
+
{ name: "AES-GCM", iv: s },
|
|
269
|
+
i,
|
|
270
|
+
n.encode(e)
|
|
271
|
+
);
|
|
272
|
+
return {
|
|
273
|
+
ciphertext: `${h(s)}-${h(o)}`,
|
|
274
|
+
key: h(r)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
async function x({ ciphertext: t, key: e }) {
|
|
278
|
+
const [n, r] = t.split("-"), i = new Uint8Array(
|
|
279
|
+
atob(e).split("").map((f) => f.charCodeAt(0))
|
|
280
|
+
), s = m(n), o = m(r), c = await crypto.subtle.importKey(
|
|
281
|
+
"raw",
|
|
282
|
+
i,
|
|
283
|
+
{ name: "AES-GCM" },
|
|
284
|
+
!1,
|
|
285
|
+
["decrypt"]
|
|
286
|
+
), p = new TextDecoder(), E = await crypto.subtle.decrypt(
|
|
287
|
+
{ name: "AES-GCM", iv: new Uint8Array(s) },
|
|
288
|
+
c,
|
|
289
|
+
o
|
|
290
|
+
);
|
|
291
|
+
return JSON.parse(p.decode(E));
|
|
292
|
+
}
|
|
293
|
+
function h(t) {
|
|
294
|
+
const e = new Uint8Array(t);
|
|
295
|
+
let n = "";
|
|
296
|
+
for (let r = 0; r < e.length; r++)
|
|
297
|
+
n += String.fromCharCode(e[r]);
|
|
298
|
+
return btoa(n);
|
|
299
|
+
}
|
|
300
|
+
function m(t) {
|
|
301
|
+
const e = atob(t), n = new Uint8Array(e.length);
|
|
302
|
+
for (let r = 0; r < e.length; r++)
|
|
303
|
+
n[r] = e.charCodeAt(r);
|
|
304
|
+
return n;
|
|
305
|
+
}
|
|
306
|
+
class M {
|
|
307
|
+
constructor(e) {
|
|
308
|
+
a(this, "endpoint");
|
|
309
|
+
this.endpoint = e;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Creates a new encrypted connection
|
|
313
|
+
* @param data The component request data to encrypt and store
|
|
314
|
+
* @param participants Array of participant identifiers
|
|
315
|
+
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
316
|
+
*/
|
|
317
|
+
async create(e, n) {
|
|
318
|
+
const r = await d(e), i = {
|
|
319
|
+
metadata: n,
|
|
320
|
+
sealed: r.ciphertext
|
|
321
|
+
}, s = await fetch(this.endpoint, {
|
|
322
|
+
method: "POST",
|
|
323
|
+
headers: {
|
|
324
|
+
"Content-Type": "application/json"
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify(i)
|
|
327
|
+
});
|
|
328
|
+
if (!s.ok)
|
|
329
|
+
throw new Error(`Failed to create connection: ${await s.text()}`);
|
|
330
|
+
const o = await s.json();
|
|
331
|
+
return {
|
|
332
|
+
id: o.id,
|
|
333
|
+
version: o.version,
|
|
334
|
+
metadata: n,
|
|
335
|
+
data: e,
|
|
336
|
+
key: r.key
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Updates an existing connection with new encrypted data
|
|
341
|
+
* @param id Connection ID
|
|
342
|
+
* @param data New data to encrypt and store
|
|
343
|
+
* @param version Current version number
|
|
344
|
+
* @returns Promise resolving to updated connection details including new encryption key
|
|
345
|
+
*/
|
|
346
|
+
async update(e, n, r) {
|
|
347
|
+
const i = await d(n), s = {
|
|
348
|
+
sealed: i.ciphertext,
|
|
349
|
+
version: r
|
|
350
|
+
}, o = await fetch(`${this.endpoint}/${e}`, {
|
|
351
|
+
method: "PATCH",
|
|
352
|
+
headers: {
|
|
353
|
+
"Content-Type": "application/json"
|
|
354
|
+
},
|
|
355
|
+
body: JSON.stringify(s)
|
|
356
|
+
});
|
|
357
|
+
if (!o.ok)
|
|
358
|
+
throw new Error(`Failed to update connection: ${await o.text()}`);
|
|
359
|
+
const c = await o.json();
|
|
360
|
+
return {
|
|
361
|
+
id: c.id,
|
|
362
|
+
metadata: c.metadata,
|
|
363
|
+
version: c.version,
|
|
364
|
+
data: n,
|
|
365
|
+
key: i.key
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Retrieves and decrypts connection data
|
|
370
|
+
* @param id Connection ID
|
|
371
|
+
* @param key Encryption key from previous create/update operation
|
|
372
|
+
* @returns Promise resolving to connection details including decrypted data
|
|
373
|
+
*/
|
|
374
|
+
async get(e, n) {
|
|
375
|
+
const r = await fetch(`${this.endpoint}/${e}`, {
|
|
376
|
+
method: "GET"
|
|
377
|
+
});
|
|
378
|
+
if (!r.ok)
|
|
379
|
+
throw new Error(`Failed to get connection: ${await r.text()}`);
|
|
380
|
+
const i = await r.json(), s = i.sealed[i.sealed.length - 1], o = await x({
|
|
381
|
+
ciphertext: s,
|
|
382
|
+
key: n
|
|
383
|
+
});
|
|
384
|
+
return {
|
|
385
|
+
id: i.id,
|
|
386
|
+
version: i.version,
|
|
387
|
+
metadata: i.metadata,
|
|
388
|
+
data: o,
|
|
389
|
+
key: n
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Closes a connection
|
|
394
|
+
* @param id Connection ID
|
|
395
|
+
*/
|
|
396
|
+
async close(e) {
|
|
397
|
+
const n = await fetch(`${this.endpoint}/${e}`, {
|
|
398
|
+
method: "DELETE"
|
|
399
|
+
});
|
|
400
|
+
if (!n.ok)
|
|
401
|
+
throw new Error(`Failed to close connection: ${await n.text()}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
class S {
|
|
261
405
|
/**
|
|
262
406
|
* Creates a new instance of the Notabene SDK
|
|
263
407
|
*
|
|
264
408
|
* @param config - Configuration options for the Notabene SDK
|
|
265
409
|
*/
|
|
266
|
-
constructor(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.uxUrl =
|
|
410
|
+
constructor(e) {
|
|
411
|
+
a(this, "nodeUrl");
|
|
412
|
+
a(this, "authToken");
|
|
413
|
+
a(this, "uxUrl");
|
|
414
|
+
a(this, "theme");
|
|
415
|
+
a(this, "locale");
|
|
416
|
+
this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
|
|
273
417
|
}
|
|
274
418
|
/**
|
|
275
419
|
* Generates a URL for a Notabene component
|
|
@@ -281,15 +425,15 @@ class U {
|
|
|
281
425
|
* @returns component URL
|
|
282
426
|
* @internal
|
|
283
427
|
*/
|
|
284
|
-
componentUrl(
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const
|
|
428
|
+
componentUrl(e, n, r, i) {
|
|
429
|
+
const s = new URL(this.uxUrl);
|
|
430
|
+
s.pathname = e;
|
|
431
|
+
const o = R({
|
|
288
432
|
authToken: this.authToken,
|
|
289
|
-
value:
|
|
290
|
-
configuration:
|
|
433
|
+
value: n,
|
|
434
|
+
configuration: r
|
|
291
435
|
});
|
|
292
|
-
return
|
|
436
|
+
return s.hash = o, this.nodeUrl && s.searchParams.set("nodeUrl", this.nodeUrl), this.theme && s.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && s.searchParams.set("locale", this.locale), i && (i.callback && s.searchParams.set("callback_url", i.callback), i.redirectUri && s.searchParams.set("redirect_uri", i.redirectUri)), s.toString();
|
|
293
437
|
}
|
|
294
438
|
/**
|
|
295
439
|
* Creates a new embedded component
|
|
@@ -301,11 +445,11 @@ class U {
|
|
|
301
445
|
* @returns A new EmbeddedComponent instance
|
|
302
446
|
* @internal
|
|
303
447
|
*/
|
|
304
|
-
createComponent(
|
|
305
|
-
return new
|
|
306
|
-
this.componentUrl(
|
|
307
|
-
|
|
308
|
-
|
|
448
|
+
createComponent(e, n, r, i) {
|
|
449
|
+
return new _(
|
|
450
|
+
this.componentUrl(e, n, r, i),
|
|
451
|
+
n,
|
|
452
|
+
r
|
|
309
453
|
);
|
|
310
454
|
}
|
|
311
455
|
/**
|
|
@@ -316,12 +460,12 @@ class U {
|
|
|
316
460
|
* @param callbacks - Optional callback configuration
|
|
317
461
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
318
462
|
*/
|
|
319
|
-
createWithdrawalAssist(
|
|
463
|
+
createWithdrawalAssist(e, n, r) {
|
|
320
464
|
return this.createComponent(
|
|
321
465
|
"withdrawal-assist",
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
466
|
+
e,
|
|
467
|
+
n,
|
|
468
|
+
r
|
|
325
469
|
);
|
|
326
470
|
}
|
|
327
471
|
/**
|
|
@@ -333,12 +477,12 @@ class U {
|
|
|
333
477
|
* @returns A new EmbeddedComponent instance for connection
|
|
334
478
|
* @alpha
|
|
335
479
|
*/
|
|
336
|
-
createConnectWallet(
|
|
480
|
+
createConnectWallet(e, n, r) {
|
|
337
481
|
return this.createComponent(
|
|
338
482
|
"connect",
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
483
|
+
e,
|
|
484
|
+
n,
|
|
485
|
+
r
|
|
342
486
|
);
|
|
343
487
|
}
|
|
344
488
|
/**
|
|
@@ -350,12 +494,12 @@ class U {
|
|
|
350
494
|
* @returns A new EmbeddedComponent instance for deposit requests
|
|
351
495
|
* @public
|
|
352
496
|
*/
|
|
353
|
-
createDepositRequest(
|
|
497
|
+
createDepositRequest(e, n, r) {
|
|
354
498
|
return this.createComponent(
|
|
355
499
|
"deposit-request",
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
500
|
+
e,
|
|
501
|
+
n,
|
|
502
|
+
r
|
|
359
503
|
);
|
|
360
504
|
}
|
|
361
505
|
/**
|
|
@@ -367,27 +511,28 @@ class U {
|
|
|
367
511
|
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
368
512
|
* @public
|
|
369
513
|
*/
|
|
370
|
-
createDepositAssist(
|
|
514
|
+
createDepositAssist(e, n, r) {
|
|
371
515
|
return this.createComponent(
|
|
372
516
|
"deposit-assist",
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
517
|
+
e,
|
|
518
|
+
n,
|
|
519
|
+
r
|
|
376
520
|
);
|
|
377
521
|
}
|
|
378
522
|
}
|
|
379
523
|
export {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
C as
|
|
392
|
-
|
|
524
|
+
A as AgentType,
|
|
525
|
+
l as CMType,
|
|
526
|
+
M as ConnectionManager,
|
|
527
|
+
_ as EmbeddedComponent,
|
|
528
|
+
L as ErrorIdentifierCode,
|
|
529
|
+
u as HMType,
|
|
530
|
+
g as PersonType,
|
|
531
|
+
b as ProofStatus,
|
|
532
|
+
N as ProofTypes,
|
|
533
|
+
y as Status,
|
|
534
|
+
I as VASPSearchControl,
|
|
535
|
+
C as ValidationSections,
|
|
536
|
+
O as decodeFragmentToObject,
|
|
537
|
+
S as default
|
|
393
538
|
};
|
package/dist/esm/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Notabene <developers@notabene.id>",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"packageManager": "yarn@4.5.1",
|
|
13
|
-
"version": "2.8.0-next.
|
|
13
|
+
"version": "2.8.0-next.5",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|