@notabene/javascript-sdk 2.11.0-next.2 → 2.12.0
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 +46 -9
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +46 -9
- package/dist/esm/notabene.js +191 -188
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +46 -9
- package/dist/notabene.js +191 -188
- package/package.json +1 -1
- package/src/notabene.ts +6 -0
- package/src/types.ts +44 -12
- package/src/utils/connections.ts +2 -0
package/dist/notabene.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var v = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var o = (e, t, n) => v(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var g = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(g || {}), I = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(I || {}), N = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(N || {}), L = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(L || {}), b = /* @__PURE__ */ ((e) => (e.SMS = "sms", e.EMAIL = "email", e))(b || {}), y = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.APPROVED = "approved", e.FAILED = "failed", e.EXPIRED = "expired", e.MAX_ATTEMPTS_REACHED = "max_attempts_reached", e.UNREACHABLE = "unreachable", e))(y || {}), C = /* @__PURE__ */ ((e) => (e.COINBASE = "coinbase", e))(C || {}), U = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(U || {}), l = /* @__PURE__ */ ((e) => (e.COMPLETE = "complete", e.RESIZE = "resize", e.RESULT = "result", e.READY = "ready", e.INVALID = "invalid", e.ERROR = "error", e.CANCEL = "cancel", e.WARNING = "warning", e.INFO = "info", e))(l || {}), _ = /* @__PURE__ */ ((e) => (e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", e.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", e.TOKEN_INVALID = "TOKEN_INVALID", e))(_ || {}), p = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(p || {}), D = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(D || {}), R = /* @__PURE__ */ ((e) => (e.SelfDeclaration = "self-declaration", e.SIWE = "siwe", e.SIWX = "siwx", e.SOL_SIWX = "sol-siwx", e.EIP191 = "eip-191", e.EIP712 = "eip-712", e.EIP1271 = "eip-1271", e.BIP137 = "bip-137", e.BIP322 = "bip-322", e.BIP137_XPUB = "xpub", e.TIP191 = "tip-191", e.ED25519 = "ed25519", e.XRP_ED25519 = "xrp-ed25519", e.XLM_ED25519 = "xlm-ed25519", e.CIP8 = "cip-8", e.COSMOS = "cosmos-ecdsa", e.MicroTransfer = "microtransfer", e.Screenshot = "screenshot", e.Connect = "connect", e.CONCORDIUM = "concordium", e))(R || {});
|
|
5
5
|
class O {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
|
+
o(this, "port");
|
|
9
9
|
this.handleMessage = this.handleMessage.bind(this);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -16,8 +16,8 @@ class O {
|
|
|
16
16
|
*
|
|
17
17
|
* @param port - The MessagePort instance to use for communication
|
|
18
18
|
*/
|
|
19
|
-
setPort(
|
|
20
|
-
this.port =
|
|
19
|
+
setPort(t) {
|
|
20
|
+
this.port = t, 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 O {
|
|
|
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(t, n) {
|
|
33
|
+
return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(n), () => this.off(t, n);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Removes a callback for a specific message type.
|
|
@@ -41,9 +41,9 @@ class O {
|
|
|
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(t, n) {
|
|
45
|
+
const r = this.listeners.get(t);
|
|
46
|
+
r && (r.delete(n), r.size === 0 && this.listeners.delete(t));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Internal message handler for processing received messages.
|
|
@@ -53,39 +53,39 @@ class O {
|
|
|
53
53
|
*
|
|
54
54
|
* @param event - The message event containing the component message
|
|
55
55
|
*/
|
|
56
|
-
handleMessage(
|
|
57
|
-
const n =
|
|
56
|
+
handleMessage(t) {
|
|
57
|
+
const n = t.data;
|
|
58
58
|
if (typeof n == "object" && n !== null && "type" in n) {
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const r = n.type, s = this.listeners.get(r);
|
|
60
|
+
s && s.forEach((i) => i(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(t) {
|
|
68
|
+
this.port && this.port.postMessage(t);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class x {
|
|
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
|
-
|
|
87
|
-
}), this.on(l.RESIZE, (
|
|
88
|
-
|
|
77
|
+
constructor(t, n, r) {
|
|
78
|
+
o(this, "_url");
|
|
79
|
+
o(this, "_value");
|
|
80
|
+
o(this, "_options");
|
|
81
|
+
o(this, "_errors", []);
|
|
82
|
+
o(this, "iframe");
|
|
83
|
+
o(this, "eventManager");
|
|
84
|
+
o(this, "modal");
|
|
85
|
+
this._url = t, this._value = n, this._options = r, this.eventManager = new O(), this.on(l.INVALID, (s) => {
|
|
86
|
+
s.type === l.INVALID && (this._errors = s.errors, this._value = s.value);
|
|
87
|
+
}), this.on(l.RESIZE, (s) => {
|
|
88
|
+
s.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -119,21 +119,21 @@ class _ {
|
|
|
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 n = document.querySelector(
|
|
124
|
-
if (!n) throw new Error(`parentID ${
|
|
122
|
+
mount(t) {
|
|
123
|
+
const n = document.querySelector(t);
|
|
124
|
+
if (!n) throw new Error(`parentID ${t} not found`);
|
|
125
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 + (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",
|
|
134
|
-
var
|
|
135
|
-
i.source === ((
|
|
136
|
-
}), (
|
|
131
|
+
embed(t, n = !1) {
|
|
132
|
+
var r, s;
|
|
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", t.appendChild(this.iframe), window.addEventListener("message", (i) => {
|
|
134
|
+
var a, c;
|
|
135
|
+
i.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((c = this.eventManager) == null || c.setPort(i.ports[0]));
|
|
136
|
+
}), (s = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || s.focus();
|
|
137
137
|
}
|
|
138
138
|
removeEmbed() {
|
|
139
139
|
this.iframe && this.iframe.remove();
|
|
@@ -142,48 +142,48 @@ class _ {
|
|
|
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(t) {
|
|
146
|
+
this.eventManager.send(t);
|
|
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(t, n) {
|
|
154
|
+
return this.eventManager.on(t, 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(t, n) {
|
|
162
|
+
this.eventManager.off(t, 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(t, n) {
|
|
169
|
+
this._value = t, n && (this._options = n), this.send({ type: p.UPDATE, value: t, 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((t, n) => {
|
|
177
|
+
let r, s, i;
|
|
178
|
+
function a() {
|
|
179
|
+
r && r(), s && s(), i && i();
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}),
|
|
184
|
-
n(new Error("User cancelled")),
|
|
181
|
+
r = this.on(l.COMPLETE, (c) => {
|
|
182
|
+
t(c.response), a();
|
|
183
|
+
}), s = this.on(l.CANCEL, () => {
|
|
184
|
+
n(new Error("User cancelled")), a();
|
|
185
185
|
}), i = this.on("error", (c) => {
|
|
186
|
-
n(new Error(c.message)),
|
|
186
|
+
n(new Error(c.message)), a();
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
}
|
|
@@ -192,7 +192,7 @@ class _ {
|
|
|
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 t = this.on(l.CANCEL, () => {
|
|
196
196
|
this.closeModal();
|
|
197
197
|
}), n = this.on(l.COMPLETE, () => {
|
|
198
198
|
this.closeModal();
|
|
@@ -200,7 +200,7 @@ class _ {
|
|
|
200
200
|
return this.modal.showModal(), this.modal.addEventListener("click", () => {
|
|
201
201
|
this.closeModal();
|
|
202
202
|
}), this.completion().finally(() => {
|
|
203
|
-
|
|
203
|
+
t(), n();
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -208,8 +208,8 @@ class _ {
|
|
|
208
208
|
*
|
|
209
209
|
*/
|
|
210
210
|
closeModal() {
|
|
211
|
-
var
|
|
212
|
-
this.modal && ((
|
|
211
|
+
var t;
|
|
212
|
+
this.modal && ((t = this.modal) == null || t.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,123 +218,123 @@ class _ {
|
|
|
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 t = window.open(
|
|
222
222
|
this.url,
|
|
223
223
|
"_blank",
|
|
224
224
|
"popup=true,width=600,height=600"
|
|
225
225
|
);
|
|
226
|
-
window.addEventListener("message", (
|
|
226
|
+
window.addEventListener("message", (s) => {
|
|
227
227
|
var i;
|
|
228
|
-
|
|
228
|
+
s.source === t && (console.log("received message from popup", s.data), (i = this.eventManager) == null || i.setPort(s.ports[0]));
|
|
229
229
|
});
|
|
230
230
|
const n = this.on(l.CANCEL, () => {
|
|
231
|
-
|
|
232
|
-
}),
|
|
233
|
-
|
|
231
|
+
t == null || t.close();
|
|
232
|
+
}), r = this.on(l.COMPLETE, () => {
|
|
233
|
+
t == null || t.close();
|
|
234
234
|
});
|
|
235
235
|
return this.completion().finally(() => {
|
|
236
|
-
n(),
|
|
236
|
+
n(), r();
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
return Object.entries(
|
|
240
|
+
function M(e) {
|
|
241
|
+
return Object.entries(e).map(([t, n]) => {
|
|
242
242
|
if (n == null) return;
|
|
243
|
-
const
|
|
243
|
+
const r = encodeURIComponent(t), s = encodeURIComponent(
|
|
244
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}=${s}`;
|
|
248
|
+
}).filter((t) => t !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
const
|
|
252
|
-
return
|
|
253
|
-
(
|
|
254
|
-
const [i,
|
|
255
|
-
return i && (
|
|
250
|
+
function k(e) {
|
|
251
|
+
const t = e.slice(1);
|
|
252
|
+
return t ? t.split("&").filter(Boolean).reduce(
|
|
253
|
+
(r, s) => {
|
|
254
|
+
const [i, a] = s.split("=");
|
|
255
|
+
return i && (r[decodeURIComponent(i)] = a ? decodeURIComponent(a) : ""), r;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
|
-
async function E(
|
|
261
|
-
const n = JSON.stringify(
|
|
260
|
+
async function E(e, t) {
|
|
261
|
+
const n = JSON.stringify(e), r = new TextEncoder(), s = t ? m(t) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
|
|
262
262
|
"raw",
|
|
263
|
-
|
|
263
|
+
s,
|
|
264
264
|
{ name: "AES-GCM" },
|
|
265
265
|
!1,
|
|
266
266
|
["encrypt"]
|
|
267
|
-
),
|
|
268
|
-
{ name: "AES-GCM", iv:
|
|
267
|
+
), a = crypto.getRandomValues(new Uint8Array(12)), c = await crypto.subtle.encrypt(
|
|
268
|
+
{ name: "AES-GCM", iv: a },
|
|
269
269
|
i,
|
|
270
|
-
|
|
270
|
+
r.encode(n)
|
|
271
271
|
);
|
|
272
272
|
return {
|
|
273
|
-
ciphertext: `${u(
|
|
274
|
-
key: u(
|
|
273
|
+
ciphertext: `${u(a)}-${u(c)}`,
|
|
274
|
+
key: u(s)
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
async function f({ ciphertext:
|
|
278
|
-
const [n,
|
|
279
|
-
atob(
|
|
280
|
-
), i = m(n),
|
|
277
|
+
async function f({ ciphertext: e, key: t }) {
|
|
278
|
+
const [n, r] = e.split("-"), s = new Uint8Array(
|
|
279
|
+
atob(t).split("").map((w) => w.charCodeAt(0))
|
|
280
|
+
), i = m(n), a = m(r), c = await crypto.subtle.importKey(
|
|
281
281
|
"raw",
|
|
282
|
-
|
|
282
|
+
s,
|
|
283
283
|
{ name: "AES-GCM" },
|
|
284
284
|
!1,
|
|
285
285
|
["decrypt"]
|
|
286
286
|
), h = new TextDecoder(), d = await crypto.subtle.decrypt(
|
|
287
287
|
{ name: "AES-GCM", iv: new Uint8Array(i) },
|
|
288
288
|
c,
|
|
289
|
-
|
|
289
|
+
a
|
|
290
290
|
);
|
|
291
291
|
return JSON.parse(h.decode(d));
|
|
292
292
|
}
|
|
293
|
-
function u(
|
|
294
|
-
const
|
|
293
|
+
function u(e) {
|
|
294
|
+
const t = new Uint8Array(e);
|
|
295
295
|
let n = "";
|
|
296
|
-
for (let
|
|
297
|
-
n += String.fromCharCode(
|
|
296
|
+
for (let r = 0; r < t.length; r++)
|
|
297
|
+
n += String.fromCharCode(t[r]);
|
|
298
298
|
return btoa(n);
|
|
299
299
|
}
|
|
300
|
-
function m(
|
|
301
|
-
const
|
|
302
|
-
for (let
|
|
303
|
-
n[
|
|
300
|
+
function m(e) {
|
|
301
|
+
const t = atob(e), n = new Uint8Array(t.length);
|
|
302
|
+
for (let r = 0; r < t.length; r++)
|
|
303
|
+
n[r] = t.charCodeAt(r);
|
|
304
304
|
return n;
|
|
305
305
|
}
|
|
306
|
-
async function
|
|
307
|
-
const
|
|
306
|
+
async function P(e) {
|
|
307
|
+
const t = await fetch(e.url, {
|
|
308
308
|
method: "GET"
|
|
309
309
|
});
|
|
310
|
-
if (!
|
|
311
|
-
throw new Error(`Failed to get connection: ${await
|
|
312
|
-
const n = await
|
|
310
|
+
if (!t.ok)
|
|
311
|
+
throw new Error(`Failed to get connection: ${await t.text()}`);
|
|
312
|
+
const n = await t.json();
|
|
313
313
|
if (!n.id || !n.metadata || !n.status || !n.sealed)
|
|
314
314
|
throw new Error("Data missing from server response");
|
|
315
|
-
const
|
|
315
|
+
const r = {
|
|
316
316
|
id: n.id,
|
|
317
317
|
metadata: n.metadata,
|
|
318
318
|
status: n.status
|
|
319
319
|
};
|
|
320
320
|
if (n.status === "closed")
|
|
321
|
-
return
|
|
322
|
-
const
|
|
323
|
-
ciphertext:
|
|
324
|
-
key:
|
|
321
|
+
return r;
|
|
322
|
+
const s = n.sealed[n.sealed.length - 1], i = await f({
|
|
323
|
+
ciphertext: s,
|
|
324
|
+
key: e.key
|
|
325
325
|
});
|
|
326
326
|
return n.status === "completed" ? {
|
|
327
|
-
...
|
|
327
|
+
...r,
|
|
328
328
|
result: i.result
|
|
329
329
|
} : {
|
|
330
|
-
...
|
|
330
|
+
...r,
|
|
331
331
|
tx: i.tx
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
class
|
|
335
|
-
constructor(
|
|
336
|
-
|
|
337
|
-
this.endpoint =
|
|
334
|
+
class T {
|
|
335
|
+
constructor(t) {
|
|
336
|
+
o(this, "endpoint");
|
|
337
|
+
this.endpoint = t;
|
|
338
338
|
}
|
|
339
339
|
/**
|
|
340
340
|
* Creates a new encrypted connection
|
|
@@ -343,27 +343,27 @@ class M {
|
|
|
343
343
|
* @param metadata Connection metadata including participants and transaction type
|
|
344
344
|
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
345
345
|
*/
|
|
346
|
-
async create(
|
|
347
|
-
const
|
|
346
|
+
async create(t, n) {
|
|
347
|
+
const r = await E(t), s = {
|
|
348
348
|
metadata: n,
|
|
349
|
-
sealed:
|
|
349
|
+
sealed: r.ciphertext
|
|
350
350
|
}, i = await fetch(this.endpoint, {
|
|
351
351
|
method: "POST",
|
|
352
352
|
headers: {
|
|
353
353
|
"Content-Type": "application/json"
|
|
354
354
|
},
|
|
355
|
-
body: JSON.stringify(
|
|
355
|
+
body: JSON.stringify(s)
|
|
356
356
|
});
|
|
357
357
|
if (!i.ok)
|
|
358
358
|
throw new Error(`Failed to create connection: ${await i.text()}`);
|
|
359
|
-
const
|
|
359
|
+
const a = await i.json();
|
|
360
360
|
return {
|
|
361
|
-
id:
|
|
362
|
-
version:
|
|
363
|
-
status:
|
|
361
|
+
id: a.id,
|
|
362
|
+
version: a.version,
|
|
363
|
+
status: a.status,
|
|
364
364
|
metadata: n,
|
|
365
|
-
data:
|
|
366
|
-
key:
|
|
365
|
+
data: t,
|
|
366
|
+
key: r.key
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
@@ -376,12 +376,12 @@ class M {
|
|
|
376
376
|
* @param key Current encryption key
|
|
377
377
|
* @returns Promise resolving to updated connection details including new encryption key
|
|
378
378
|
*/
|
|
379
|
-
async update(
|
|
380
|
-
const
|
|
381
|
-
sealed:
|
|
382
|
-
version:
|
|
383
|
-
status:
|
|
384
|
-
}, h = await fetch(`${this.endpoint}/${
|
|
379
|
+
async update(t, n, r, s, i) {
|
|
380
|
+
const a = await E(n, i), c = {
|
|
381
|
+
sealed: a.ciphertext,
|
|
382
|
+
version: r,
|
|
383
|
+
status: s
|
|
384
|
+
}, h = await fetch(`${this.endpoint}/${t}`, {
|
|
385
385
|
method: "PATCH",
|
|
386
386
|
headers: {
|
|
387
387
|
"Content-Type": "application/json"
|
|
@@ -397,7 +397,7 @@ class M {
|
|
|
397
397
|
version: d.version,
|
|
398
398
|
status: d.status,
|
|
399
399
|
data: n,
|
|
400
|
-
key:
|
|
400
|
+
key: a.key
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
@@ -407,22 +407,22 @@ class M {
|
|
|
407
407
|
* @param key Encryption key from previous create/update operation
|
|
408
408
|
* @returns Promise resolving to connection details including decrypted data
|
|
409
409
|
*/
|
|
410
|
-
async get(
|
|
411
|
-
const
|
|
410
|
+
async get(t, n) {
|
|
411
|
+
const r = await fetch(`${this.endpoint}/${t}`, {
|
|
412
412
|
method: "GET"
|
|
413
413
|
});
|
|
414
|
-
if (!
|
|
415
|
-
throw new Error(`Failed to get connection: ${await
|
|
416
|
-
const
|
|
414
|
+
if (!r.ok)
|
|
415
|
+
throw new Error(`Failed to get connection: ${await r.text()}`);
|
|
416
|
+
const s = await r.json(), i = s.sealed[s.sealed.length - 1], a = await f({
|
|
417
417
|
ciphertext: i,
|
|
418
418
|
key: n
|
|
419
419
|
});
|
|
420
420
|
return {
|
|
421
|
-
id:
|
|
422
|
-
status:
|
|
423
|
-
version:
|
|
424
|
-
metadata:
|
|
425
|
-
data:
|
|
421
|
+
id: s.id,
|
|
422
|
+
status: s.status,
|
|
423
|
+
version: s.version,
|
|
424
|
+
metadata: s.metadata,
|
|
425
|
+
data: a,
|
|
426
426
|
key: n
|
|
427
427
|
};
|
|
428
428
|
}
|
|
@@ -431,27 +431,27 @@ class M {
|
|
|
431
431
|
* @param id Connection ID
|
|
432
432
|
* @returns Promise resolving when the connection is closed
|
|
433
433
|
*/
|
|
434
|
-
async close(
|
|
435
|
-
const n = await fetch(`${this.endpoint}/${
|
|
434
|
+
async close(t) {
|
|
435
|
+
const n = await fetch(`${this.endpoint}/${t}`, {
|
|
436
436
|
method: "DELETE"
|
|
437
437
|
});
|
|
438
438
|
if (!n.ok)
|
|
439
439
|
throw new Error(`Failed to close connection: ${await n.text()}`);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
class
|
|
442
|
+
class B {
|
|
443
443
|
/**
|
|
444
444
|
* Creates a new instance of the Notabene SDK
|
|
445
445
|
*
|
|
446
446
|
* @param config - Configuration options for the Notabene SDK
|
|
447
447
|
*/
|
|
448
|
-
constructor(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.uxUrl =
|
|
448
|
+
constructor(t) {
|
|
449
|
+
o(this, "nodeUrl");
|
|
450
|
+
o(this, "authToken");
|
|
451
|
+
o(this, "uxUrl");
|
|
452
|
+
o(this, "theme");
|
|
453
|
+
o(this, "locale");
|
|
454
|
+
this.uxUrl = t.uxUrl || "https://connect.notabene.id", this.nodeUrl = t.nodeUrl, this.authToken = t.authToken, this.theme = t.theme, this.locale = t.locale;
|
|
455
455
|
}
|
|
456
456
|
/**
|
|
457
457
|
* Generates a URL for a Notabene component
|
|
@@ -463,15 +463,15 @@ class k {
|
|
|
463
463
|
* @returns component URL
|
|
464
464
|
* @internal
|
|
465
465
|
*/
|
|
466
|
-
componentUrl(
|
|
466
|
+
componentUrl(t, n, r, s) {
|
|
467
467
|
const i = new URL(this.uxUrl);
|
|
468
|
-
i.pathname =
|
|
469
|
-
const
|
|
468
|
+
i.pathname = t;
|
|
469
|
+
const a = M({
|
|
470
470
|
authToken: this.authToken,
|
|
471
471
|
value: n,
|
|
472
|
-
configuration:
|
|
472
|
+
configuration: r
|
|
473
473
|
});
|
|
474
|
-
return i.hash =
|
|
474
|
+
return i.hash = a, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), s && (s.callback && i.searchParams.set("callback_url", s.callback), s.redirectUri && i.searchParams.set("redirect_uri", s.redirectUri)), i.toString();
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Creates a new embedded component
|
|
@@ -483,11 +483,11 @@ class k {
|
|
|
483
483
|
* @returns A new EmbeddedComponent instance
|
|
484
484
|
* @internal
|
|
485
485
|
*/
|
|
486
|
-
createComponent(
|
|
487
|
-
return new
|
|
488
|
-
this.componentUrl(
|
|
486
|
+
createComponent(t, n, r, s) {
|
|
487
|
+
return new x(
|
|
488
|
+
this.componentUrl(t, n, r, s),
|
|
489
489
|
n,
|
|
490
|
-
|
|
490
|
+
r
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
493
|
/**
|
|
@@ -498,12 +498,12 @@ class k {
|
|
|
498
498
|
* @param callbacks - Optional callback configuration
|
|
499
499
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
500
500
|
*/
|
|
501
|
-
createWithdrawalAssist(
|
|
501
|
+
createWithdrawalAssist(t, n, r) {
|
|
502
502
|
return this.createComponent(
|
|
503
503
|
"withdrawal-assist",
|
|
504
|
-
|
|
504
|
+
t,
|
|
505
505
|
n,
|
|
506
|
-
|
|
506
|
+
r
|
|
507
507
|
);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
@@ -515,12 +515,12 @@ class k {
|
|
|
515
515
|
* @returns A new EmbeddedComponent instance for connection
|
|
516
516
|
* @alpha
|
|
517
517
|
*/
|
|
518
|
-
createConnectWallet(
|
|
518
|
+
createConnectWallet(t, n, r) {
|
|
519
519
|
return this.createComponent(
|
|
520
520
|
"connect",
|
|
521
|
-
|
|
521
|
+
t,
|
|
522
522
|
n,
|
|
523
|
-
|
|
523
|
+
r
|
|
524
524
|
);
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
@@ -532,12 +532,12 @@ class k {
|
|
|
532
532
|
* @returns A new EmbeddedComponent instance for deposit requests
|
|
533
533
|
* @public
|
|
534
534
|
*/
|
|
535
|
-
createDepositRequest(
|
|
535
|
+
createDepositRequest(t, n, r) {
|
|
536
536
|
return this.createComponent(
|
|
537
537
|
"deposit-request",
|
|
538
|
-
|
|
538
|
+
t,
|
|
539
539
|
n,
|
|
540
|
-
|
|
540
|
+
r
|
|
541
541
|
);
|
|
542
542
|
}
|
|
543
543
|
/**
|
|
@@ -549,29 +549,32 @@ class k {
|
|
|
549
549
|
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
550
550
|
* @public
|
|
551
551
|
*/
|
|
552
|
-
createDepositAssist(
|
|
552
|
+
createDepositAssist(t, n, r) {
|
|
553
553
|
return this.createComponent(
|
|
554
554
|
"deposit-assist",
|
|
555
|
-
|
|
555
|
+
t,
|
|
556
556
|
n,
|
|
557
|
-
|
|
557
|
+
r
|
|
558
558
|
);
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
export {
|
|
562
|
-
|
|
562
|
+
g as AgentType,
|
|
563
563
|
l as CMType,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
y as CodeVerificationStatus,
|
|
565
|
+
T as ConnectionManager,
|
|
566
|
+
x as EmbeddedComponent,
|
|
567
|
+
_ as ErrorIdentifierCode,
|
|
567
568
|
p as HMType,
|
|
569
|
+
b as IdentityVerificationMethod,
|
|
570
|
+
C as OAuthProvider,
|
|
568
571
|
I as PersonType,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
572
|
+
D as ProofStatus,
|
|
573
|
+
R as ProofTypes,
|
|
574
|
+
N as Status,
|
|
575
|
+
L as VASPSearchControl,
|
|
576
|
+
U as ValidationSections,
|
|
577
|
+
k as decodeFragmentToObject,
|
|
578
|
+
B as default,
|
|
579
|
+
P as getRefreshResult
|
|
577
580
|
};
|