@notabene/javascript-sdk 2.14.0-next.3 → 2.14.0-next.4
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/package.json +1 -1
- package/dist/esm/notabene.js +128 -122
- package/dist/esm/package.json +1 -1
- package/dist/notabene.js +128 -122
- package/package.json +1 -1
- package/src/responseTransformer/mappers.ts +13 -5
package/dist/notabene.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
2
|
var R = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
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 || {}),
|
|
4
|
+
var S = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(S || {}), g = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(g || {}), _ = /* @__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
5
|
class k {
|
|
6
6
|
constructor() {
|
|
7
7
|
c(this, "listeners", /* @__PURE__ */ new Map());
|
|
@@ -56,8 +56,8 @@ class k {
|
|
|
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, o = this.listeners.get(r);
|
|
60
|
+
o && o.forEach((i) => i(n));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -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 = n, this._options = r, this.eventManager = new k(), this.on(l.INVALID, (
|
|
86
|
-
|
|
87
|
-
}), this.on(l.RESIZE, (
|
|
88
|
-
|
|
85
|
+
this._url = t, this._value = n, this._options = r, this.eventManager = new k(), this.on(l.INVALID, (o) => {
|
|
86
|
+
o.type === l.INVALID && (this._errors = o.errors, this._value = o.value);
|
|
87
|
+
}), this.on(l.RESIZE, (o) => {
|
|
88
|
+
o.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${o.height}px`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -129,11 +129,11 @@ class J {
|
|
|
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", (
|
|
132
|
+
var r, o;
|
|
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
134
|
var s, a;
|
|
135
|
-
|
|
136
|
-
}), (
|
|
135
|
+
i.source === ((s = this.iframe) == null ? void 0 : s.contentWindow) && ((a = this.eventManager) == null || a.setPort(i.ports[0]));
|
|
136
|
+
}), (o = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || o.focus();
|
|
137
137
|
}
|
|
138
138
|
removeEmbed() {
|
|
139
139
|
this.iframe && this.iframe.remove();
|
|
@@ -174,15 +174,15 @@ class J {
|
|
|
174
174
|
*/
|
|
175
175
|
completion() {
|
|
176
176
|
return new Promise((t, n) => {
|
|
177
|
-
let r,
|
|
177
|
+
let r, o, i;
|
|
178
178
|
function s() {
|
|
179
|
-
r && r(),
|
|
179
|
+
r && r(), o && o(), i && i();
|
|
180
180
|
}
|
|
181
181
|
r = this.on(l.COMPLETE, (a) => {
|
|
182
182
|
t(a.response), s();
|
|
183
|
-
}),
|
|
183
|
+
}), o = this.on(l.CANCEL, () => {
|
|
184
184
|
n(new Error("User cancelled")), s();
|
|
185
|
-
}),
|
|
185
|
+
}), i = this.on("error", (a) => {
|
|
186
186
|
n(new Error(a.message)), s();
|
|
187
187
|
});
|
|
188
188
|
});
|
|
@@ -223,9 +223,9 @@ 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", (o) => {
|
|
227
|
+
var i;
|
|
228
|
+
o.source === t && (console.log("received message from popup", o.data), (i = this.eventManager) == null || i.setPort(o.ports[0]));
|
|
229
229
|
});
|
|
230
230
|
const n = this.on(l.CANCEL, () => {
|
|
231
231
|
t == null || t.close();
|
|
@@ -237,29 +237,29 @@ class J {
|
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function F(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), o = 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}=${o}`;
|
|
248
248
|
}).filter((t) => t !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function oe(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, o) => {
|
|
254
|
+
const [i, s] = o.split("=");
|
|
255
|
+
return i && (r[decodeURIComponent(i)] = s ? decodeURIComponent(s) : ""), r;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
260
|
new TextEncoder();
|
|
261
261
|
const f = new TextDecoder();
|
|
262
|
-
function
|
|
262
|
+
function j(e) {
|
|
263
263
|
if (Uint8Array.fromBase64)
|
|
264
264
|
return Uint8Array.fromBase64(e);
|
|
265
265
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
@@ -275,21 +275,21 @@ function G(e) {
|
|
|
275
275
|
let t = e;
|
|
276
276
|
t instanceof Uint8Array && (t = f.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
277
277
|
try {
|
|
278
|
-
return
|
|
278
|
+
return j(t);
|
|
279
279
|
} catch {
|
|
280
280
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
class
|
|
283
|
+
class N extends Error {
|
|
284
284
|
constructor(n, r) {
|
|
285
|
-
var
|
|
285
|
+
var o;
|
|
286
286
|
super(n, r);
|
|
287
287
|
c(this, "code", "ERR_JOSE_GENERIC");
|
|
288
|
-
this.name = this.constructor.name, (
|
|
288
|
+
this.name = this.constructor.name, (o = Error.captureStackTrace) == null || o.call(Error, this, this.constructor);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
c(
|
|
292
|
-
class u extends
|
|
291
|
+
c(N, "code", "ERR_JOSE_GENERIC");
|
|
292
|
+
class u extends N {
|
|
293
293
|
constructor() {
|
|
294
294
|
super(...arguments);
|
|
295
295
|
c(this, "code", "ERR_JWT_INVALID");
|
|
@@ -325,15 +325,15 @@ function K(e) {
|
|
|
325
325
|
} catch {
|
|
326
326
|
throw new u("Failed to base64url decode the payload");
|
|
327
327
|
}
|
|
328
|
-
let
|
|
328
|
+
let o;
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
o = JSON.parse(f.decode(r));
|
|
331
331
|
} catch {
|
|
332
332
|
throw new u("Failed to parse the decoded payload as JSON");
|
|
333
333
|
}
|
|
334
|
-
if (!q(
|
|
334
|
+
if (!q(o))
|
|
335
335
|
throw new u("Invalid JWT Claims Set");
|
|
336
|
-
return
|
|
336
|
+
return o;
|
|
337
337
|
}
|
|
338
338
|
function E(e, t) {
|
|
339
339
|
if (t != null && t.email)
|
|
@@ -348,8 +348,8 @@ function H(e) {
|
|
|
348
348
|
const { nameIdentifier: t, ...n } = e;
|
|
349
349
|
return {
|
|
350
350
|
...n,
|
|
351
|
-
nameIdentifier: t == null ? void 0 : t.map(({ nameIdentifierType: r, ...
|
|
352
|
-
...
|
|
351
|
+
nameIdentifier: t == null ? void 0 : t.map(({ nameIdentifierType: r, ...o }) => ({
|
|
352
|
+
...o,
|
|
353
353
|
naturalPersonNameIdentifierType: r
|
|
354
354
|
}))
|
|
355
355
|
};
|
|
@@ -376,24 +376,24 @@ function z(e) {
|
|
|
376
376
|
const t = e.trim();
|
|
377
377
|
if (!t)
|
|
378
378
|
return { primaryIdentifier: "", secondaryIdentifier: "" };
|
|
379
|
-
const n = t.split(/\s+/), r = n[n.length - 1],
|
|
380
|
-
return { primaryIdentifier: r, secondaryIdentifier:
|
|
379
|
+
const n = t.split(/\s+/), r = n[n.length - 1], o = n.slice(0, -1), i = o.length > 0 ? o.join(" ") : r;
|
|
380
|
+
return { primaryIdentifier: r, secondaryIdentifier: i };
|
|
381
381
|
}
|
|
382
382
|
function Y(e, t, n = ["1234567890"]) {
|
|
383
|
-
const r = t == null ? void 0 : t.map((
|
|
384
|
-
const
|
|
385
|
-
return
|
|
386
|
-
...
|
|
383
|
+
const r = t == null ? void 0 : t.map((o) => {
|
|
384
|
+
const i = { ...o };
|
|
385
|
+
return i.naturalPerson && (i.naturalPerson = {
|
|
386
|
+
...i.naturalPerson,
|
|
387
387
|
geographicAddress: p
|
|
388
|
-
}),
|
|
389
|
-
...
|
|
388
|
+
}), i.legalPerson && (i.legalPerson = {
|
|
389
|
+
...i.legalPerson,
|
|
390
390
|
geographicAddress: p
|
|
391
|
-
}),
|
|
391
|
+
}), i;
|
|
392
392
|
});
|
|
393
393
|
return e === "originator" ? { originatorPersons: r, accountNumber: n } : { beneficiaryPersons: r, accountNumber: n };
|
|
394
394
|
}
|
|
395
395
|
function Q(e, t = "John Doe") {
|
|
396
|
-
const { primaryIdentifier: n, secondaryIdentifier: r } = z(t),
|
|
396
|
+
const { primaryIdentifier: n, secondaryIdentifier: r } = z(t), o = {
|
|
397
397
|
naturalPerson: {
|
|
398
398
|
name: [
|
|
399
399
|
{
|
|
@@ -409,7 +409,7 @@ function Q(e, t = "John Doe") {
|
|
|
409
409
|
geographicAddress: p
|
|
410
410
|
}
|
|
411
411
|
};
|
|
412
|
-
return e === "originator" ? { originatorPersons: [
|
|
412
|
+
return e === "originator" ? { originatorPersons: [o], accountNumber: ["1234567890"] } : { beneficiaryPersons: [o], accountNumber: ["1234567890"] };
|
|
413
413
|
}
|
|
414
414
|
const Z = (e) => ({
|
|
415
415
|
...e,
|
|
@@ -418,12 +418,12 @@ const Z = (e) => ({
|
|
|
418
418
|
}), ee = (e) => ({
|
|
419
419
|
...e,
|
|
420
420
|
naturalPerson: e.naturalPerson ? Z(e.naturalPerson) : void 0
|
|
421
|
-
}), te = ({ beneficiary: e, originator: t }, n, r,
|
|
421
|
+
}), te = ({ beneficiary: e, originator: t }, n, r, o, i) => {
|
|
422
422
|
var s;
|
|
423
423
|
{
|
|
424
424
|
const a = e && {
|
|
425
425
|
...e,
|
|
426
|
-
...
|
|
426
|
+
...o && { accountNumber: [o] },
|
|
427
427
|
beneficiaryPersons: (s = e.beneficiaryPersons) == null ? void 0 : s.map(ee)
|
|
428
428
|
};
|
|
429
429
|
if (r && (a != null && a.beneficiaryPersons)) {
|
|
@@ -446,10 +446,10 @@ const Z = (e) => ({
|
|
|
446
446
|
}
|
|
447
447
|
};
|
|
448
448
|
function ne(e, t, n) {
|
|
449
|
-
var
|
|
450
|
-
const { beneficiary: r, originator:
|
|
449
|
+
var i, s;
|
|
450
|
+
const { beneficiary: r, originator: o } = te(
|
|
451
451
|
n,
|
|
452
|
-
(
|
|
452
|
+
(i = e.customer) == null ? void 0 : i.name,
|
|
453
453
|
t.originatorEqualsBeneficiary,
|
|
454
454
|
e.destination
|
|
455
455
|
);
|
|
@@ -460,95 +460,101 @@ function ne(e, t, n) {
|
|
|
460
460
|
originatorVASPdid: t.originatorVASPdid,
|
|
461
461
|
...t.beneficiaryVASPdid && !t.beneficiaryProof ? { beneficiaryVASPdid: t.beneficiaryVASPdid } : {},
|
|
462
462
|
transactionBlockchainInfo: {
|
|
463
|
-
...(
|
|
463
|
+
...(o == null ? void 0 : o.accountNumber) && { origin: o.accountNumber[0] },
|
|
464
464
|
...e.destination && { destination: e.destination }
|
|
465
465
|
},
|
|
466
466
|
...t.beneficiaryProof && {
|
|
467
467
|
beneficiaryProof: t.beneficiaryProof
|
|
468
468
|
},
|
|
469
469
|
...r && { beneficiary: r },
|
|
470
|
-
...
|
|
470
|
+
...o && { originator: o },
|
|
471
471
|
...t.originatorEqualsBeneficiary && {
|
|
472
472
|
originatorEqualsBeneficiary: t.originatorEqualsBeneficiary
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function w(e, t, n = {}) {
|
|
477
477
|
var a, d;
|
|
478
|
-
const r = (n == null ? void 0 : n.originatorId) || E("originator", e.customer),
|
|
478
|
+
const r = (n == null ? void 0 : n.originatorId) || E("originator", e.customer), o = (n == null ? void 0 : n.beneficiaryId) || E("beneficiary", e.counterparty), i = (n == null ? void 0 : n.referenceId) || Math.random().toString(36).substring(2, 15), s = [];
|
|
479
479
|
return t.originatorVASPdid && s.push({
|
|
480
480
|
"@id": t.originatorVASPdid,
|
|
481
481
|
for: r,
|
|
482
482
|
role: "VASP"
|
|
483
483
|
}), t.beneficiaryVASPdid && s.push({
|
|
484
484
|
"@id": t.beneficiaryVASPdid,
|
|
485
|
-
for:
|
|
485
|
+
for: o,
|
|
486
486
|
role: "VASP"
|
|
487
487
|
}), e.destination && ((a = e == null ? void 0 : e.account) != null && a.did) && s.push({
|
|
488
488
|
"@id": e.account.did,
|
|
489
|
-
for: t.beneficiaryVASPdid ||
|
|
489
|
+
for: t.beneficiaryVASPdid || o,
|
|
490
490
|
role: "SettlementAddress"
|
|
491
491
|
}), {
|
|
492
492
|
originator: { "@id": r },
|
|
493
|
-
beneficiary: { "@id":
|
|
493
|
+
beneficiary: { "@id": o },
|
|
494
494
|
asset: e.asset,
|
|
495
495
|
amount: ((d = e.amountDecimal) == null ? void 0 : d.toString()) || t.transactionAmount,
|
|
496
496
|
agents: s,
|
|
497
|
-
ref:
|
|
497
|
+
ref: i
|
|
498
498
|
};
|
|
499
499
|
}
|
|
500
500
|
function L(e, t, n = {}) {
|
|
501
|
-
var
|
|
502
|
-
const r = n.beneficiaryId || E("beneficiary", e.counterparty),
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
var i, s, a;
|
|
502
|
+
const r = n.beneficiaryId || E("beneficiary", e.counterparty), o = (
|
|
503
|
+
// If counterparty type is SELF, reuse originator data for beneficiary
|
|
504
|
+
((i = e.counterparty) == null ? void 0 : i.type) === g.SELF && n.originator ? n.originator.originatorPerson : (
|
|
505
|
+
// Convert all beneficiary persons from V1 to V2 format
|
|
506
|
+
((a = (s = t.beneficiary) == null ? void 0 : s.beneficiaryPersons) == null ? void 0 : a.map(
|
|
507
|
+
(d) => X(d, r)
|
|
508
|
+
)) || []
|
|
509
|
+
)
|
|
510
|
+
);
|
|
505
511
|
return {
|
|
506
512
|
ivms101: {
|
|
507
513
|
originator: n.originator,
|
|
508
514
|
beneficiary: {
|
|
509
|
-
beneficiaryPerson:
|
|
515
|
+
beneficiaryPerson: o
|
|
510
516
|
}
|
|
511
517
|
}
|
|
512
518
|
};
|
|
513
519
|
}
|
|
514
|
-
function
|
|
515
|
-
var
|
|
520
|
+
function b(e, t, n) {
|
|
521
|
+
var o;
|
|
516
522
|
const r = { ...e };
|
|
517
523
|
if (!r.originatorId)
|
|
518
524
|
try {
|
|
519
|
-
const
|
|
520
|
-
|
|
525
|
+
const i = K(t);
|
|
526
|
+
i != null && i.sub && (r.originatorId = i.sub);
|
|
521
527
|
} catch {
|
|
522
528
|
}
|
|
523
|
-
return r.beneficiaryId || (((
|
|
529
|
+
return r.beneficiaryId || (((o = n.counterparty) == null ? void 0 : o.type) === g.SELF ? r.beneficiaryId = r.originatorId : n.destination && (r.beneficiaryId = `did:key:${n.destination}`)), r;
|
|
524
530
|
}
|
|
525
|
-
function
|
|
531
|
+
function ie(e) {
|
|
526
532
|
var s;
|
|
527
533
|
if (!e.txCreate || !e.ivms101)
|
|
528
534
|
throw new Error(
|
|
529
535
|
"Invalid response: missing required txCreate or ivms101 data"
|
|
530
536
|
);
|
|
531
|
-
const { value: t, ivms101: n, proof: r, txCreate:
|
|
537
|
+
const { value: t, ivms101: n, proof: r, txCreate: o } = e, i = {
|
|
532
538
|
destination: (t == null ? void 0 : t.destination) || "",
|
|
533
539
|
counterparty: (t == null ? void 0 : t.counterparty) || {},
|
|
534
540
|
agent: t == null ? void 0 : t.agent,
|
|
535
541
|
account: t == null ? void 0 : t.account,
|
|
536
542
|
proof: r,
|
|
537
|
-
asset: (t == null ? void 0 : t.asset) || (typeof
|
|
538
|
-
amountDecimal: (t == null ? void 0 : t.amountDecimal) || (
|
|
543
|
+
asset: (t == null ? void 0 : t.asset) || (typeof o.transactionAsset == "string" ? o.transactionAsset : (s = o.transactionAsset) == null ? void 0 : s.caip19) || "",
|
|
544
|
+
amountDecimal: (t == null ? void 0 : t.amountDecimal) || (o.transactionAmount ? parseFloat(o.transactionAmount) : 0),
|
|
539
545
|
customer: t == null ? void 0 : t.customer
|
|
540
546
|
};
|
|
541
|
-
return ne(
|
|
547
|
+
return ne(i, o, n);
|
|
542
548
|
}
|
|
543
549
|
function se(e, t, n = {}) {
|
|
544
550
|
if (!e.txCreate || !e.ivms101)
|
|
545
551
|
throw new Error(
|
|
546
552
|
"Invalid response: missing required txCreate or ivms101 data"
|
|
547
553
|
);
|
|
548
|
-
const { value: r, txCreate:
|
|
554
|
+
const { value: r, txCreate: o, ivms101: i, proof: s } = e, a = b(n, t, r);
|
|
549
555
|
return {
|
|
550
|
-
createTx:
|
|
551
|
-
ivms101: L(r,
|
|
556
|
+
createTx: w(r, o, a),
|
|
557
|
+
ivms101: L(r, i, a),
|
|
552
558
|
...s && { confirmRelationship: { proof: s } }
|
|
553
559
|
};
|
|
554
560
|
}
|
|
@@ -557,43 +563,43 @@ function ae(e, t, n = {}) {
|
|
|
557
563
|
throw new Error(
|
|
558
564
|
"Invalid response: missing required txCreate or ivms101 data"
|
|
559
565
|
);
|
|
560
|
-
const { value: r, txCreate:
|
|
561
|
-
return
|
|
566
|
+
const { value: r, txCreate: o } = e, i = b(n, t, r);
|
|
567
|
+
return w(r, o, i);
|
|
562
568
|
}
|
|
563
569
|
function ce(e, t, n = {}) {
|
|
564
570
|
if (!e.ivms101)
|
|
565
571
|
throw new Error("Invalid response: missing required ivms101 data");
|
|
566
|
-
const { value: r, ivms101:
|
|
567
|
-
return L(r,
|
|
572
|
+
const { value: r, ivms101: o } = e, i = b(n, t, r);
|
|
573
|
+
return L(r, o, i);
|
|
568
574
|
}
|
|
569
|
-
async function
|
|
570
|
-
const n = JSON.stringify(e), r = new TextEncoder(),
|
|
575
|
+
async function I(e, t) {
|
|
576
|
+
const n = JSON.stringify(e), r = new TextEncoder(), o = t ? A(t) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
|
|
571
577
|
"raw",
|
|
572
|
-
|
|
578
|
+
o,
|
|
573
579
|
{ name: "AES-GCM" },
|
|
574
580
|
!1,
|
|
575
581
|
["encrypt"]
|
|
576
582
|
), s = crypto.getRandomValues(new Uint8Array(12)), a = await crypto.subtle.encrypt(
|
|
577
583
|
{ name: "AES-GCM", iv: s },
|
|
578
|
-
|
|
584
|
+
i,
|
|
579
585
|
r.encode(n)
|
|
580
586
|
);
|
|
581
587
|
return {
|
|
582
588
|
ciphertext: `${m(s)}-${m(a)}`,
|
|
583
|
-
key: m(
|
|
589
|
+
key: m(o)
|
|
584
590
|
};
|
|
585
591
|
}
|
|
586
592
|
async function P({ ciphertext: e, key: t }) {
|
|
587
|
-
const [n, r] = e.split("-"),
|
|
593
|
+
const [n, r] = e.split("-"), o = new Uint8Array(
|
|
588
594
|
atob(t).split("").map((v) => v.charCodeAt(0))
|
|
589
|
-
),
|
|
595
|
+
), i = A(n), s = A(r), a = await crypto.subtle.importKey(
|
|
590
596
|
"raw",
|
|
591
|
-
|
|
597
|
+
o,
|
|
592
598
|
{ name: "AES-GCM" },
|
|
593
599
|
!1,
|
|
594
600
|
["decrypt"]
|
|
595
601
|
), d = new TextDecoder(), h = await crypto.subtle.decrypt(
|
|
596
|
-
{ name: "AES-GCM", iv: new Uint8Array(
|
|
602
|
+
{ name: "AES-GCM", iv: new Uint8Array(i) },
|
|
597
603
|
a,
|
|
598
604
|
s
|
|
599
605
|
);
|
|
@@ -628,16 +634,16 @@ async function de(e) {
|
|
|
628
634
|
};
|
|
629
635
|
if (n.status === "closed")
|
|
630
636
|
return r;
|
|
631
|
-
const
|
|
632
|
-
ciphertext:
|
|
637
|
+
const o = n.sealed[n.sealed.length - 1], i = await P({
|
|
638
|
+
ciphertext: o,
|
|
633
639
|
key: e.key
|
|
634
640
|
});
|
|
635
641
|
return n.status === "completed" ? {
|
|
636
642
|
...r,
|
|
637
|
-
result:
|
|
643
|
+
result: i.result
|
|
638
644
|
} : {
|
|
639
645
|
...r,
|
|
640
|
-
tx:
|
|
646
|
+
tx: i.tx
|
|
641
647
|
};
|
|
642
648
|
}
|
|
643
649
|
class le {
|
|
@@ -653,19 +659,19 @@ class le {
|
|
|
653
659
|
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
654
660
|
*/
|
|
655
661
|
async create(t, n) {
|
|
656
|
-
const r = await
|
|
662
|
+
const r = await I(t), o = {
|
|
657
663
|
metadata: n,
|
|
658
664
|
sealed: r.ciphertext
|
|
659
|
-
},
|
|
665
|
+
}, i = await fetch(this.endpoint, {
|
|
660
666
|
method: "POST",
|
|
661
667
|
headers: {
|
|
662
668
|
"Content-Type": "application/json"
|
|
663
669
|
},
|
|
664
|
-
body: JSON.stringify(
|
|
670
|
+
body: JSON.stringify(o)
|
|
665
671
|
});
|
|
666
|
-
if (!
|
|
667
|
-
throw new Error(`Failed to create connection: ${await
|
|
668
|
-
const s = await
|
|
672
|
+
if (!i.ok)
|
|
673
|
+
throw new Error(`Failed to create connection: ${await i.text()}`);
|
|
674
|
+
const s = await i.json();
|
|
669
675
|
return {
|
|
670
676
|
id: s.id,
|
|
671
677
|
version: s.version,
|
|
@@ -685,11 +691,11 @@ class le {
|
|
|
685
691
|
* @param key Current encryption key
|
|
686
692
|
* @returns Promise resolving to updated connection details including new encryption key
|
|
687
693
|
*/
|
|
688
|
-
async update(t, n, r,
|
|
689
|
-
const s = await
|
|
694
|
+
async update(t, n, r, o, i) {
|
|
695
|
+
const s = await I(n, i), a = {
|
|
690
696
|
sealed: s.ciphertext,
|
|
691
697
|
version: r,
|
|
692
|
-
status:
|
|
698
|
+
status: o
|
|
693
699
|
}, d = await fetch(`${this.endpoint}/${t}`, {
|
|
694
700
|
method: "PATCH",
|
|
695
701
|
headers: {
|
|
@@ -722,15 +728,15 @@ class le {
|
|
|
722
728
|
});
|
|
723
729
|
if (!r.ok)
|
|
724
730
|
throw new Error(`Failed to get connection: ${await r.text()}`);
|
|
725
|
-
const
|
|
726
|
-
ciphertext:
|
|
731
|
+
const o = await r.json(), i = o.sealed[o.sealed.length - 1], s = await P({
|
|
732
|
+
ciphertext: i,
|
|
727
733
|
key: n
|
|
728
734
|
});
|
|
729
735
|
return {
|
|
730
|
-
id:
|
|
731
|
-
status:
|
|
732
|
-
version:
|
|
733
|
-
metadata:
|
|
736
|
+
id: o.id,
|
|
737
|
+
status: o.status,
|
|
738
|
+
version: o.version,
|
|
739
|
+
metadata: o.metadata,
|
|
734
740
|
data: s,
|
|
735
741
|
key: n
|
|
736
742
|
};
|
|
@@ -772,15 +778,15 @@ class ue {
|
|
|
772
778
|
* @returns component URL
|
|
773
779
|
* @internal
|
|
774
780
|
*/
|
|
775
|
-
componentUrl(t, n, r,
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
const s =
|
|
781
|
+
componentUrl(t, n, r, o) {
|
|
782
|
+
const i = new URL(this.uxUrl);
|
|
783
|
+
i.pathname = t;
|
|
784
|
+
const s = F({
|
|
779
785
|
authToken: this.authToken,
|
|
780
786
|
value: n,
|
|
781
787
|
configuration: r
|
|
782
788
|
});
|
|
783
|
-
return
|
|
789
|
+
return i.hash = s, 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), o && (o.callback && i.searchParams.set("callback_url", o.callback), o.redirectUri && i.searchParams.set("redirect_uri", o.redirectUri)), i.toString();
|
|
784
790
|
}
|
|
785
791
|
/**
|
|
786
792
|
* Creates a new embedded component
|
|
@@ -792,9 +798,9 @@ class ue {
|
|
|
792
798
|
* @returns A new EmbeddedComponent instance
|
|
793
799
|
* @internal
|
|
794
800
|
*/
|
|
795
|
-
createComponent(t, n, r,
|
|
801
|
+
createComponent(t, n, r, o) {
|
|
796
802
|
return new J(
|
|
797
|
-
this.componentUrl(t, n, r,
|
|
803
|
+
this.componentUrl(t, n, r, o),
|
|
798
804
|
n,
|
|
799
805
|
r
|
|
800
806
|
);
|
|
@@ -877,7 +883,7 @@ export {
|
|
|
877
883
|
y as HMType,
|
|
878
884
|
T as IdentityVerificationMethod,
|
|
879
885
|
U as OAuthProvider,
|
|
880
|
-
|
|
886
|
+
g as PersonType,
|
|
881
887
|
B as ProofStatus,
|
|
882
888
|
W as ProofTypes,
|
|
883
889
|
_ as Status,
|
|
@@ -887,8 +893,8 @@ export {
|
|
|
887
893
|
ce as componentResponseToIVMS101,
|
|
888
894
|
ae as componentResponseToTxCreateRequest,
|
|
889
895
|
se as componentResponseToTxRequests,
|
|
890
|
-
|
|
891
|
-
|
|
896
|
+
ie as componentResponseToV1TxCreateRequest,
|
|
897
|
+
oe as decodeFragmentToObject,
|
|
892
898
|
ue as default,
|
|
893
899
|
de as getRefreshResult
|
|
894
900
|
};
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Notabene <developers@notabene.id>",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"packageManager": "yarn@4.5.1",
|
|
13
|
-
"version": "2.14.0-next.
|
|
13
|
+
"version": "2.14.0-next.4",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|
|
@@ -6,7 +6,12 @@ import type {
|
|
|
6
6
|
Person,
|
|
7
7
|
} from '@notabene/javascript-sdk/src/ivms/types';
|
|
8
8
|
import type { Agent } from '@taprsvp/types';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
PersonType,
|
|
11
|
+
type IVMS101,
|
|
12
|
+
type V1Transaction,
|
|
13
|
+
type Withdrawal,
|
|
14
|
+
} from '../types';
|
|
10
15
|
import type {
|
|
11
16
|
ResponseToTxRequestConfig,
|
|
12
17
|
TransactionCreateRequest,
|
|
@@ -276,11 +281,14 @@ export function mapToAppendPiiRequest(
|
|
|
276
281
|
const beneficiaryId =
|
|
277
282
|
config.beneficiaryId || getPartyId('beneficiary', withdrawal.counterparty);
|
|
278
283
|
|
|
279
|
-
// Convert all beneficiary persons from V1 to V2 format
|
|
280
284
|
const beneficiaryPersons =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
285
|
+
// If counterparty type is SELF, reuse originator data for beneficiary
|
|
286
|
+
withdrawal.counterparty?.type === PersonType.SELF && config.originator
|
|
287
|
+
? config.originator.originatorPerson
|
|
288
|
+
: // Convert all beneficiary persons from V1 to V2 format
|
|
289
|
+
ivms101.beneficiary?.beneficiaryPersons?.map((person) =>
|
|
290
|
+
convertPersonToV2(person, beneficiaryId),
|
|
291
|
+
) || [];
|
|
284
292
|
|
|
285
293
|
return {
|
|
286
294
|
ivms101: {
|