@notabene/javascript-sdk 2.12.0 → 2.13.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -4
- package/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +237 -2
- package/dist/cjs/package.json +6 -2
- package/dist/esm/notabene.d.ts +237 -2
- package/dist/esm/notabene.js +447 -133
- package/dist/esm/package.json +6 -2
- package/dist/notabene.d.ts +237 -2
- package/dist/notabene.js +447 -133
- package/docs/README.md +0 -4
- package/docs/_media/TransactionOptions.md +0 -4
- package/docs/types/interfaces/TransactionOptions.md +0 -4
- package/package.json +6 -2
- package/src/ivms/index.ts +5 -0
- package/src/ivms/v2Types.ts +35 -0
- package/src/notabene.ts +14 -0
- package/src/responseTransformer/README.md +164 -0
- package/src/responseTransformer/index.ts +21 -0
- package/src/responseTransformer/mappers.ts +293 -0
- package/src/responseTransformer/transformer.ts +278 -0
- package/src/responseTransformer/types.ts +60 -0
- package/src/responseTransformer/utils.ts +61 -0
- package/src/types.ts +15 -2
- package/src/utils/arbitraries.ts +0 -1
package/dist/notabene.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var R = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var c = (e, t, n) => R(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var S = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(S || {}), I = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(I || {}), _ = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(_ || {}), O = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(O || {}), T = /* @__PURE__ */ ((e) => (e.SMS = "sms", e.EMAIL = "email", e))(T || {}), D = /* @__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))(D || {}), U = /* @__PURE__ */ ((e) => (e.COINBASE = "coinbase", e))(U || {}), x = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(x || {}), 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 || {}), M = /* @__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))(M || {}), V = /* @__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))(V || {}), y = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(y || {}), B = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(B || {}), W = /* @__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))(W || {});
|
|
5
|
+
class k {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
c(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
|
+
c(this, "port");
|
|
9
9
|
this.handleMessage = this.handleMessage.bind(this);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -56,8 +56,8 @@ class O {
|
|
|
56
56
|
handleMessage(t) {
|
|
57
57
|
const n = t.data;
|
|
58
58
|
if (typeof n == "object" && n !== null && "type" in n) {
|
|
59
|
-
const r = n.type,
|
|
60
|
-
|
|
59
|
+
const r = n.type, i = this.listeners.get(r);
|
|
60
|
+
i && i.forEach((o) => o(n));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -68,24 +68,24 @@ class O {
|
|
|
68
68
|
this.port && this.port.postMessage(t);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class J {
|
|
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
77
|
constructor(t, n, r) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this._url = t, this._value = n, this._options = r, this.eventManager = new
|
|
86
|
-
|
|
87
|
-
}), this.on(l.RESIZE, (
|
|
88
|
-
|
|
78
|
+
c(this, "_url");
|
|
79
|
+
c(this, "_value");
|
|
80
|
+
c(this, "_options");
|
|
81
|
+
c(this, "_errors", []);
|
|
82
|
+
c(this, "iframe");
|
|
83
|
+
c(this, "eventManager");
|
|
84
|
+
c(this, "modal");
|
|
85
|
+
this._url = t, this._value = n, this._options = r, this.eventManager = new k(), 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
|
/**
|
|
@@ -129,11 +129,11 @@ class x {
|
|
|
129
129
|
* @param parent - The parent element to embed the component into
|
|
130
130
|
*/
|
|
131
131
|
embed(t, n = !1) {
|
|
132
|
-
var r,
|
|
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", (
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
}), (
|
|
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", t.appendChild(this.iframe), window.addEventListener("message", (o) => {
|
|
134
|
+
var s, a;
|
|
135
|
+
o.source === ((s = this.iframe) == null ? void 0 : s.contentWindow) && ((a = this.eventManager) == null || a.setPort(o.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();
|
|
@@ -166,7 +166,7 @@ class x {
|
|
|
166
166
|
* @param value - The new transaction value
|
|
167
167
|
*/
|
|
168
168
|
update(t, n) {
|
|
169
|
-
this._value = t, n && (this._options = n), this.send({ type:
|
|
169
|
+
this._value = t, n && (this._options = n), this.send({ type: y.UPDATE, value: t, options: this._options });
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Waits for the component to complete and returns the transaction response
|
|
@@ -174,16 +174,16 @@ class x {
|
|
|
174
174
|
*/
|
|
175
175
|
completion() {
|
|
176
176
|
return new Promise((t, n) => {
|
|
177
|
-
let r,
|
|
178
|
-
function
|
|
179
|
-
r && r(),
|
|
177
|
+
let r, i, o;
|
|
178
|
+
function s() {
|
|
179
|
+
r && r(), i && i(), o && o();
|
|
180
180
|
}
|
|
181
|
-
r = this.on(l.COMPLETE, (
|
|
182
|
-
t(
|
|
183
|
-
}),
|
|
184
|
-
n(new Error("User cancelled")),
|
|
185
|
-
}),
|
|
186
|
-
n(new Error(
|
|
181
|
+
r = this.on(l.COMPLETE, (a) => {
|
|
182
|
+
t(a.response), s();
|
|
183
|
+
}), i = this.on(l.CANCEL, () => {
|
|
184
|
+
n(new Error("User cancelled")), s();
|
|
185
|
+
}), o = this.on("error", (a) => {
|
|
186
|
+
n(new Error(a.message)), s();
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
}
|
|
@@ -223,9 +223,9 @@ class x {
|
|
|
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
230
|
const n = this.on(l.CANCEL, () => {
|
|
231
231
|
t == null || t.close();
|
|
@@ -237,73 +237,382 @@ class x {
|
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function j(e) {
|
|
241
241
|
return Object.entries(e).map(([t, n]) => {
|
|
242
242
|
if (n == null) return;
|
|
243
|
-
const r = encodeURIComponent(t),
|
|
243
|
+
const r = encodeURIComponent(t), i = encodeURIComponent(
|
|
244
244
|
typeof n == "object" ? JSON.stringify(n) : String(n)
|
|
245
245
|
// Use String() to handle all primitive types
|
|
246
246
|
);
|
|
247
|
-
return `${r}=${
|
|
247
|
+
return `${r}=${i}`;
|
|
248
248
|
}).filter((t) => t !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function ie(e) {
|
|
251
251
|
const t = e.slice(1);
|
|
252
252
|
return t ? t.split("&").filter(Boolean).reduce(
|
|
253
|
-
(r,
|
|
254
|
-
const [
|
|
255
|
-
return
|
|
253
|
+
(r, i) => {
|
|
254
|
+
const [o, s] = i.split("=");
|
|
255
|
+
return o && (r[decodeURIComponent(o)] = s ? decodeURIComponent(s) : ""), r;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
new TextEncoder();
|
|
261
|
+
const f = new TextDecoder();
|
|
262
|
+
function F(e) {
|
|
263
|
+
if (Uint8Array.fromBase64)
|
|
264
|
+
return Uint8Array.fromBase64(e);
|
|
265
|
+
const t = atob(e), n = new Uint8Array(t.length);
|
|
266
|
+
for (let r = 0; r < t.length; r++)
|
|
267
|
+
n[r] = t.charCodeAt(r);
|
|
268
|
+
return n;
|
|
269
|
+
}
|
|
270
|
+
function G(e) {
|
|
271
|
+
if (Uint8Array.fromBase64)
|
|
272
|
+
return Uint8Array.fromBase64(typeof e == "string" ? e : f.decode(e), {
|
|
273
|
+
alphabet: "base64url"
|
|
274
|
+
});
|
|
275
|
+
let t = e;
|
|
276
|
+
t instanceof Uint8Array && (t = f.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
277
|
+
try {
|
|
278
|
+
return F(t);
|
|
279
|
+
} catch {
|
|
280
|
+
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
class w extends Error {
|
|
284
|
+
constructor(n, r) {
|
|
285
|
+
var i;
|
|
286
|
+
super(n, r);
|
|
287
|
+
c(this, "code", "ERR_JOSE_GENERIC");
|
|
288
|
+
this.name = this.constructor.name, (i = Error.captureStackTrace) == null || i.call(Error, this, this.constructor);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
c(w, "code", "ERR_JOSE_GENERIC");
|
|
292
|
+
class u extends w {
|
|
293
|
+
constructor() {
|
|
294
|
+
super(...arguments);
|
|
295
|
+
c(this, "code", "ERR_JWT_INVALID");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
c(u, "code", "ERR_JWT_INVALID");
|
|
299
|
+
function $(e) {
|
|
300
|
+
return typeof e == "object" && e !== null;
|
|
301
|
+
}
|
|
302
|
+
const q = (e) => {
|
|
303
|
+
if (!$(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
304
|
+
return !1;
|
|
305
|
+
if (Object.getPrototypeOf(e) === null)
|
|
306
|
+
return !0;
|
|
307
|
+
let t = e;
|
|
308
|
+
for (; Object.getPrototypeOf(t) !== null; )
|
|
309
|
+
t = Object.getPrototypeOf(t);
|
|
310
|
+
return Object.getPrototypeOf(e) === t;
|
|
311
|
+
};
|
|
312
|
+
function K(e) {
|
|
313
|
+
if (typeof e != "string")
|
|
314
|
+
throw new u("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
315
|
+
const { 1: t, length: n } = e.split(".");
|
|
316
|
+
if (n === 5)
|
|
317
|
+
throw new u("Only JWTs using Compact JWS serialization can be decoded");
|
|
318
|
+
if (n !== 3)
|
|
319
|
+
throw new u("Invalid JWT");
|
|
320
|
+
if (!t)
|
|
321
|
+
throw new u("JWTs must contain a payload");
|
|
322
|
+
let r;
|
|
323
|
+
try {
|
|
324
|
+
r = G(t);
|
|
325
|
+
} catch {
|
|
326
|
+
throw new u("Failed to base64url decode the payload");
|
|
327
|
+
}
|
|
328
|
+
let i;
|
|
329
|
+
try {
|
|
330
|
+
i = JSON.parse(f.decode(r));
|
|
331
|
+
} catch {
|
|
332
|
+
throw new u("Failed to parse the decoded payload as JSON");
|
|
333
|
+
}
|
|
334
|
+
if (!q(i))
|
|
335
|
+
throw new u("Invalid JWT Claims Set");
|
|
336
|
+
return i;
|
|
337
|
+
}
|
|
338
|
+
function E(e, t) {
|
|
339
|
+
if (t != null && t.email)
|
|
340
|
+
return `did:email:${t.email}`;
|
|
341
|
+
if (t != null && t.name)
|
|
342
|
+
return `did:name:${encodeURIComponent(t.name.replace(/\s+/g, "-"))}`;
|
|
343
|
+
throw new Error(
|
|
344
|
+
`Unable to generate ${e} ID: missing required ${e} information`
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
function H(e) {
|
|
348
|
+
const { nameIdentifier: t, ...n } = e;
|
|
349
|
+
return {
|
|
350
|
+
...n,
|
|
351
|
+
nameIdentifier: t == null ? void 0 : t.map(({ nameIdentifierType: r, ...i }) => ({
|
|
352
|
+
...i,
|
|
353
|
+
naturalPersonNameIdentifierType: r
|
|
354
|
+
}))
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function X(e, t) {
|
|
358
|
+
return {
|
|
359
|
+
naturalPerson: e.naturalPerson ? {
|
|
360
|
+
...e.naturalPerson,
|
|
361
|
+
name: H(e.naturalPerson.name)
|
|
362
|
+
} : void 0,
|
|
363
|
+
legalPerson: e.legalPerson,
|
|
364
|
+
accountNumber: [t]
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const p = [
|
|
368
|
+
{
|
|
369
|
+
addressType: "GEOG",
|
|
370
|
+
addressLine: ["1234 Main Street"],
|
|
371
|
+
townName: "Unknown",
|
|
372
|
+
country: "US"
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
function z(e) {
|
|
376
|
+
const t = e.trim();
|
|
377
|
+
if (!t)
|
|
378
|
+
return { primaryIdentifier: "", secondaryIdentifier: "" };
|
|
379
|
+
const n = t.split(/\s+/), r = n[n.length - 1], i = n.slice(0, -1), o = i.length > 0 ? i.join(" ") : r;
|
|
380
|
+
return { primaryIdentifier: r, secondaryIdentifier: o };
|
|
381
|
+
}
|
|
382
|
+
function Y(e, t, n = ["1234567890"]) {
|
|
383
|
+
const r = t == null ? void 0 : t.map((i) => {
|
|
384
|
+
const o = { ...i };
|
|
385
|
+
return o.naturalPerson && (o.naturalPerson = {
|
|
386
|
+
...o.naturalPerson,
|
|
387
|
+
geographicAddress: p
|
|
388
|
+
}), o.legalPerson && (o.legalPerson = {
|
|
389
|
+
...o.legalPerson,
|
|
390
|
+
geographicAddress: p
|
|
391
|
+
}), o;
|
|
392
|
+
});
|
|
393
|
+
return e === "originator" ? { originatorPersons: r, accountNumber: n } : { beneficiaryPersons: r, accountNumber: n };
|
|
394
|
+
}
|
|
395
|
+
function Q(e, t = "John Doe") {
|
|
396
|
+
const { primaryIdentifier: n, secondaryIdentifier: r } = z(t), i = {
|
|
397
|
+
naturalPerson: {
|
|
398
|
+
name: [
|
|
399
|
+
{
|
|
400
|
+
nameIdentifier: [
|
|
401
|
+
{
|
|
402
|
+
primaryIdentifier: n,
|
|
403
|
+
...r ? { secondaryIdentifier: r } : {},
|
|
404
|
+
nameIdentifierType: "LEGL"
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
geographicAddress: p
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
return e === "originator" ? { originatorPersons: [i], accountNumber: ["1234567890"] } : { beneficiaryPersons: [i], accountNumber: ["1234567890"] };
|
|
413
|
+
}
|
|
414
|
+
const Z = (e) => ({
|
|
415
|
+
...e,
|
|
416
|
+
// @ts-expect-error Preserving the original logic
|
|
417
|
+
name: e.name ? [e.name] : void 0
|
|
418
|
+
}), ee = (e) => ({
|
|
419
|
+
...e,
|
|
420
|
+
naturalPerson: e.naturalPerson ? Z(e.naturalPerson) : void 0
|
|
421
|
+
}), te = ({ beneficiary: e, originator: t }, n, r, i, o) => {
|
|
422
|
+
var s;
|
|
423
|
+
{
|
|
424
|
+
const a = e && {
|
|
425
|
+
...e,
|
|
426
|
+
...i && { accountNumber: [i] },
|
|
427
|
+
beneficiaryPersons: (s = e.beneficiaryPersons) == null ? void 0 : s.map(ee)
|
|
428
|
+
};
|
|
429
|
+
if (r && (a != null && a.beneficiaryPersons)) {
|
|
430
|
+
const d = Y(
|
|
431
|
+
"originator",
|
|
432
|
+
a == null ? void 0 : a.beneficiaryPersons
|
|
433
|
+
);
|
|
434
|
+
return {
|
|
435
|
+
beneficiary: {
|
|
436
|
+
accountNumber: d.accountNumber,
|
|
437
|
+
beneficiaryPersons: d.originatorPersons
|
|
438
|
+
},
|
|
439
|
+
originator: d
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
beneficiary: a,
|
|
444
|
+
originator: Q("originator", n)
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
function ne(e, t, n) {
|
|
449
|
+
var o, s;
|
|
450
|
+
const { beneficiary: r, originator: i } = te(
|
|
451
|
+
n,
|
|
452
|
+
(o = e.customer) == null ? void 0 : o.name,
|
|
453
|
+
t.originatorEqualsBeneficiary,
|
|
454
|
+
e.destination
|
|
455
|
+
);
|
|
456
|
+
return {
|
|
457
|
+
transactionAsset: t.transactionAsset,
|
|
458
|
+
transactionAmount: t.transactionAmount,
|
|
459
|
+
beneficiaryDid: (s = e.counterparty) == null ? void 0 : s.did,
|
|
460
|
+
originatorVASPdid: t.originatorVASPdid,
|
|
461
|
+
...t.beneficiaryVASPdid && !t.beneficiaryProof ? { beneficiaryVASPdid: t.beneficiaryVASPdid } : {},
|
|
462
|
+
transactionBlockchainInfo: {
|
|
463
|
+
...(i == null ? void 0 : i.accountNumber) && { origin: i.accountNumber[0] },
|
|
464
|
+
...e.destination && { destination: e.destination }
|
|
465
|
+
},
|
|
466
|
+
...t.beneficiaryProof && {
|
|
467
|
+
beneficiaryProof: t.beneficiaryProof
|
|
468
|
+
},
|
|
469
|
+
...r && { beneficiary: r },
|
|
470
|
+
...i && { originator: i },
|
|
471
|
+
...t.originatorEqualsBeneficiary && {
|
|
472
|
+
originatorEqualsBeneficiary: t.originatorEqualsBeneficiary
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function N(e, t, n = {}) {
|
|
477
|
+
var a, d;
|
|
478
|
+
const r = (n == null ? void 0 : n.originatorId) || E("originator", e.customer), i = (n == null ? void 0 : n.beneficiaryId) || E("beneficiary", e.counterparty), o = (n == null ? void 0 : n.referenceId) || Math.random().toString(36).substring(2, 15), s = [];
|
|
479
|
+
return t.originatorVASPdid && s.push({
|
|
480
|
+
"@id": t.originatorVASPdid,
|
|
481
|
+
for: r,
|
|
482
|
+
role: "VASP"
|
|
483
|
+
}), t.beneficiaryVASPdid && s.push({
|
|
484
|
+
"@id": t.beneficiaryVASPdid,
|
|
485
|
+
for: i,
|
|
486
|
+
role: "VASP"
|
|
487
|
+
}), e.destination && ((a = e == null ? void 0 : e.account) != null && a.did) && s.push({
|
|
488
|
+
"@id": e.account.did,
|
|
489
|
+
for: t.beneficiaryVASPdid || i,
|
|
490
|
+
role: "SettlementAddress"
|
|
491
|
+
}), {
|
|
492
|
+
originator: { "@id": r },
|
|
493
|
+
beneficiary: { "@id": i },
|
|
494
|
+
asset: e.asset,
|
|
495
|
+
amount: ((d = e.amountDecimal) == null ? void 0 : d.toString()) || t.transactionAmount,
|
|
496
|
+
agents: s,
|
|
497
|
+
ref: o
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function L(e, t, n = {}) {
|
|
501
|
+
var o, s;
|
|
502
|
+
const r = n.beneficiaryId || E("beneficiary", e.counterparty), i = ((s = (o = t.beneficiary) == null ? void 0 : o.beneficiaryPersons) == null ? void 0 : s.map(
|
|
503
|
+
(a) => X(a, r)
|
|
504
|
+
)) || [];
|
|
505
|
+
return {
|
|
506
|
+
ivms101: {
|
|
507
|
+
originator: n.originator,
|
|
508
|
+
beneficiary: {
|
|
509
|
+
beneficiaryPerson: i
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function g(e, t, n) {
|
|
515
|
+
var i;
|
|
516
|
+
const r = { ...e };
|
|
517
|
+
if (!r.originatorId)
|
|
518
|
+
try {
|
|
519
|
+
const o = K(t);
|
|
520
|
+
o != null && o.sub && (r.originatorId = o.sub);
|
|
521
|
+
} catch {
|
|
522
|
+
}
|
|
523
|
+
return r.beneficiaryId || (((i = n.counterparty) == null ? void 0 : i.type) === I.SELF ? r.beneficiaryId = r.originatorId : n.destination && (r.beneficiaryId = `did:key:${n.destination}`)), r;
|
|
524
|
+
}
|
|
525
|
+
function oe(e) {
|
|
526
|
+
var s;
|
|
527
|
+
if (!e.txCreate || !e.ivms101)
|
|
528
|
+
throw new Error(
|
|
529
|
+
"Invalid response: missing required txCreate or ivms101 data"
|
|
530
|
+
);
|
|
531
|
+
const { value: t, ivms101: n, proof: r, txCreate: i } = e, o = {
|
|
532
|
+
destination: (t == null ? void 0 : t.destination) || "",
|
|
533
|
+
counterparty: (t == null ? void 0 : t.counterparty) || {},
|
|
534
|
+
agent: t == null ? void 0 : t.agent,
|
|
535
|
+
account: t == null ? void 0 : t.account,
|
|
536
|
+
proof: r,
|
|
537
|
+
asset: (t == null ? void 0 : t.asset) || (typeof i.transactionAsset == "string" ? i.transactionAsset : (s = i.transactionAsset) == null ? void 0 : s.caip19) || "",
|
|
538
|
+
amountDecimal: (t == null ? void 0 : t.amountDecimal) || (i.transactionAmount ? parseFloat(i.transactionAmount) : 0),
|
|
539
|
+
customer: t == null ? void 0 : t.customer
|
|
540
|
+
};
|
|
541
|
+
return ne(o, i, n);
|
|
542
|
+
}
|
|
543
|
+
function se(e, t, n = {}) {
|
|
544
|
+
if (!e.txCreate || !e.ivms101)
|
|
545
|
+
throw new Error(
|
|
546
|
+
"Invalid response: missing required txCreate or ivms101 data"
|
|
547
|
+
);
|
|
548
|
+
const { value: r, txCreate: i, ivms101: o, proof: s } = e, a = g(n, t, r);
|
|
549
|
+
return {
|
|
550
|
+
createTx: N(r, i, a),
|
|
551
|
+
ivms101: L(r, o, a),
|
|
552
|
+
...s && { confirmRelationship: { proof: s } }
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function ae(e, t, n = {}) {
|
|
556
|
+
if (!e.txCreate || !e.ivms101)
|
|
557
|
+
throw new Error(
|
|
558
|
+
"Invalid response: missing required txCreate or ivms101 data"
|
|
559
|
+
);
|
|
560
|
+
const { value: r, txCreate: i } = e, o = g(n, t, r);
|
|
561
|
+
return N(r, i, o);
|
|
562
|
+
}
|
|
563
|
+
function ce(e, t, n = {}) {
|
|
564
|
+
if (!e.ivms101)
|
|
565
|
+
throw new Error("Invalid response: missing required ivms101 data");
|
|
566
|
+
const { value: r, ivms101: i } = e, o = g(n, t, r);
|
|
567
|
+
return L(r, i, o);
|
|
568
|
+
}
|
|
569
|
+
async function b(e, t) {
|
|
570
|
+
const n = JSON.stringify(e), r = new TextEncoder(), i = t ? A(t) : crypto.getRandomValues(new Uint8Array(32)), o = await crypto.subtle.importKey(
|
|
262
571
|
"raw",
|
|
263
|
-
|
|
572
|
+
i,
|
|
264
573
|
{ name: "AES-GCM" },
|
|
265
574
|
!1,
|
|
266
575
|
["encrypt"]
|
|
267
|
-
),
|
|
268
|
-
{ name: "AES-GCM", iv:
|
|
269
|
-
|
|
576
|
+
), s = crypto.getRandomValues(new Uint8Array(12)), a = await crypto.subtle.encrypt(
|
|
577
|
+
{ name: "AES-GCM", iv: s },
|
|
578
|
+
o,
|
|
270
579
|
r.encode(n)
|
|
271
580
|
);
|
|
272
581
|
return {
|
|
273
|
-
ciphertext: `${
|
|
274
|
-
key:
|
|
582
|
+
ciphertext: `${m(s)}-${m(a)}`,
|
|
583
|
+
key: m(i)
|
|
275
584
|
};
|
|
276
585
|
}
|
|
277
|
-
async function
|
|
278
|
-
const [n, r] = e.split("-"),
|
|
279
|
-
atob(t).split("").map((
|
|
280
|
-
),
|
|
586
|
+
async function P({ ciphertext: e, key: t }) {
|
|
587
|
+
const [n, r] = e.split("-"), i = new Uint8Array(
|
|
588
|
+
atob(t).split("").map((v) => v.charCodeAt(0))
|
|
589
|
+
), o = A(n), s = A(r), a = await crypto.subtle.importKey(
|
|
281
590
|
"raw",
|
|
282
|
-
|
|
591
|
+
i,
|
|
283
592
|
{ name: "AES-GCM" },
|
|
284
593
|
!1,
|
|
285
594
|
["decrypt"]
|
|
286
|
-
),
|
|
287
|
-
{ name: "AES-GCM", iv: new Uint8Array(
|
|
288
|
-
|
|
289
|
-
|
|
595
|
+
), d = new TextDecoder(), h = await crypto.subtle.decrypt(
|
|
596
|
+
{ name: "AES-GCM", iv: new Uint8Array(o) },
|
|
597
|
+
a,
|
|
598
|
+
s
|
|
290
599
|
);
|
|
291
|
-
return JSON.parse(
|
|
600
|
+
return JSON.parse(d.decode(h));
|
|
292
601
|
}
|
|
293
|
-
function
|
|
602
|
+
function m(e) {
|
|
294
603
|
const t = new Uint8Array(e);
|
|
295
604
|
let n = "";
|
|
296
605
|
for (let r = 0; r < t.length; r++)
|
|
297
606
|
n += String.fromCharCode(t[r]);
|
|
298
607
|
return btoa(n);
|
|
299
608
|
}
|
|
300
|
-
function
|
|
609
|
+
function A(e) {
|
|
301
610
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
302
611
|
for (let r = 0; r < t.length; r++)
|
|
303
612
|
n[r] = t.charCodeAt(r);
|
|
304
613
|
return n;
|
|
305
614
|
}
|
|
306
|
-
async function
|
|
615
|
+
async function de(e) {
|
|
307
616
|
const t = await fetch(e.url, {
|
|
308
617
|
method: "GET"
|
|
309
618
|
});
|
|
@@ -319,21 +628,21 @@ async function P(e) {
|
|
|
319
628
|
};
|
|
320
629
|
if (n.status === "closed")
|
|
321
630
|
return r;
|
|
322
|
-
const
|
|
323
|
-
ciphertext:
|
|
631
|
+
const i = n.sealed[n.sealed.length - 1], o = await P({
|
|
632
|
+
ciphertext: i,
|
|
324
633
|
key: e.key
|
|
325
634
|
});
|
|
326
635
|
return n.status === "completed" ? {
|
|
327
636
|
...r,
|
|
328
|
-
result:
|
|
637
|
+
result: o.result
|
|
329
638
|
} : {
|
|
330
639
|
...r,
|
|
331
|
-
tx:
|
|
640
|
+
tx: o.tx
|
|
332
641
|
};
|
|
333
642
|
}
|
|
334
|
-
class
|
|
643
|
+
class le {
|
|
335
644
|
constructor(t) {
|
|
336
|
-
|
|
645
|
+
c(this, "endpoint");
|
|
337
646
|
this.endpoint = t;
|
|
338
647
|
}
|
|
339
648
|
/**
|
|
@@ -344,23 +653,23 @@ class T {
|
|
|
344
653
|
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
345
654
|
*/
|
|
346
655
|
async create(t, n) {
|
|
347
|
-
const r = await
|
|
656
|
+
const r = await b(t), i = {
|
|
348
657
|
metadata: n,
|
|
349
658
|
sealed: r.ciphertext
|
|
350
|
-
},
|
|
659
|
+
}, o = await fetch(this.endpoint, {
|
|
351
660
|
method: "POST",
|
|
352
661
|
headers: {
|
|
353
662
|
"Content-Type": "application/json"
|
|
354
663
|
},
|
|
355
|
-
body: JSON.stringify(
|
|
664
|
+
body: JSON.stringify(i)
|
|
356
665
|
});
|
|
357
|
-
if (!
|
|
358
|
-
throw new Error(`Failed to create connection: ${await
|
|
359
|
-
const
|
|
666
|
+
if (!o.ok)
|
|
667
|
+
throw new Error(`Failed to create connection: ${await o.text()}`);
|
|
668
|
+
const s = await o.json();
|
|
360
669
|
return {
|
|
361
|
-
id:
|
|
362
|
-
version:
|
|
363
|
-
status:
|
|
670
|
+
id: s.id,
|
|
671
|
+
version: s.version,
|
|
672
|
+
status: s.status,
|
|
364
673
|
metadata: n,
|
|
365
674
|
data: t,
|
|
366
675
|
key: r.key
|
|
@@ -376,28 +685,28 @@ class T {
|
|
|
376
685
|
* @param key Current encryption key
|
|
377
686
|
* @returns Promise resolving to updated connection details including new encryption key
|
|
378
687
|
*/
|
|
379
|
-
async update(t, n, r,
|
|
380
|
-
const
|
|
381
|
-
sealed:
|
|
688
|
+
async update(t, n, r, i, o) {
|
|
689
|
+
const s = await b(n, o), a = {
|
|
690
|
+
sealed: s.ciphertext,
|
|
382
691
|
version: r,
|
|
383
|
-
status:
|
|
384
|
-
},
|
|
692
|
+
status: i
|
|
693
|
+
}, d = await fetch(`${this.endpoint}/${t}`, {
|
|
385
694
|
method: "PATCH",
|
|
386
695
|
headers: {
|
|
387
696
|
"Content-Type": "application/json"
|
|
388
697
|
},
|
|
389
|
-
body: JSON.stringify(
|
|
698
|
+
body: JSON.stringify(a)
|
|
390
699
|
});
|
|
391
|
-
if (!
|
|
392
|
-
throw new Error(`Failed to update connection: ${await
|
|
393
|
-
const
|
|
700
|
+
if (!d.ok)
|
|
701
|
+
throw new Error(`Failed to update connection: ${await d.text()}`);
|
|
702
|
+
const h = await d.json();
|
|
394
703
|
return {
|
|
395
|
-
id:
|
|
396
|
-
metadata:
|
|
397
|
-
version:
|
|
398
|
-
status:
|
|
704
|
+
id: h.id,
|
|
705
|
+
metadata: h.metadata,
|
|
706
|
+
version: h.version,
|
|
707
|
+
status: h.status,
|
|
399
708
|
data: n,
|
|
400
|
-
key:
|
|
709
|
+
key: s.key
|
|
401
710
|
};
|
|
402
711
|
}
|
|
403
712
|
/**
|
|
@@ -413,16 +722,16 @@ class T {
|
|
|
413
722
|
});
|
|
414
723
|
if (!r.ok)
|
|
415
724
|
throw new Error(`Failed to get connection: ${await r.text()}`);
|
|
416
|
-
const
|
|
417
|
-
ciphertext:
|
|
725
|
+
const i = await r.json(), o = i.sealed[i.sealed.length - 1], s = await P({
|
|
726
|
+
ciphertext: o,
|
|
418
727
|
key: n
|
|
419
728
|
});
|
|
420
729
|
return {
|
|
421
|
-
id:
|
|
422
|
-
status:
|
|
423
|
-
version:
|
|
424
|
-
metadata:
|
|
425
|
-
data:
|
|
730
|
+
id: i.id,
|
|
731
|
+
status: i.status,
|
|
732
|
+
version: i.version,
|
|
733
|
+
metadata: i.metadata,
|
|
734
|
+
data: s,
|
|
426
735
|
key: n
|
|
427
736
|
};
|
|
428
737
|
}
|
|
@@ -439,18 +748,18 @@ class T {
|
|
|
439
748
|
throw new Error(`Failed to close connection: ${await n.text()}`);
|
|
440
749
|
}
|
|
441
750
|
}
|
|
442
|
-
class
|
|
751
|
+
class ue {
|
|
443
752
|
/**
|
|
444
753
|
* Creates a new instance of the Notabene SDK
|
|
445
754
|
*
|
|
446
755
|
* @param config - Configuration options for the Notabene SDK
|
|
447
756
|
*/
|
|
448
757
|
constructor(t) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
758
|
+
c(this, "nodeUrl");
|
|
759
|
+
c(this, "authToken");
|
|
760
|
+
c(this, "uxUrl");
|
|
761
|
+
c(this, "theme");
|
|
762
|
+
c(this, "locale");
|
|
454
763
|
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
764
|
}
|
|
456
765
|
/**
|
|
@@ -463,15 +772,15 @@ class B {
|
|
|
463
772
|
* @returns component URL
|
|
464
773
|
* @internal
|
|
465
774
|
*/
|
|
466
|
-
componentUrl(t, n, r,
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
const
|
|
775
|
+
componentUrl(t, n, r, i) {
|
|
776
|
+
const o = new URL(this.uxUrl);
|
|
777
|
+
o.pathname = t;
|
|
778
|
+
const s = j({
|
|
470
779
|
authToken: this.authToken,
|
|
471
780
|
value: n,
|
|
472
781
|
configuration: r
|
|
473
782
|
});
|
|
474
|
-
return
|
|
783
|
+
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();
|
|
475
784
|
}
|
|
476
785
|
/**
|
|
477
786
|
* Creates a new embedded component
|
|
@@ -483,9 +792,9 @@ class B {
|
|
|
483
792
|
* @returns A new EmbeddedComponent instance
|
|
484
793
|
* @internal
|
|
485
794
|
*/
|
|
486
|
-
createComponent(t, n, r,
|
|
487
|
-
return new
|
|
488
|
-
this.componentUrl(t, n, r,
|
|
795
|
+
createComponent(t, n, r, i) {
|
|
796
|
+
return new J(
|
|
797
|
+
this.componentUrl(t, n, r, i),
|
|
489
798
|
n,
|
|
490
799
|
r
|
|
491
800
|
);
|
|
@@ -559,22 +868,27 @@ class B {
|
|
|
559
868
|
}
|
|
560
869
|
}
|
|
561
870
|
export {
|
|
562
|
-
|
|
871
|
+
S as AgentType,
|
|
563
872
|
l as CMType,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
873
|
+
D as CodeVerificationStatus,
|
|
874
|
+
le as ConnectionManager,
|
|
875
|
+
J as EmbeddedComponent,
|
|
876
|
+
M as ErrorIdentifierCode,
|
|
877
|
+
y as HMType,
|
|
878
|
+
T as IdentityVerificationMethod,
|
|
879
|
+
U as OAuthProvider,
|
|
571
880
|
I as PersonType,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
881
|
+
B as ProofStatus,
|
|
882
|
+
W as ProofTypes,
|
|
883
|
+
_ as Status,
|
|
884
|
+
O as VASPSearchControl,
|
|
885
|
+
x as ValidationSections,
|
|
886
|
+
V as WarningIdentifierCode,
|
|
887
|
+
ce as componentResponseToIVMS101,
|
|
888
|
+
ae as componentResponseToTxCreateRequest,
|
|
889
|
+
se as componentResponseToTxRequests,
|
|
890
|
+
oe as componentResponseToV1TxCreateRequest,
|
|
891
|
+
ie as decodeFragmentToObject,
|
|
892
|
+
ue as default,
|
|
893
|
+
de as getRefreshResult
|
|
580
894
|
};
|