@notabene/javascript-sdk 2.14.0-next.4 → 2.14.1-next.1
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 +73 -51
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +73 -51
- package/dist/esm/notabene.js +363 -335
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +73 -51
- package/dist/notabene.js +363 -335
- package/package.json +1 -1
- package/src/responseTransformer/__tests__/transformer.test.ts +597 -0
- package/src/responseTransformer/mappers.ts +80 -26
- package/src/responseTransformer/transformer.ts +121 -73
- package/src/responseTransformer/types.ts +11 -1
- package/src/responseTransformer/utils.ts +13 -0
- package/src/types.ts +0 -3
package/dist/esm/notabene.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (e, t,
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var U = (e, t, r) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var c = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
var x = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(x || {}), p = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(p || {}), M = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(M || {}), V = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(V || {}), W = /* @__PURE__ */ ((e) => (e.SMS = "sms", e.EMAIL = "email", e))(W || {}), k = /* @__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))(k || {}), B = /* @__PURE__ */ ((e) => (e.COINBASE = "coinbase", e))(B || {}), F = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(F || {}), u = /* @__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))(u || {}), J = /* @__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))(J || {}), $ = /* @__PURE__ */ ((e) => (e.WALLET_ADDRESS_NOT_CONNECTED = "WALLET_ADDRESS_NOT_CONNECTED", e.WALLET_LOCKED = "WALLET_LOCKED", e.WALLET_UNREACHABLE = "WALLET_UNREACHABLE", e.JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE = "JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE", e.IDV_UNAVAILABLE = "IDV_UNAVAILABLE", e))($ || {}), S = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(S || {}), j = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(j || {}), G = /* @__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.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))(G || {});
|
|
5
|
+
class q {
|
|
6
6
|
constructor() {
|
|
7
7
|
c(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
8
|
c(this, "port");
|
|
@@ -29,8 +29,8 @@ class k {
|
|
|
29
29
|
* @param callback - The callback function to execute when matching messages are received
|
|
30
30
|
|
|
31
31
|
*/
|
|
32
|
-
on(t,
|
|
33
|
-
return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(
|
|
32
|
+
on(t, r) {
|
|
33
|
+
return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(r), () => this.off(t, r);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Removes a callback for a specific message type.
|
|
@@ -41,9 +41,9 @@ class k {
|
|
|
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(t,
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
off(t, r) {
|
|
45
|
+
const n = this.listeners.get(t);
|
|
46
|
+
n && (n.delete(r), n.size === 0 && this.listeners.delete(t));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Internal message handler for processing received messages.
|
|
@@ -54,10 +54,10 @@ class k {
|
|
|
54
54
|
* @param event - The message event containing the component message
|
|
55
55
|
*/
|
|
56
56
|
handleMessage(t) {
|
|
57
|
-
const
|
|
58
|
-
if (typeof
|
|
59
|
-
const
|
|
60
|
-
|
|
57
|
+
const r = t.data;
|
|
58
|
+
if (typeof r == "object" && r !== null && "type" in r) {
|
|
59
|
+
const n = r.type, i = this.listeners.get(n);
|
|
60
|
+
i && i.forEach((o) => o(r));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -68,13 +68,13 @@ class k {
|
|
|
68
68
|
this.port && this.port.postMessage(t);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class K {
|
|
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(t,
|
|
77
|
+
constructor(t, r, n) {
|
|
78
78
|
c(this, "_url");
|
|
79
79
|
c(this, "_value");
|
|
80
80
|
c(this, "_options");
|
|
@@ -82,10 +82,10 @@ class J {
|
|
|
82
82
|
c(this, "iframe");
|
|
83
83
|
c(this, "eventManager");
|
|
84
84
|
c(this, "modal");
|
|
85
|
-
this._url = t, this._value =
|
|
86
|
-
|
|
87
|
-
}), this.on(
|
|
88
|
-
|
|
85
|
+
this._url = t, this._value = r, this._options = n, this.eventManager = new q(), this.on(u.INVALID, (i) => {
|
|
86
|
+
i.type === u.INVALID && (this._errors = i.errors, this._value = i.value);
|
|
87
|
+
}), this.on(u.RESIZE, (i) => {
|
|
88
|
+
i.type === u.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -120,20 +120,20 @@ class J {
|
|
|
120
120
|
* @throws Will throw an error if the parent element is not found
|
|
121
121
|
*/
|
|
122
122
|
mount(t) {
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
125
|
-
this.embed(
|
|
123
|
+
const r = document.querySelector(t);
|
|
124
|
+
if (!r) throw new Error(`parentID ${t} not found`);
|
|
125
|
+
this.embed(r);
|
|
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(t,
|
|
132
|
-
var
|
|
133
|
-
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (
|
|
131
|
+
embed(t, r = !1) {
|
|
132
|
+
var n, i;
|
|
133
|
+
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&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", (o) => {
|
|
134
134
|
var s, a;
|
|
135
|
-
|
|
136
|
-
}), (
|
|
135
|
+
o.source === ((s = this.iframe) == null ? void 0 : s.contentWindow) && ((a = this.eventManager) == null || a.setPort(o.ports[0]));
|
|
136
|
+
}), (i = (n = this.iframe) == null ? void 0 : n.contentWindow) == null || i.focus();
|
|
137
137
|
}
|
|
138
138
|
removeEmbed() {
|
|
139
139
|
this.iframe && this.iframe.remove();
|
|
@@ -150,40 +150,40 @@ class J {
|
|
|
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(t,
|
|
154
|
-
return this.eventManager.on(t,
|
|
153
|
+
on(t, r) {
|
|
154
|
+
return this.eventManager.on(t, r);
|
|
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(t,
|
|
162
|
-
this.eventManager.off(t,
|
|
161
|
+
off(t, r) {
|
|
162
|
+
this.eventManager.off(t, r);
|
|
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(t,
|
|
169
|
-
this._value = t,
|
|
168
|
+
update(t, r) {
|
|
169
|
+
this._value = t, r && (this._options = r), this.send({ type: S.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((t,
|
|
177
|
-
let
|
|
176
|
+
return new Promise((t, r) => {
|
|
177
|
+
let n, i, o;
|
|
178
178
|
function s() {
|
|
179
|
-
|
|
179
|
+
n && n(), i && i(), o && o();
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
n = this.on(u.COMPLETE, (a) => {
|
|
182
182
|
t(a.response), s();
|
|
183
|
-
}),
|
|
184
|
-
|
|
185
|
-
}),
|
|
186
|
-
|
|
183
|
+
}), i = this.on(u.CANCEL, () => {
|
|
184
|
+
r(new Error("User cancelled")), s();
|
|
185
|
+
}), o = this.on("error", (a) => {
|
|
186
|
+
r(new Error(a.message)), s();
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
}
|
|
@@ -192,15 +192,15 @@ class J {
|
|
|
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 t = this.on(
|
|
195
|
+
const t = this.on(u.CANCEL, () => {
|
|
196
196
|
this.closeModal();
|
|
197
|
-
}),
|
|
197
|
+
}), r = this.on(u.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
|
-
t(),
|
|
203
|
+
t(), r();
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -223,84 +223,84 @@ class J {
|
|
|
223
223
|
"_blank",
|
|
224
224
|
"popup=true,width=600,height=600"
|
|
225
225
|
);
|
|
226
|
-
window.addEventListener("message", (
|
|
227
|
-
var
|
|
228
|
-
|
|
226
|
+
window.addEventListener("message", (i) => {
|
|
227
|
+
var o;
|
|
228
|
+
i.source === t && (console.log("received message from popup", i.data), (o = this.eventManager) == null || o.setPort(i.ports[0]));
|
|
229
229
|
});
|
|
230
|
-
const
|
|
230
|
+
const r = this.on(u.CANCEL, () => {
|
|
231
231
|
t == null || t.close();
|
|
232
|
-
}),
|
|
232
|
+
}), n = this.on(u.COMPLETE, () => {
|
|
233
233
|
t == null || t.close();
|
|
234
234
|
});
|
|
235
235
|
return this.completion().finally(() => {
|
|
236
|
-
|
|
236
|
+
r(), n();
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
return Object.entries(e).map(([t,
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
typeof
|
|
240
|
+
function H(e) {
|
|
241
|
+
return Object.entries(e).map(([t, r]) => {
|
|
242
|
+
if (r == null) return;
|
|
243
|
+
const n = encodeURIComponent(t), i = encodeURIComponent(
|
|
244
|
+
typeof r == "object" ? JSON.stringify(r) : String(r)
|
|
245
245
|
// Use String() to handle all primitive types
|
|
246
246
|
);
|
|
247
|
-
return `${
|
|
247
|
+
return `${n}=${i}`;
|
|
248
248
|
}).filter((t) => t !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function de(e) {
|
|
251
251
|
const t = e.slice(1);
|
|
252
252
|
return t ? t.split("&").filter(Boolean).reduce(
|
|
253
|
-
(
|
|
254
|
-
const [
|
|
255
|
-
return
|
|
253
|
+
(n, i) => {
|
|
254
|
+
const [o, s] = i.split("=");
|
|
255
|
+
return o && (n[decodeURIComponent(o)] = s ? decodeURIComponent(s) : ""), n;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
260
|
new TextEncoder();
|
|
261
|
-
const
|
|
262
|
-
function
|
|
261
|
+
const b = new TextDecoder();
|
|
262
|
+
function X(e) {
|
|
263
263
|
if (Uint8Array.fromBase64)
|
|
264
264
|
return Uint8Array.fromBase64(e);
|
|
265
|
-
const t = atob(e),
|
|
266
|
-
for (let
|
|
267
|
-
n
|
|
268
|
-
return
|
|
265
|
+
const t = atob(e), r = new Uint8Array(t.length);
|
|
266
|
+
for (let n = 0; n < t.length; n++)
|
|
267
|
+
r[n] = t.charCodeAt(n);
|
|
268
|
+
return r;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function z(e) {
|
|
271
271
|
if (Uint8Array.fromBase64)
|
|
272
|
-
return Uint8Array.fromBase64(typeof e == "string" ? e :
|
|
272
|
+
return Uint8Array.fromBase64(typeof e == "string" ? e : b.decode(e), {
|
|
273
273
|
alphabet: "base64url"
|
|
274
274
|
});
|
|
275
275
|
let t = e;
|
|
276
|
-
t instanceof Uint8Array && (t =
|
|
276
|
+
t instanceof Uint8Array && (t = b.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
277
277
|
try {
|
|
278
|
-
return
|
|
278
|
+
return X(t);
|
|
279
279
|
} catch {
|
|
280
280
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
class
|
|
284
|
-
constructor(
|
|
285
|
-
var
|
|
286
|
-
super(
|
|
283
|
+
class R extends Error {
|
|
284
|
+
constructor(r, n) {
|
|
285
|
+
var i;
|
|
286
|
+
super(r, n);
|
|
287
287
|
c(this, "code", "ERR_JOSE_GENERIC");
|
|
288
|
-
this.name = this.constructor.name, (
|
|
288
|
+
this.name = this.constructor.name, (i = Error.captureStackTrace) == null || i.call(Error, this, this.constructor);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
c(
|
|
292
|
-
class
|
|
291
|
+
c(R, "code", "ERR_JOSE_GENERIC");
|
|
292
|
+
class h extends R {
|
|
293
293
|
constructor() {
|
|
294
294
|
super(...arguments);
|
|
295
295
|
c(this, "code", "ERR_JWT_INVALID");
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
c(
|
|
299
|
-
function
|
|
298
|
+
c(h, "code", "ERR_JWT_INVALID");
|
|
299
|
+
function Y(e) {
|
|
300
300
|
return typeof e == "object" && e !== null;
|
|
301
301
|
}
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
302
|
+
const Q = (e) => {
|
|
303
|
+
if (!Y(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
304
304
|
return !1;
|
|
305
305
|
if (Object.getPrototypeOf(e) === null)
|
|
306
306
|
return !0;
|
|
@@ -309,33 +309,39 @@ const q = (e) => {
|
|
|
309
309
|
t = Object.getPrototypeOf(t);
|
|
310
310
|
return Object.getPrototypeOf(e) === t;
|
|
311
311
|
};
|
|
312
|
-
function
|
|
312
|
+
function Z(e) {
|
|
313
313
|
if (typeof e != "string")
|
|
314
|
-
throw new
|
|
315
|
-
const { 1: t, length:
|
|
316
|
-
if (
|
|
317
|
-
throw new
|
|
318
|
-
if (
|
|
319
|
-
throw new
|
|
314
|
+
throw new h("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
315
|
+
const { 1: t, length: r } = e.split(".");
|
|
316
|
+
if (r === 5)
|
|
317
|
+
throw new h("Only JWTs using Compact JWS serialization can be decoded");
|
|
318
|
+
if (r !== 3)
|
|
319
|
+
throw new h("Invalid JWT");
|
|
320
320
|
if (!t)
|
|
321
|
-
throw new
|
|
322
|
-
let
|
|
321
|
+
throw new h("JWTs must contain a payload");
|
|
322
|
+
let n;
|
|
323
323
|
try {
|
|
324
|
-
|
|
324
|
+
n = z(t);
|
|
325
325
|
} catch {
|
|
326
|
-
throw new
|
|
326
|
+
throw new h("Failed to base64url decode the payload");
|
|
327
327
|
}
|
|
328
|
-
let
|
|
328
|
+
let i;
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
i = JSON.parse(b.decode(n));
|
|
331
331
|
} catch {
|
|
332
|
-
throw new
|
|
332
|
+
throw new h("Failed to parse the decoded payload as JSON");
|
|
333
333
|
}
|
|
334
|
-
if (!
|
|
335
|
-
throw new
|
|
336
|
-
return
|
|
334
|
+
if (!Q(i))
|
|
335
|
+
throw new h("Invalid JWT Claims Set");
|
|
336
|
+
return i;
|
|
337
|
+
}
|
|
338
|
+
function N(e) {
|
|
339
|
+
return "source" in e && e.source !== void 0;
|
|
337
340
|
}
|
|
338
|
-
function E(e
|
|
341
|
+
function E(e) {
|
|
342
|
+
return !N(e);
|
|
343
|
+
}
|
|
344
|
+
function g(e, t) {
|
|
339
345
|
if (t != null && t.email)
|
|
340
346
|
return `did:email:${t.email}`;
|
|
341
347
|
if (t != null && t.name)
|
|
@@ -344,27 +350,27 @@ function E(e, t) {
|
|
|
344
350
|
`Unable to generate ${e} ID: missing required ${e} information`
|
|
345
351
|
);
|
|
346
352
|
}
|
|
347
|
-
function
|
|
348
|
-
const { nameIdentifier: t, ...
|
|
353
|
+
function ee(e) {
|
|
354
|
+
const { nameIdentifier: t, ...r } = e;
|
|
349
355
|
return {
|
|
350
|
-
...
|
|
351
|
-
nameIdentifier: t == null ? void 0 : t.map(({ nameIdentifierType:
|
|
352
|
-
...
|
|
353
|
-
naturalPersonNameIdentifierType:
|
|
356
|
+
...r,
|
|
357
|
+
nameIdentifier: t == null ? void 0 : t.map(({ nameIdentifierType: n, ...i }) => ({
|
|
358
|
+
...i,
|
|
359
|
+
naturalPersonNameIdentifierType: n
|
|
354
360
|
}))
|
|
355
361
|
};
|
|
356
362
|
}
|
|
357
|
-
function
|
|
363
|
+
function L(e, t) {
|
|
358
364
|
return {
|
|
359
365
|
naturalPerson: e.naturalPerson ? {
|
|
360
366
|
...e.naturalPerson,
|
|
361
|
-
name:
|
|
367
|
+
name: ee(e.naturalPerson.name)
|
|
362
368
|
} : void 0,
|
|
363
369
|
legalPerson: e.legalPerson,
|
|
364
370
|
accountNumber: [t]
|
|
365
371
|
};
|
|
366
372
|
}
|
|
367
|
-
const
|
|
373
|
+
const I = [
|
|
368
374
|
{
|
|
369
375
|
addressType: "GEOG",
|
|
370
376
|
addressLine: ["1234 Main Street"],
|
|
@@ -372,62 +378,62 @@ const p = [
|
|
|
372
378
|
country: "US"
|
|
373
379
|
}
|
|
374
380
|
];
|
|
375
|
-
function
|
|
381
|
+
function te(e) {
|
|
376
382
|
const t = e.trim();
|
|
377
383
|
if (!t)
|
|
378
384
|
return { primaryIdentifier: "", secondaryIdentifier: "" };
|
|
379
|
-
const
|
|
380
|
-
return { primaryIdentifier:
|
|
381
|
-
}
|
|
382
|
-
function
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
return
|
|
386
|
-
...
|
|
387
|
-
geographicAddress:
|
|
388
|
-
}),
|
|
389
|
-
...
|
|
390
|
-
geographicAddress:
|
|
391
|
-
}),
|
|
385
|
+
const r = t.split(/\s+/), n = r[r.length - 1], i = r.slice(0, -1), o = i.length > 0 ? i.join(" ") : n;
|
|
386
|
+
return { primaryIdentifier: n, secondaryIdentifier: o };
|
|
387
|
+
}
|
|
388
|
+
function re(e, t, r = ["1234567890"]) {
|
|
389
|
+
const n = t == null ? void 0 : t.map((i) => {
|
|
390
|
+
const o = { ...i };
|
|
391
|
+
return o.naturalPerson && (o.naturalPerson = {
|
|
392
|
+
...o.naturalPerson,
|
|
393
|
+
geographicAddress: I
|
|
394
|
+
}), o.legalPerson && (o.legalPerson = {
|
|
395
|
+
...o.legalPerson,
|
|
396
|
+
geographicAddress: I
|
|
397
|
+
}), o;
|
|
392
398
|
});
|
|
393
|
-
return e === "originator" ? { originatorPersons:
|
|
399
|
+
return e === "originator" ? { originatorPersons: n, accountNumber: r } : { beneficiaryPersons: n, accountNumber: r };
|
|
394
400
|
}
|
|
395
|
-
function
|
|
396
|
-
const { primaryIdentifier:
|
|
401
|
+
function ne(e, t = "John Doe") {
|
|
402
|
+
const { primaryIdentifier: r, secondaryIdentifier: n } = te(t), i = {
|
|
397
403
|
naturalPerson: {
|
|
398
404
|
name: [
|
|
399
405
|
{
|
|
400
406
|
nameIdentifier: [
|
|
401
407
|
{
|
|
402
|
-
primaryIdentifier:
|
|
403
|
-
...
|
|
408
|
+
primaryIdentifier: r,
|
|
409
|
+
...n ? { secondaryIdentifier: n } : {},
|
|
404
410
|
nameIdentifierType: "LEGL"
|
|
405
411
|
}
|
|
406
412
|
]
|
|
407
413
|
}
|
|
408
414
|
],
|
|
409
|
-
geographicAddress:
|
|
415
|
+
geographicAddress: I
|
|
410
416
|
}
|
|
411
417
|
};
|
|
412
|
-
return e === "originator" ? { originatorPersons: [
|
|
418
|
+
return e === "originator" ? { originatorPersons: [i], accountNumber: ["1234567890"] } : { beneficiaryPersons: [i], accountNumber: ["1234567890"] };
|
|
413
419
|
}
|
|
414
|
-
const
|
|
420
|
+
const ie = (e) => ({
|
|
415
421
|
...e,
|
|
416
422
|
// @ts-expect-error Preserving the original logic
|
|
417
423
|
name: e.name ? [e.name] : void 0
|
|
418
|
-
}),
|
|
424
|
+
}), oe = (e) => ({
|
|
419
425
|
...e,
|
|
420
|
-
naturalPerson: e.naturalPerson ?
|
|
421
|
-
}),
|
|
426
|
+
naturalPerson: e.naturalPerson ? ie(e.naturalPerson) : void 0
|
|
427
|
+
}), se = ({ beneficiary: e, originator: t }, r, n, i, o) => {
|
|
422
428
|
var s;
|
|
423
429
|
{
|
|
424
430
|
const a = e && {
|
|
425
431
|
...e,
|
|
426
|
-
...
|
|
427
|
-
beneficiaryPersons: (s = e.beneficiaryPersons) == null ? void 0 : s.map(
|
|
432
|
+
...i && { accountNumber: [i] },
|
|
433
|
+
beneficiaryPersons: (s = e.beneficiaryPersons) == null ? void 0 : s.map(oe)
|
|
428
434
|
};
|
|
429
|
-
if (
|
|
430
|
-
const d =
|
|
435
|
+
if (n && (a != null && a.beneficiaryPersons)) {
|
|
436
|
+
const d = re(
|
|
431
437
|
"originator",
|
|
432
438
|
a == null ? void 0 : a.beneficiaryPersons
|
|
433
439
|
);
|
|
@@ -441,15 +447,15 @@ const Z = (e) => ({
|
|
|
441
447
|
}
|
|
442
448
|
return {
|
|
443
449
|
beneficiary: a,
|
|
444
|
-
originator:
|
|
450
|
+
originator: ne("originator", r)
|
|
445
451
|
};
|
|
446
452
|
}
|
|
447
453
|
};
|
|
448
|
-
function
|
|
449
|
-
var
|
|
450
|
-
const { beneficiary:
|
|
451
|
-
|
|
452
|
-
(
|
|
454
|
+
function ae(e, t, r) {
|
|
455
|
+
var o, s;
|
|
456
|
+
const { beneficiary: n, originator: i } = se(
|
|
457
|
+
r,
|
|
458
|
+
(o = e.customer) == null ? void 0 : o.name,
|
|
453
459
|
t.originatorEqualsBeneficiary,
|
|
454
460
|
e.destination
|
|
455
461
|
);
|
|
@@ -460,193 +466,215 @@ function ne(e, t, n) {
|
|
|
460
466
|
originatorVASPdid: t.originatorVASPdid,
|
|
461
467
|
...t.beneficiaryVASPdid && !t.beneficiaryProof ? { beneficiaryVASPdid: t.beneficiaryVASPdid } : {},
|
|
462
468
|
transactionBlockchainInfo: {
|
|
463
|
-
...(
|
|
469
|
+
...(i == null ? void 0 : i.accountNumber) && { origin: i.accountNumber[0] },
|
|
464
470
|
...e.destination && { destination: e.destination }
|
|
465
471
|
},
|
|
466
472
|
...t.beneficiaryProof && {
|
|
467
473
|
beneficiaryProof: t.beneficiaryProof
|
|
468
474
|
},
|
|
469
|
-
...
|
|
470
|
-
...
|
|
475
|
+
...n && { beneficiary: n },
|
|
476
|
+
...i && { originator: i },
|
|
471
477
|
...t.originatorEqualsBeneficiary && {
|
|
472
478
|
originatorEqualsBeneficiary: t.originatorEqualsBeneficiary
|
|
473
479
|
}
|
|
474
480
|
};
|
|
475
481
|
}
|
|
476
|
-
function
|
|
477
|
-
var
|
|
478
|
-
const
|
|
479
|
-
return t.originatorVASPdid &&
|
|
482
|
+
function C(e, t, r = {}) {
|
|
483
|
+
var m, f, A;
|
|
484
|
+
const n = E(e), i = n ? e.customer : e.counterparty, o = n ? e.counterparty : e.customer, s = (r == null ? void 0 : r.originatorId) || g("originator", i), a = (r == null ? void 0 : r.beneficiaryId) || g("beneficiary", o), d = (r == null ? void 0 : r.referenceId) || t.transactionId || Math.random().toString(36).substring(2, 15), l = [];
|
|
485
|
+
return t.originatorVASPdid && l.push({
|
|
480
486
|
"@id": t.originatorVASPdid,
|
|
481
|
-
for:
|
|
487
|
+
for: s,
|
|
482
488
|
role: "VASP"
|
|
483
|
-
}), t.beneficiaryVASPdid &&
|
|
489
|
+
}), t.beneficiaryVASPdid && l.push({
|
|
484
490
|
"@id": t.beneficiaryVASPdid,
|
|
485
|
-
for:
|
|
491
|
+
for: a,
|
|
486
492
|
role: "VASP"
|
|
487
|
-
}), e.destination && ((
|
|
493
|
+
}), E(e) && e.destination && ((m = e == null ? void 0 : e.account) != null && m.did) && l.push({
|
|
488
494
|
"@id": e.account.did,
|
|
489
|
-
for: t.beneficiaryVASPdid ||
|
|
495
|
+
for: t.beneficiaryVASPdid || a,
|
|
490
496
|
role: "SettlementAddress"
|
|
497
|
+
}), N(e) && e.source && ((f = e.agent) != null && f.did) && l.push({
|
|
498
|
+
"@id": e.agent.did,
|
|
499
|
+
for: t.originatorVASPdid || s,
|
|
500
|
+
role: "SourceAddress"
|
|
491
501
|
}), {
|
|
492
|
-
originator: { "@id":
|
|
493
|
-
beneficiary: { "@id":
|
|
502
|
+
originator: { "@id": s },
|
|
503
|
+
beneficiary: { "@id": a },
|
|
494
504
|
asset: e.asset,
|
|
495
|
-
amount: ((
|
|
496
|
-
agents:
|
|
497
|
-
ref:
|
|
505
|
+
amount: ((A = e.amountDecimal) == null ? void 0 : A.toString()) || t.transactionAmount,
|
|
506
|
+
agents: l,
|
|
507
|
+
ref: d
|
|
498
508
|
};
|
|
499
509
|
}
|
|
500
|
-
function
|
|
501
|
-
var
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
function T(e, t, r = {}) {
|
|
511
|
+
var o, s, a, d, l, m;
|
|
512
|
+
if (E(e)) {
|
|
513
|
+
const f = r.beneficiaryId || g("beneficiary", e.counterparty), A = (
|
|
514
|
+
// If counterparty type is SELF, reuse originator data for beneficiary
|
|
515
|
+
((o = e.counterparty) == null ? void 0 : o.type) === p.SELF && r.originator ? r.originator.originatorPerson : (
|
|
516
|
+
// Convert all beneficiary persons from V1 to V2 format
|
|
517
|
+
((a = (s = t.beneficiary) == null ? void 0 : s.beneficiaryPersons) == null ? void 0 : a.map(
|
|
518
|
+
(O) => L(O, f)
|
|
519
|
+
)) || []
|
|
520
|
+
)
|
|
521
|
+
);
|
|
522
|
+
return {
|
|
523
|
+
ivms101: {
|
|
524
|
+
originator: r.originator,
|
|
525
|
+
beneficiary: {
|
|
526
|
+
beneficiaryPerson: A
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
const n = r.originatorId || g("originator", e.counterparty);
|
|
511
532
|
return {
|
|
512
533
|
ivms101: {
|
|
513
|
-
originator:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
534
|
+
originator: {
|
|
535
|
+
originatorPerson: ((d = e.counterparty) == null ? void 0 : d.type) === p.SELF && r.beneficiary ? r.beneficiary.beneficiaryPerson : (
|
|
536
|
+
// Convert all originator persons from V1 to V2 format
|
|
537
|
+
((m = (l = t.originator) == null ? void 0 : l.originatorPersons) == null ? void 0 : m.map(
|
|
538
|
+
(f) => L(f, n)
|
|
539
|
+
)) || []
|
|
540
|
+
)
|
|
541
|
+
},
|
|
542
|
+
beneficiary: r.beneficiary
|
|
517
543
|
}
|
|
518
544
|
};
|
|
519
545
|
}
|
|
520
|
-
function
|
|
521
|
-
var o;
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
return r.beneficiaryId || (((o =
|
|
546
|
+
function P(e, t, r) {
|
|
547
|
+
var o, s;
|
|
548
|
+
const n = { ...e };
|
|
549
|
+
let i;
|
|
550
|
+
try {
|
|
551
|
+
const a = Z(t);
|
|
552
|
+
i = a == null ? void 0 : a.sub;
|
|
553
|
+
} catch {
|
|
554
|
+
}
|
|
555
|
+
return E(r) ? (!n.originatorId && i && (n.originatorId = i), n.beneficiaryId || (((o = r.counterparty) == null ? void 0 : o.type) === p.SELF ? n.beneficiaryId = n.originatorId : r.destination && (n.beneficiaryId = `did:key:${r.destination}`))) : N(r) && (!n.beneficiaryId && i && (n.beneficiaryId = i), n.originatorId || (((s = r.counterparty) == null ? void 0 : s.type) === p.SELF ? n.originatorId = n.beneficiaryId : r.source && (n.originatorId = `did:key:${r.source}`))), n;
|
|
530
556
|
}
|
|
531
|
-
function
|
|
557
|
+
function le(e) {
|
|
532
558
|
var s;
|
|
533
559
|
if (!e.txCreate || !e.ivms101)
|
|
534
560
|
throw new Error(
|
|
535
561
|
"Invalid response: missing required txCreate or ivms101 data"
|
|
536
562
|
);
|
|
537
|
-
const { value: t, ivms101:
|
|
563
|
+
const { value: t, ivms101: r, proof: n, txCreate: i } = e, o = {
|
|
538
564
|
destination: (t == null ? void 0 : t.destination) || "",
|
|
539
565
|
counterparty: (t == null ? void 0 : t.counterparty) || {},
|
|
540
566
|
agent: t == null ? void 0 : t.agent,
|
|
541
567
|
account: t == null ? void 0 : t.account,
|
|
542
|
-
proof:
|
|
543
|
-
asset: (t == null ? void 0 : t.asset) || (typeof
|
|
544
|
-
amountDecimal: (t == null ? void 0 : t.amountDecimal) || (
|
|
568
|
+
proof: n,
|
|
569
|
+
asset: (t == null ? void 0 : t.asset) || (typeof i.transactionAsset == "string" ? i.transactionAsset : (s = i.transactionAsset) == null ? void 0 : s.caip19) || "",
|
|
570
|
+
amountDecimal: (t == null ? void 0 : t.amountDecimal) || (i.transactionAmount ? parseFloat(i.transactionAmount) : 0),
|
|
545
571
|
customer: t == null ? void 0 : t.customer
|
|
546
572
|
};
|
|
547
|
-
return
|
|
573
|
+
return ae(o, i, r);
|
|
548
574
|
}
|
|
549
|
-
function
|
|
550
|
-
|
|
575
|
+
function ue(e, t, r = {}) {
|
|
576
|
+
const { value: n, txCreate: i, txUpdate: o, ivms101: s, proof: a } = e, d = E(n) ? i : o;
|
|
577
|
+
if (!d || !s)
|
|
551
578
|
throw new Error(
|
|
552
|
-
"Invalid response: missing required txCreate or ivms101 data"
|
|
579
|
+
"Invalid response: missing required txCreate/txUpdate or ivms101 data"
|
|
553
580
|
);
|
|
554
|
-
const
|
|
581
|
+
const l = P(r, t, n);
|
|
555
582
|
return {
|
|
556
|
-
createTx:
|
|
557
|
-
ivms101:
|
|
558
|
-
...
|
|
583
|
+
createTx: C(n, d, l),
|
|
584
|
+
ivms101: T(n, s, l),
|
|
585
|
+
...a && { confirmRelationship: { proof: a } }
|
|
559
586
|
};
|
|
560
587
|
}
|
|
561
|
-
function
|
|
562
|
-
|
|
588
|
+
function he(e, t, r = {}) {
|
|
589
|
+
const { value: n, txCreate: i, txUpdate: o } = e, s = E(n) ? i : o;
|
|
590
|
+
if (!s || !e.ivms101)
|
|
563
591
|
throw new Error(
|
|
564
|
-
"Invalid response: missing required txCreate or ivms101 data"
|
|
592
|
+
"Invalid response: missing required txCreate/txUpdate or ivms101 data"
|
|
565
593
|
);
|
|
566
|
-
const
|
|
567
|
-
return
|
|
594
|
+
const a = P(r, t, n);
|
|
595
|
+
return C(n, s, a);
|
|
568
596
|
}
|
|
569
|
-
function
|
|
597
|
+
function me(e, t, r = {}) {
|
|
570
598
|
if (!e.ivms101)
|
|
571
599
|
throw new Error("Invalid response: missing required ivms101 data");
|
|
572
|
-
const { value:
|
|
573
|
-
return
|
|
600
|
+
const { value: n, ivms101: i } = e, o = P(r, t, n);
|
|
601
|
+
return T(n, i, o);
|
|
574
602
|
}
|
|
575
|
-
async function
|
|
576
|
-
const
|
|
603
|
+
async function v(e, t) {
|
|
604
|
+
const r = JSON.stringify(e), n = new TextEncoder(), i = t ? w(t) : crypto.getRandomValues(new Uint8Array(32)), o = await crypto.subtle.importKey(
|
|
577
605
|
"raw",
|
|
578
|
-
|
|
606
|
+
i,
|
|
579
607
|
{ name: "AES-GCM" },
|
|
580
608
|
!1,
|
|
581
609
|
["encrypt"]
|
|
582
610
|
), s = crypto.getRandomValues(new Uint8Array(12)), a = await crypto.subtle.encrypt(
|
|
583
611
|
{ name: "AES-GCM", iv: s },
|
|
584
|
-
|
|
585
|
-
|
|
612
|
+
o,
|
|
613
|
+
n.encode(r)
|
|
586
614
|
);
|
|
587
615
|
return {
|
|
588
|
-
ciphertext: `${
|
|
589
|
-
key:
|
|
616
|
+
ciphertext: `${y(s)}-${y(a)}`,
|
|
617
|
+
key: y(i)
|
|
590
618
|
};
|
|
591
619
|
}
|
|
592
|
-
async function
|
|
593
|
-
const [
|
|
594
|
-
atob(t).split("").map((
|
|
595
|
-
),
|
|
620
|
+
async function _({ ciphertext: e, key: t }) {
|
|
621
|
+
const [r, n] = e.split("-"), i = new Uint8Array(
|
|
622
|
+
atob(t).split("").map((m) => m.charCodeAt(0))
|
|
623
|
+
), o = w(r), s = w(n), a = await crypto.subtle.importKey(
|
|
596
624
|
"raw",
|
|
597
|
-
|
|
625
|
+
i,
|
|
598
626
|
{ name: "AES-GCM" },
|
|
599
627
|
!1,
|
|
600
628
|
["decrypt"]
|
|
601
|
-
), d = new TextDecoder(),
|
|
602
|
-
{ name: "AES-GCM", iv: new Uint8Array(
|
|
629
|
+
), d = new TextDecoder(), l = await crypto.subtle.decrypt(
|
|
630
|
+
{ name: "AES-GCM", iv: new Uint8Array(o) },
|
|
603
631
|
a,
|
|
604
632
|
s
|
|
605
633
|
);
|
|
606
|
-
return JSON.parse(d.decode(
|
|
634
|
+
return JSON.parse(d.decode(l));
|
|
607
635
|
}
|
|
608
|
-
function
|
|
636
|
+
function y(e) {
|
|
609
637
|
const t = new Uint8Array(e);
|
|
610
|
-
let
|
|
611
|
-
for (let
|
|
612
|
-
|
|
613
|
-
return btoa(
|
|
614
|
-
}
|
|
615
|
-
function
|
|
616
|
-
const t = atob(e),
|
|
617
|
-
for (let
|
|
618
|
-
n
|
|
619
|
-
return
|
|
620
|
-
}
|
|
621
|
-
async function
|
|
638
|
+
let r = "";
|
|
639
|
+
for (let n = 0; n < t.length; n++)
|
|
640
|
+
r += String.fromCharCode(t[n]);
|
|
641
|
+
return btoa(r);
|
|
642
|
+
}
|
|
643
|
+
function w(e) {
|
|
644
|
+
const t = atob(e), r = new Uint8Array(t.length);
|
|
645
|
+
for (let n = 0; n < t.length; n++)
|
|
646
|
+
r[n] = t.charCodeAt(n);
|
|
647
|
+
return r;
|
|
648
|
+
}
|
|
649
|
+
async function fe(e) {
|
|
622
650
|
const t = await fetch(e.url, {
|
|
623
651
|
method: "GET"
|
|
624
652
|
});
|
|
625
653
|
if (!t.ok)
|
|
626
654
|
throw new Error(`Failed to get connection: ${await t.text()}`);
|
|
627
|
-
const
|
|
628
|
-
if (!
|
|
655
|
+
const r = await t.json();
|
|
656
|
+
if (!r.id || !r.metadata || !r.status || !r.sealed)
|
|
629
657
|
throw new Error("Data missing from server response");
|
|
630
|
-
const
|
|
631
|
-
id:
|
|
632
|
-
metadata:
|
|
633
|
-
status:
|
|
658
|
+
const n = {
|
|
659
|
+
id: r.id,
|
|
660
|
+
metadata: r.metadata,
|
|
661
|
+
status: r.status
|
|
634
662
|
};
|
|
635
|
-
if (
|
|
636
|
-
return
|
|
637
|
-
const
|
|
638
|
-
ciphertext:
|
|
663
|
+
if (r.status === "closed")
|
|
664
|
+
return n;
|
|
665
|
+
const i = r.sealed[r.sealed.length - 1], o = await _({
|
|
666
|
+
ciphertext: i,
|
|
639
667
|
key: e.key
|
|
640
668
|
});
|
|
641
|
-
return
|
|
642
|
-
...
|
|
643
|
-
result:
|
|
669
|
+
return r.status === "completed" ? {
|
|
670
|
+
...n,
|
|
671
|
+
result: o.result
|
|
644
672
|
} : {
|
|
645
|
-
...
|
|
646
|
-
tx:
|
|
673
|
+
...n,
|
|
674
|
+
tx: o.tx
|
|
647
675
|
};
|
|
648
676
|
}
|
|
649
|
-
class
|
|
677
|
+
class Ee {
|
|
650
678
|
constructor(t) {
|
|
651
679
|
c(this, "endpoint");
|
|
652
680
|
this.endpoint = t;
|
|
@@ -658,27 +686,27 @@ class le {
|
|
|
658
686
|
* @param metadata Connection metadata including participants and transaction type
|
|
659
687
|
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
660
688
|
*/
|
|
661
|
-
async create(t,
|
|
662
|
-
const
|
|
663
|
-
metadata:
|
|
664
|
-
sealed:
|
|
665
|
-
},
|
|
689
|
+
async create(t, r) {
|
|
690
|
+
const n = await v(t), i = {
|
|
691
|
+
metadata: r,
|
|
692
|
+
sealed: n.ciphertext
|
|
693
|
+
}, o = await fetch(this.endpoint, {
|
|
666
694
|
method: "POST",
|
|
667
695
|
headers: {
|
|
668
696
|
"Content-Type": "application/json"
|
|
669
697
|
},
|
|
670
|
-
body: JSON.stringify(
|
|
698
|
+
body: JSON.stringify(i)
|
|
671
699
|
});
|
|
672
|
-
if (!
|
|
673
|
-
throw new Error(`Failed to create connection: ${await
|
|
674
|
-
const s = await
|
|
700
|
+
if (!o.ok)
|
|
701
|
+
throw new Error(`Failed to create connection: ${await o.text()}`);
|
|
702
|
+
const s = await o.json();
|
|
675
703
|
return {
|
|
676
704
|
id: s.id,
|
|
677
705
|
version: s.version,
|
|
678
706
|
status: s.status,
|
|
679
|
-
metadata:
|
|
707
|
+
metadata: r,
|
|
680
708
|
data: t,
|
|
681
|
-
key:
|
|
709
|
+
key: n.key
|
|
682
710
|
};
|
|
683
711
|
}
|
|
684
712
|
/**
|
|
@@ -691,11 +719,11 @@ class le {
|
|
|
691
719
|
* @param key Current encryption key
|
|
692
720
|
* @returns Promise resolving to updated connection details including new encryption key
|
|
693
721
|
*/
|
|
694
|
-
async update(t, n,
|
|
695
|
-
const s = await
|
|
722
|
+
async update(t, r, n, i, o) {
|
|
723
|
+
const s = await v(r, o), a = {
|
|
696
724
|
sealed: s.ciphertext,
|
|
697
|
-
version:
|
|
698
|
-
status:
|
|
725
|
+
version: n,
|
|
726
|
+
status: i
|
|
699
727
|
}, d = await fetch(`${this.endpoint}/${t}`, {
|
|
700
728
|
method: "PATCH",
|
|
701
729
|
headers: {
|
|
@@ -705,13 +733,13 @@ class le {
|
|
|
705
733
|
});
|
|
706
734
|
if (!d.ok)
|
|
707
735
|
throw new Error(`Failed to update connection: ${await d.text()}`);
|
|
708
|
-
const
|
|
736
|
+
const l = await d.json();
|
|
709
737
|
return {
|
|
710
|
-
id:
|
|
711
|
-
metadata:
|
|
712
|
-
version:
|
|
713
|
-
status:
|
|
714
|
-
data:
|
|
738
|
+
id: l.id,
|
|
739
|
+
metadata: l.metadata,
|
|
740
|
+
version: l.version,
|
|
741
|
+
status: l.status,
|
|
742
|
+
data: r,
|
|
715
743
|
key: s.key
|
|
716
744
|
};
|
|
717
745
|
}
|
|
@@ -722,23 +750,23 @@ class le {
|
|
|
722
750
|
* @param key Encryption key from previous create/update operation
|
|
723
751
|
* @returns Promise resolving to connection details including decrypted data
|
|
724
752
|
*/
|
|
725
|
-
async get(t,
|
|
726
|
-
const
|
|
753
|
+
async get(t, r) {
|
|
754
|
+
const n = await fetch(`${this.endpoint}/${t}`, {
|
|
727
755
|
method: "GET"
|
|
728
756
|
});
|
|
729
|
-
if (!
|
|
730
|
-
throw new Error(`Failed to get connection: ${await
|
|
731
|
-
const
|
|
732
|
-
ciphertext:
|
|
733
|
-
key:
|
|
757
|
+
if (!n.ok)
|
|
758
|
+
throw new Error(`Failed to get connection: ${await n.text()}`);
|
|
759
|
+
const i = await n.json(), o = i.sealed[i.sealed.length - 1], s = await _({
|
|
760
|
+
ciphertext: o,
|
|
761
|
+
key: r
|
|
734
762
|
});
|
|
735
763
|
return {
|
|
736
|
-
id:
|
|
737
|
-
status:
|
|
738
|
-
version:
|
|
739
|
-
metadata:
|
|
764
|
+
id: i.id,
|
|
765
|
+
status: i.status,
|
|
766
|
+
version: i.version,
|
|
767
|
+
metadata: i.metadata,
|
|
740
768
|
data: s,
|
|
741
|
-
key:
|
|
769
|
+
key: r
|
|
742
770
|
};
|
|
743
771
|
}
|
|
744
772
|
/**
|
|
@@ -747,14 +775,14 @@ class le {
|
|
|
747
775
|
* @returns Promise resolving when the connection is closed
|
|
748
776
|
*/
|
|
749
777
|
async close(t) {
|
|
750
|
-
const
|
|
778
|
+
const r = await fetch(`${this.endpoint}/${t}`, {
|
|
751
779
|
method: "DELETE"
|
|
752
780
|
});
|
|
753
|
-
if (!
|
|
754
|
-
throw new Error(`Failed to close connection: ${await
|
|
781
|
+
if (!r.ok)
|
|
782
|
+
throw new Error(`Failed to close connection: ${await r.text()}`);
|
|
755
783
|
}
|
|
756
784
|
}
|
|
757
|
-
class
|
|
785
|
+
class pe {
|
|
758
786
|
/**
|
|
759
787
|
* Creates a new instance of the Notabene SDK
|
|
760
788
|
*
|
|
@@ -778,15 +806,15 @@ class ue {
|
|
|
778
806
|
* @returns component URL
|
|
779
807
|
* @internal
|
|
780
808
|
*/
|
|
781
|
-
componentUrl(t,
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
const s =
|
|
809
|
+
componentUrl(t, r, n, i) {
|
|
810
|
+
const o = new URL(this.uxUrl);
|
|
811
|
+
o.pathname = t;
|
|
812
|
+
const s = H({
|
|
785
813
|
authToken: this.authToken,
|
|
786
|
-
value:
|
|
787
|
-
configuration:
|
|
814
|
+
value: r,
|
|
815
|
+
configuration: n
|
|
788
816
|
});
|
|
789
|
-
return
|
|
817
|
+
return o.hash = s, this.nodeUrl && o.searchParams.set("nodeUrl", this.nodeUrl), this.theme && o.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && o.searchParams.set("locale", this.locale), i && (i.callback && o.searchParams.set("callback_url", i.callback), i.redirectUri && o.searchParams.set("redirect_uri", i.redirectUri)), o.toString();
|
|
790
818
|
}
|
|
791
819
|
/**
|
|
792
820
|
* Creates a new embedded component
|
|
@@ -798,11 +826,11 @@ class ue {
|
|
|
798
826
|
* @returns A new EmbeddedComponent instance
|
|
799
827
|
* @internal
|
|
800
828
|
*/
|
|
801
|
-
createComponent(t,
|
|
802
|
-
return new
|
|
803
|
-
this.componentUrl(t,
|
|
804
|
-
|
|
805
|
-
|
|
829
|
+
createComponent(t, r, n, i) {
|
|
830
|
+
return new K(
|
|
831
|
+
this.componentUrl(t, r, n, i),
|
|
832
|
+
r,
|
|
833
|
+
n
|
|
806
834
|
);
|
|
807
835
|
}
|
|
808
836
|
/**
|
|
@@ -813,12 +841,12 @@ class ue {
|
|
|
813
841
|
* @param callbacks - Optional callback configuration
|
|
814
842
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
815
843
|
*/
|
|
816
|
-
createWithdrawalAssist(t,
|
|
844
|
+
createWithdrawalAssist(t, r, n) {
|
|
817
845
|
return this.createComponent(
|
|
818
846
|
"withdrawal-assist",
|
|
819
847
|
t,
|
|
820
|
-
|
|
821
|
-
|
|
848
|
+
r,
|
|
849
|
+
n
|
|
822
850
|
);
|
|
823
851
|
}
|
|
824
852
|
/**
|
|
@@ -830,12 +858,12 @@ class ue {
|
|
|
830
858
|
* @returns A new EmbeddedComponent instance for connection
|
|
831
859
|
* @alpha
|
|
832
860
|
*/
|
|
833
|
-
createConnectWallet(t,
|
|
861
|
+
createConnectWallet(t, r, n) {
|
|
834
862
|
return this.createComponent(
|
|
835
863
|
"connect",
|
|
836
864
|
t,
|
|
837
|
-
|
|
838
|
-
|
|
865
|
+
r,
|
|
866
|
+
n
|
|
839
867
|
);
|
|
840
868
|
}
|
|
841
869
|
/**
|
|
@@ -847,12 +875,12 @@ class ue {
|
|
|
847
875
|
* @returns A new EmbeddedComponent instance for deposit requests
|
|
848
876
|
* @public
|
|
849
877
|
*/
|
|
850
|
-
createDepositRequest(t,
|
|
878
|
+
createDepositRequest(t, r, n) {
|
|
851
879
|
return this.createComponent(
|
|
852
880
|
"deposit-request",
|
|
853
881
|
t,
|
|
854
|
-
|
|
855
|
-
|
|
882
|
+
r,
|
|
883
|
+
n
|
|
856
884
|
);
|
|
857
885
|
}
|
|
858
886
|
/**
|
|
@@ -864,37 +892,37 @@ class ue {
|
|
|
864
892
|
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
865
893
|
* @public
|
|
866
894
|
*/
|
|
867
|
-
createDepositAssist(t,
|
|
895
|
+
createDepositAssist(t, r, n) {
|
|
868
896
|
return this.createComponent(
|
|
869
897
|
"deposit-assist",
|
|
870
898
|
t,
|
|
871
|
-
|
|
872
|
-
|
|
899
|
+
r,
|
|
900
|
+
n
|
|
873
901
|
);
|
|
874
902
|
}
|
|
875
903
|
}
|
|
876
904
|
export {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
905
|
+
x as AgentType,
|
|
906
|
+
u as CMType,
|
|
907
|
+
k as CodeVerificationStatus,
|
|
908
|
+
Ee as ConnectionManager,
|
|
909
|
+
K as EmbeddedComponent,
|
|
910
|
+
J as ErrorIdentifierCode,
|
|
911
|
+
S as HMType,
|
|
912
|
+
W as IdentityVerificationMethod,
|
|
913
|
+
B as OAuthProvider,
|
|
914
|
+
p as PersonType,
|
|
915
|
+
j as ProofStatus,
|
|
916
|
+
G as ProofTypes,
|
|
917
|
+
M as Status,
|
|
918
|
+
V as VASPSearchControl,
|
|
919
|
+
F as ValidationSections,
|
|
920
|
+
$ as WarningIdentifierCode,
|
|
921
|
+
me as componentResponseToIVMS101,
|
|
922
|
+
he as componentResponseToTxCreateRequest,
|
|
923
|
+
ue as componentResponseToTxRequests,
|
|
924
|
+
le as componentResponseToV1TxCreateRequest,
|
|
925
|
+
de as decodeFragmentToObject,
|
|
926
|
+
pe as default,
|
|
927
|
+
fe as getRefreshResult
|
|
900
928
|
};
|