@notabene/javascript-sdk 2.14.0 → 2.14.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/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 || {}), 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 || {});
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 || {}), I = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(I || {}), 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.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, i = this.listeners.get(r);
60
- i && i.forEach((o) => o(n));
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, (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`);
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, 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) => {
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
- 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();
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();
@@ -166,7 +166,7 @@ class J {
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: y.UPDATE, value: t, options: this._options });
169
+ this._value = t, n && (this._options = n), this.send({ type: I.UPDATE, value: t, options: this._options });
170
170
  }
171
171
  /**
172
172
  * Waits for the component to complete and returns the transaction response
@@ -174,15 +174,15 @@ class J {
174
174
  */
175
175
  completion() {
176
176
  return new Promise((t, n) => {
177
- let r, i, o;
177
+ let r, o, i;
178
178
  function s() {
179
- r && r(), i && i(), o && o();
179
+ r && r(), o && o(), i && i();
180
180
  }
181
181
  r = this.on(l.COMPLETE, (a) => {
182
182
  t(a.response), s();
183
- }), i = this.on(l.CANCEL, () => {
183
+ }), o = this.on(l.CANCEL, () => {
184
184
  n(new Error("User cancelled")), s();
185
- }), o = this.on("error", (a) => {
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", (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]));
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 j(e) {
240
+ function F(e) {
241
241
  return Object.entries(e).map(([t, n]) => {
242
242
  if (n == null) return;
243
- const r = encodeURIComponent(t), i = encodeURIComponent(
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}=${i}`;
247
+ return `${r}=${o}`;
248
248
  }).filter((t) => t !== void 0).join("&");
249
249
  }
250
- function ie(e) {
250
+ function oe(e) {
251
251
  const t = e.slice(1);
252
252
  return t ? t.split("&").filter(Boolean).reduce(
253
- (r, i) => {
254
- const [o, s] = i.split("=");
255
- return o && (r[decodeURIComponent(o)] = s ? decodeURIComponent(s) : ""), r;
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 F(e) {
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 F(t);
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 w extends Error {
283
+ class N extends Error {
284
284
  constructor(n, r) {
285
- var i;
285
+ var o;
286
286
  super(n, r);
287
287
  c(this, "code", "ERR_JOSE_GENERIC");
288
- this.name = this.constructor.name, (i = Error.captureStackTrace) == null || i.call(Error, this, this.constructor);
288
+ this.name = this.constructor.name, (o = Error.captureStackTrace) == null || o.call(Error, this, this.constructor);
289
289
  }
290
290
  }
291
- c(w, "code", "ERR_JOSE_GENERIC");
292
- class u extends w {
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 i;
328
+ let o;
329
329
  try {
330
- i = JSON.parse(f.decode(r));
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(i))
334
+ if (!q(o))
335
335
  throw new u("Invalid JWT Claims Set");
336
- return i;
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, ...i }) => ({
352
- ...i,
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], i = n.slice(0, -1), o = i.length > 0 ? i.join(" ") : r;
380
- return { primaryIdentifier: r, secondaryIdentifier: o };
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((i) => {
384
- const o = { ...i };
385
- return o.naturalPerson && (o.naturalPerson = {
386
- ...o.naturalPerson,
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
- }), o.legalPerson && (o.legalPerson = {
389
- ...o.legalPerson,
388
+ }), i.legalPerson && (i.legalPerson = {
389
+ ...i.legalPerson,
390
390
  geographicAddress: p
391
- }), o;
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), i = {
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: [i], accountNumber: ["1234567890"] } : { beneficiaryPersons: [i], accountNumber: ["1234567890"] };
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, i, o) => {
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
- ...i && { accountNumber: [i] },
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 o, s;
450
- const { beneficiary: r, originator: i } = te(
449
+ var i, s;
450
+ const { beneficiary: r, originator: o } = te(
451
451
  n,
452
- (o = e.customer) == null ? void 0 : o.name,
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
- ...(i == null ? void 0 : i.accountNumber) && { origin: i.accountNumber[0] },
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
- ...i && { originator: i },
470
+ ...o && { originator: o },
471
471
  ...t.originatorEqualsBeneficiary && {
472
472
  originatorEqualsBeneficiary: t.originatorEqualsBeneficiary
473
473
  }
474
474
  };
475
475
  }
476
- function N(e, t, n = {}) {
476
+ function w(e, t, n = {}) {
477
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 = [];
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: i,
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 || i,
489
+ for: t.beneficiaryVASPdid || o,
490
490
  role: "SettlementAddress"
491
491
  }), {
492
492
  originator: { "@id": r },
493
- beneficiary: { "@id": i },
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: o
497
+ ref: i
498
498
  };
499
499
  }
500
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
- )) || [];
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: i
515
+ beneficiaryPerson: o
510
516
  }
511
517
  }
512
518
  };
513
519
  }
514
- function g(e, t, n) {
515
- var i;
520
+ function b(e, t, n) {
521
+ var o;
516
522
  const r = { ...e };
517
523
  if (!r.originatorId)
518
524
  try {
519
- const o = K(t);
520
- o != null && o.sub && (r.originatorId = o.sub);
525
+ const i = K(t);
526
+ i != null && i.sub && (r.originatorId = i.sub);
521
527
  } catch {
522
528
  }
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;
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 oe(e) {
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: i } = e, o = {
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 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),
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(o, i, n);
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: i, ivms101: o, proof: s } = e, a = g(n, t, r);
554
+ const { value: r, txCreate: o, ivms101: i, proof: s } = e, a = b(n, t, r);
549
555
  return {
550
- createTx: N(r, i, a),
551
- ivms101: L(r, o, a),
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: i } = e, o = g(n, t, r);
561
- return N(r, i, o);
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: i } = e, o = g(n, t, r);
567
- return L(r, i, o);
572
+ const { value: r, ivms101: o } = e, i = b(n, t, r);
573
+ return L(r, o, i);
568
574
  }
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(
575
+ async function y(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
- i,
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
- o,
584
+ i,
579
585
  r.encode(n)
580
586
  );
581
587
  return {
582
588
  ciphertext: `${m(s)}-${m(a)}`,
583
- key: m(i)
589
+ key: m(o)
584
590
  };
585
591
  }
586
592
  async function P({ ciphertext: e, key: t }) {
587
- const [n, r] = e.split("-"), i = new Uint8Array(
593
+ const [n, r] = e.split("-"), o = new Uint8Array(
588
594
  atob(t).split("").map((v) => v.charCodeAt(0))
589
- ), o = A(n), s = A(r), a = await crypto.subtle.importKey(
595
+ ), i = A(n), s = A(r), a = await crypto.subtle.importKey(
590
596
  "raw",
591
- i,
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(o) },
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 i = n.sealed[n.sealed.length - 1], o = await P({
632
- ciphertext: i,
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: o.result
643
+ result: i.result
638
644
  } : {
639
645
  ...r,
640
- tx: o.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 b(t), i = {
662
+ const r = await y(t), o = {
657
663
  metadata: n,
658
664
  sealed: r.ciphertext
659
- }, o = await fetch(this.endpoint, {
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(i)
670
+ body: JSON.stringify(o)
665
671
  });
666
- if (!o.ok)
667
- throw new Error(`Failed to create connection: ${await o.text()}`);
668
- const s = await o.json();
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, i, o) {
689
- const s = await b(n, o), a = {
694
+ async update(t, n, r, o, i) {
695
+ const s = await y(n, i), a = {
690
696
  sealed: s.ciphertext,
691
697
  version: r,
692
- status: i
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 i = await r.json(), o = i.sealed[i.sealed.length - 1], s = await P({
726
- ciphertext: o,
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: i.id,
731
- status: i.status,
732
- version: i.version,
733
- metadata: i.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, i) {
776
- const o = new URL(this.uxUrl);
777
- o.pathname = t;
778
- const s = j({
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 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();
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, i) {
801
+ createComponent(t, n, r, o) {
796
802
  return new J(
797
- this.componentUrl(t, n, r, i),
803
+ this.componentUrl(t, n, r, o),
798
804
  n,
799
805
  r
800
806
  );
@@ -874,10 +880,10 @@ export {
874
880
  le as ConnectionManager,
875
881
  J as EmbeddedComponent,
876
882
  M as ErrorIdentifierCode,
877
- y as HMType,
883
+ I as HMType,
878
884
  T as IdentityVerificationMethod,
879
885
  U as OAuthProvider,
880
- I as PersonType,
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
- oe as componentResponseToV1TxCreateRequest,
891
- ie as decodeFragmentToObject,
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",
13
+ "version": "2.14.1",
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 type { IVMS101, V1Transaction, Withdrawal } from '../types';
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
- ivms101.beneficiary?.beneficiaryPersons?.map((person) =>
282
- convertPersonToV2(person, beneficiaryId),
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: {
package/src/types.ts CHANGED
@@ -888,6 +888,7 @@ export interface TransactionOptions {
888
888
  vasps?: VASPOptions;
889
889
  hide?: ValidationSections[]; // You can hide a specific section of the component by listing it here
890
890
  counterpartyAssist?: CounterpartyAssistConfig;
891
+ autoSubmit?: boolean; // Defaults to false
891
892
  }
892
893
  /**
893
894
  * Component Message Type enum representing different message types that can be sent
@@ -1163,7 +1164,6 @@ export enum ProofStatus {
1163
1164
  * - ED25519: Ed25519 signature (used in Solana)
1164
1165
  * - XRP_ED25519: Ed25519 signature (used in XRP)
1165
1166
  * - XLM_ED25519: Ed25519 signature (used in Stellar)
1166
- * - XPUB: Extended public key signature for HD wallets
1167
1167
  * - MicroTransfer: Proof via small blockchain transaction
1168
1168
  * - Screenshot: Image proof of ownership/access
1169
1169
  * - CIP8: Cardano message signing standard (CIP-8)
@@ -1184,7 +1184,6 @@ export enum ProofTypes {
1184
1184
  EIP1271 = 'eip-1271',
1185
1185
  BIP137 = 'bip-137',
1186
1186
  BIP322 = 'bip-322',
1187
- BIP137_XPUB = 'xpub',
1188
1187
  TIP191 = 'tip-191',
1189
1188
  ED25519 = 'ed25519',
1190
1189
  XRP_ED25519 = 'xrp-ed25519',
@@ -1315,7 +1314,6 @@ export interface SignatureProof extends OwnershipProof {
1315
1314
  | ProofTypes.EIP1271
1316
1315
  | ProofTypes.BIP137
1317
1316
  | ProofTypes.BIP322
1318
- | ProofTypes.BIP137_XPUB
1319
1317
  | ProofTypes.ED25519
1320
1318
  | ProofTypes.TIP191
1321
1319
  | ProofTypes.SIWX