🚀 Socket Launch Week 🚀 Day 2: Introducing Repository Labels and Security Policies.Learn More
Socket
Sign inDemoInstall
Socket

@notabene/javascript-sdk

Package Overview
Dependencies
Maintainers
3
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@notabene/javascript-sdk - npm Package Compare versions

Comparing version

to
2.9.0-next.3

15

dist/cjs/notabene.d.ts
/**
* A blockchain account
* @public
*/
export declare interface Account {
did?: DID;
blockchainAddress?: BlockchainAddress;
chain?: CAIP2;
caip10?: CAIP10;
identifier?: string;
}
/**
* Address

@@ -368,3 +380,3 @@ * Represents a physical address

status: ConnectionStatus;
tx: T;
tx?: T;
result?: TransactionResponse<T>;

@@ -1503,2 +1515,3 @@ }

};
account?: Account;
}

@@ -1505,0 +1518,0 @@

2

dist/cjs/package.json

@@ -13,3 +13,3 @@ {

"packageManager": "yarn@4.5.1",
"version": "2.9.0-next.2",
"version": "2.9.0-next.3",
"source": "src/notabene.ts",

@@ -16,0 +16,0 @@ "main": "dist/cjs/notabene.cjs",

/**
* A blockchain account
* @public
*/
export declare interface Account {
did?: DID;
blockchainAddress?: BlockchainAddress;
chain?: CAIP2;
caip10?: CAIP10;
identifier?: string;
}
/**
* Address

@@ -368,3 +380,3 @@ * Represents a physical address

status: ConnectionStatus;
tx: T;
tx?: T;
result?: TransactionResponse<T>;

@@ -1503,2 +1515,3 @@ }

};
account?: Account;
}

@@ -1505,0 +1518,0 @@

var v = Object.defineProperty;
var g = (t, e, n) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var a = (t, e, n) => g(t, typeof e != "symbol" ? e + "" : e, n);
var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), y = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(I || {}), L = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(L || {}), C = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(C || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), N = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(N || {}), E = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(E || {}), b = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(b || {}), U = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.XLM_ED25519 = "xlm-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(U || {});
var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), y = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(I || {}), L = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(L || {}), b = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(b || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), C = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(C || {}), E = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(E || {}), N = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(N || {}), U = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.XLM_ED25519 = "xlm-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(U || {});
class _ {

@@ -45,4 +45,4 @@ constructor() {

off(e, n) {
const r = this.listeners.get(e);
r && (r.delete(n), r.size === 0 && this.listeners.delete(e));
const s = this.listeners.get(e);
s && (s.delete(n), s.size === 0 && this.listeners.delete(e));
}

@@ -60,4 +60,4 @@ /**

if (typeof n == "object" && n !== null && "type" in n) {
const r = n.type, s = this.listeners.get(r);
s && s.forEach((i) => i(n));
const s = n.type, r = this.listeners.get(s);
r && r.forEach((i) => i(n));
}

@@ -79,3 +79,3 @@ }

*/
constructor(e, n, r) {
constructor(e, n, s) {
a(this, "_url");

@@ -88,6 +88,6 @@ a(this, "_value");

a(this, "modal");
this._url = e, this._value = n, this._options = r, this.eventManager = new _(), this.on(l.INVALID, (s) => {
s.type === l.INVALID && (this._errors = s.errors, this._value = s.value);
}), this.on(l.RESIZE, (s) => {
s.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
this._url = e, this._value = n, this._options = s, this.eventManager = new _(), this.on(l.INVALID, (r) => {
r.type === l.INVALID && (this._errors = r.errors, this._value = r.value);
}), this.on(l.RESIZE, (r) => {
r.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
});

@@ -136,7 +136,7 @@ }

embed(e, n = !1) {
var r, s;
var s, r;
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", e.appendChild(this.iframe), window.addEventListener("message", (i) => {
var o, c;
i.source === ((o = this.iframe) == null ? void 0 : o.contentWindow) && ((c = this.eventManager) == null || c.setPort(i.ports[0]));
}), (s = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || s.focus();
}), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.focus();
}

@@ -182,9 +182,9 @@ removeEmbed() {

return new Promise((e, n) => {
let r, s, i;
let s, r, i;
function o() {
r && r(), s && s(), i && i();
s && s(), r && r(), i && i();
}
r = this.on(l.COMPLETE, (c) => {
s = this.on(l.COMPLETE, (c) => {
e(c.response), o();
}), s = this.on(l.CANCEL, () => {
}), r = this.on(l.CANCEL, () => {
n(new Error("User cancelled")), o();

@@ -232,24 +232,24 @@ }), i = this.on("error", (c) => {

);
window.addEventListener("message", (s) => {
window.addEventListener("message", (r) => {
var i;
s.source === e && (console.log("received message from popup", s.data), (i = this.eventManager) == null || i.setPort(s.ports[0]));
r.source === e && (console.log("received message from popup", r.data), (i = this.eventManager) == null || i.setPort(r.ports[0]));
});
const n = this.on(l.CANCEL, () => {
e == null || e.close();
}), r = this.on(l.COMPLETE, () => {
}), s = this.on(l.COMPLETE, () => {
e == null || e.close();
});
return this.completion().finally(() => {
n(), r();
n(), s();
});
}
}
function R(t) {
function D(t) {
return Object.entries(t).map(([e, n]) => {
if (n == null) return;
const r = encodeURIComponent(e), s = encodeURIComponent(
const s = encodeURIComponent(e), r = encodeURIComponent(
typeof n == "object" ? JSON.stringify(n) : String(n)
// Use String() to handle all primitive types
);
return `${r}=${s}`;
return `${s}=${r}`;
}).filter((e) => e !== void 0).join("&");

@@ -260,5 +260,5 @@ }

return e ? e.split("&").filter(Boolean).reduce(
(r, s) => {
const [i, o] = s.split("=");
return i && (r[decodeURIComponent(i)] = o ? decodeURIComponent(o) : ""), r;
(s, r) => {
const [i, o] = r.split("=");
return i && (s[decodeURIComponent(i)] = o ? decodeURIComponent(o) : ""), s;
},

@@ -269,5 +269,5 @@ {}

async function p(t, e) {
const n = JSON.stringify(t), r = new TextEncoder(), s = e ? m(e) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
const n = JSON.stringify(t), s = new TextEncoder(), r = e ? m(e) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
"raw",
s,
r,
{ name: "AES-GCM" },

@@ -279,15 +279,15 @@ !1,

i,
r.encode(n)
s.encode(n)
);
return {
ciphertext: `${u(o)}-${u(c)}`,
key: u(s)
key: u(r)
};
}
async function f({ ciphertext: t, key: e }) {
const [n, r] = t.split("-"), s = new Uint8Array(
const [n, s] = t.split("-"), r = new Uint8Array(
atob(e).split("").map((w) => w.charCodeAt(0))
), i = m(n), o = m(r), c = await crypto.subtle.importKey(
), i = m(n), o = m(s), c = await crypto.subtle.importKey(
"raw",
s,
r,
{ name: "AES-GCM" },

@@ -306,4 +306,4 @@ !1,

let n = "";
for (let r = 0; r < e.length; r++)
n += String.fromCharCode(e[r]);
for (let s = 0; s < e.length; s++)
n += String.fromCharCode(e[s]);
return btoa(n);

@@ -313,4 +313,4 @@ }

const e = atob(t), n = new Uint8Array(e.length);
for (let r = 0; r < e.length; r++)
n[r] = e.charCodeAt(r);
for (let s = 0; s < e.length; s++)
n[s] = e.charCodeAt(s);
return n;

@@ -325,14 +325,21 @@ }

const n = await e.json();
if (!n.sealed)
throw new Error("No data found");
const r = n.sealed[n.sealed.length - 1], s = await f({
if (!n.id || !n.metadata || !n.status || !n.sealed)
throw new Error("Data missing from server response");
const s = {
id: n.id,
metadata: n.metadata,
status: n.status
};
if (n.status === "closed")
return s;
const r = n.sealed[n.sealed.length - 1], i = await f({
ciphertext: r,
key: t.key
});
return {
id: n.id,
metadata: n.metadata,
status: n.status,
tx: s.tx,
result: s.result
return n.status === "completed" ? {
...s,
result: i.result
} : {
...s,
tx: i.tx
};

@@ -352,5 +359,5 @@ }

async create(e, n) {
const r = await p(e), s = {
const s = await p(e), r = {
metadata: n,
sealed: r.ciphertext
sealed: s.ciphertext
}, i = await fetch(this.endpoint, {

@@ -361,3 +368,3 @@ method: "POST",

},
body: JSON.stringify(s)
body: JSON.stringify(r)
});

@@ -373,3 +380,3 @@ if (!i.ok)

data: e,
key: r.key
key: s.key
};

@@ -384,7 +391,7 @@ }

*/
async update(e, n, r, s, i) {
async update(e, n, s, r, i) {
const o = await p(n, i), c = {
sealed: o.ciphertext,
version: r,
status: s
version: s,
status: r
}, h = await fetch(`${this.endpoint}/${e}`, {

@@ -416,8 +423,8 @@ method: "PATCH",

async get(e, n) {
const r = await fetch(`${this.endpoint}/${e}`, {
const s = await fetch(`${this.endpoint}/${e}`, {
method: "GET"
});
if (!r.ok)
throw new Error(`Failed to get connection: ${await r.text()}`);
const s = await r.json(), i = s.sealed[s.sealed.length - 1], o = await f({
if (!s.ok)
throw new Error(`Failed to get connection: ${await s.text()}`);
const r = await s.json(), i = r.sealed[r.sealed.length - 1], o = await f({
ciphertext: i,

@@ -427,6 +434,6 @@ key: n

return {
id: s.id,
status: s.status,
version: s.version,
metadata: s.metadata,
id: r.id,
status: r.status,
version: r.version,
metadata: r.metadata,
data: o,

@@ -472,11 +479,11 @@ key: n

*/
componentUrl(e, n, r, s) {
componentUrl(e, n, s, r) {
const i = new URL(this.uxUrl);
i.pathname = e;
const o = R({
const o = D({
authToken: this.authToken,
value: n,
configuration: r
configuration: s
});
return i.hash = o, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), s && (s.callback && i.searchParams.set("callback_url", s.callback), s.redirectUri && i.searchParams.set("redirect_uri", s.redirectUri)), i.toString();
return i.hash = o, 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), r && (r.callback && i.searchParams.set("callback_url", r.callback), r.redirectUri && i.searchParams.set("redirect_uri", r.redirectUri)), i.toString();
}

@@ -493,7 +500,7 @@ /**

*/
createComponent(e, n, r, s) {
createComponent(e, n, s, r) {
return new x(
this.componentUrl(e, n, r, s),
this.componentUrl(e, n, s, r),
n,
r
s
);

@@ -509,3 +516,3 @@ }

*/
createWithdrawalAssist(e, n, r) {
createWithdrawalAssist(e, n, s) {
return this.createComponent(

@@ -515,3 +522,3 @@ "withdrawal-assist",

n,
r
s
);

@@ -528,3 +535,3 @@ }

*/
createConnectWallet(e, n, r) {
createConnectWallet(e, n, s) {
return this.createComponent(

@@ -534,3 +541,3 @@ "connect",

n,
r
s
);

@@ -547,3 +554,3 @@ }

*/
createDepositRequest(e, n, r) {
createDepositRequest(e, n, s) {
return this.createComponent(

@@ -553,3 +560,3 @@ "deposit-request",

n,
r
s
);

@@ -566,3 +573,3 @@ }

*/
createDepositAssist(e, n, r) {
createDepositAssist(e, n, s) {
return this.createComponent(

@@ -572,3 +579,3 @@ "deposit-assist",

n,
r
s
);

@@ -582,10 +589,10 @@ }

x as EmbeddedComponent,
N as ErrorIdentifierCode,
C as ErrorIdentifierCode,
E as HMType,
y as PersonType,
b as ProofStatus,
N as ProofStatus,
U as ProofTypes,
I as Status,
L as VASPSearchControl,
C as ValidationSections,
b as ValidationSections,
O as decodeFragmentToObject,

@@ -592,0 +599,0 @@ k as default,

@@ -13,3 +13,3 @@ {

"packageManager": "yarn@4.5.1",
"version": "2.9.0-next.2",
"version": "2.9.0-next.3",
"source": "src/notabene.ts",

@@ -16,0 +16,0 @@ "main": "dist/cjs/notabene.cjs",

/**
* A blockchain account
* @public
*/
export declare interface Account {
did?: DID;
blockchainAddress?: BlockchainAddress;
chain?: CAIP2;
caip10?: CAIP10;
identifier?: string;
}
/**
* Address

@@ -368,3 +380,3 @@ * Represents a physical address

status: ConnectionStatus;
tx: T;
tx?: T;
result?: TransactionResponse<T>;

@@ -1503,2 +1515,3 @@ }

};
account?: Account;
}

@@ -1505,0 +1518,0 @@

var v = Object.defineProperty;
var g = (t, e, n) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var a = (t, e, n) => g(t, typeof e != "symbol" ? e + "" : e, n);
var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), y = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(I || {}), L = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(L || {}), C = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(C || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), N = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(N || {}), E = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(E || {}), b = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(b || {}), U = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.XLM_ED25519 = "xlm-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(U || {});
var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), y = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(I || {}), L = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(L || {}), b = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(b || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), C = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(C || {}), E = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(E || {}), N = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(N || {}), U = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.XLM_ED25519 = "xlm-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(U || {});
class _ {

@@ -45,4 +45,4 @@ constructor() {

off(e, n) {
const r = this.listeners.get(e);
r && (r.delete(n), r.size === 0 && this.listeners.delete(e));
const s = this.listeners.get(e);
s && (s.delete(n), s.size === 0 && this.listeners.delete(e));
}

@@ -60,4 +60,4 @@ /**

if (typeof n == "object" && n !== null && "type" in n) {
const r = n.type, s = this.listeners.get(r);
s && s.forEach((i) => i(n));
const s = n.type, r = this.listeners.get(s);
r && r.forEach((i) => i(n));
}

@@ -79,3 +79,3 @@ }

*/
constructor(e, n, r) {
constructor(e, n, s) {
a(this, "_url");

@@ -88,6 +88,6 @@ a(this, "_value");

a(this, "modal");
this._url = e, this._value = n, this._options = r, this.eventManager = new _(), this.on(l.INVALID, (s) => {
s.type === l.INVALID && (this._errors = s.errors, this._value = s.value);
}), this.on(l.RESIZE, (s) => {
s.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
this._url = e, this._value = n, this._options = s, this.eventManager = new _(), this.on(l.INVALID, (r) => {
r.type === l.INVALID && (this._errors = r.errors, this._value = r.value);
}), this.on(l.RESIZE, (r) => {
r.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
});

@@ -136,7 +136,7 @@ }

embed(e, n = !1) {
var r, s;
var s, r;
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", e.appendChild(this.iframe), window.addEventListener("message", (i) => {
var o, c;
i.source === ((o = this.iframe) == null ? void 0 : o.contentWindow) && ((c = this.eventManager) == null || c.setPort(i.ports[0]));
}), (s = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || s.focus();
}), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.focus();
}

@@ -182,9 +182,9 @@ removeEmbed() {

return new Promise((e, n) => {
let r, s, i;
let s, r, i;
function o() {
r && r(), s && s(), i && i();
s && s(), r && r(), i && i();
}
r = this.on(l.COMPLETE, (c) => {
s = this.on(l.COMPLETE, (c) => {
e(c.response), o();
}), s = this.on(l.CANCEL, () => {
}), r = this.on(l.CANCEL, () => {
n(new Error("User cancelled")), o();

@@ -232,24 +232,24 @@ }), i = this.on("error", (c) => {

);
window.addEventListener("message", (s) => {
window.addEventListener("message", (r) => {
var i;
s.source === e && (console.log("received message from popup", s.data), (i = this.eventManager) == null || i.setPort(s.ports[0]));
r.source === e && (console.log("received message from popup", r.data), (i = this.eventManager) == null || i.setPort(r.ports[0]));
});
const n = this.on(l.CANCEL, () => {
e == null || e.close();
}), r = this.on(l.COMPLETE, () => {
}), s = this.on(l.COMPLETE, () => {
e == null || e.close();
});
return this.completion().finally(() => {
n(), r();
n(), s();
});
}
}
function R(t) {
function D(t) {
return Object.entries(t).map(([e, n]) => {
if (n == null) return;
const r = encodeURIComponent(e), s = encodeURIComponent(
const s = encodeURIComponent(e), r = encodeURIComponent(
typeof n == "object" ? JSON.stringify(n) : String(n)
// Use String() to handle all primitive types
);
return `${r}=${s}`;
return `${s}=${r}`;
}).filter((e) => e !== void 0).join("&");

@@ -260,5 +260,5 @@ }

return e ? e.split("&").filter(Boolean).reduce(
(r, s) => {
const [i, o] = s.split("=");
return i && (r[decodeURIComponent(i)] = o ? decodeURIComponent(o) : ""), r;
(s, r) => {
const [i, o] = r.split("=");
return i && (s[decodeURIComponent(i)] = o ? decodeURIComponent(o) : ""), s;
},

@@ -269,5 +269,5 @@ {}

async function p(t, e) {
const n = JSON.stringify(t), r = new TextEncoder(), s = e ? m(e) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
const n = JSON.stringify(t), s = new TextEncoder(), r = e ? m(e) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
"raw",
s,
r,
{ name: "AES-GCM" },

@@ -279,15 +279,15 @@ !1,

i,
r.encode(n)
s.encode(n)
);
return {
ciphertext: `${u(o)}-${u(c)}`,
key: u(s)
key: u(r)
};
}
async function f({ ciphertext: t, key: e }) {
const [n, r] = t.split("-"), s = new Uint8Array(
const [n, s] = t.split("-"), r = new Uint8Array(
atob(e).split("").map((w) => w.charCodeAt(0))
), i = m(n), o = m(r), c = await crypto.subtle.importKey(
), i = m(n), o = m(s), c = await crypto.subtle.importKey(
"raw",
s,
r,
{ name: "AES-GCM" },

@@ -306,4 +306,4 @@ !1,

let n = "";
for (let r = 0; r < e.length; r++)
n += String.fromCharCode(e[r]);
for (let s = 0; s < e.length; s++)
n += String.fromCharCode(e[s]);
return btoa(n);

@@ -313,4 +313,4 @@ }

const e = atob(t), n = new Uint8Array(e.length);
for (let r = 0; r < e.length; r++)
n[r] = e.charCodeAt(r);
for (let s = 0; s < e.length; s++)
n[s] = e.charCodeAt(s);
return n;

@@ -325,14 +325,21 @@ }

const n = await e.json();
if (!n.sealed)
throw new Error("No data found");
const r = n.sealed[n.sealed.length - 1], s = await f({
if (!n.id || !n.metadata || !n.status || !n.sealed)
throw new Error("Data missing from server response");
const s = {
id: n.id,
metadata: n.metadata,
status: n.status
};
if (n.status === "closed")
return s;
const r = n.sealed[n.sealed.length - 1], i = await f({
ciphertext: r,
key: t.key
});
return {
id: n.id,
metadata: n.metadata,
status: n.status,
tx: s.tx,
result: s.result
return n.status === "completed" ? {
...s,
result: i.result
} : {
...s,
tx: i.tx
};

@@ -352,5 +359,5 @@ }

async create(e, n) {
const r = await p(e), s = {
const s = await p(e), r = {
metadata: n,
sealed: r.ciphertext
sealed: s.ciphertext
}, i = await fetch(this.endpoint, {

@@ -361,3 +368,3 @@ method: "POST",

},
body: JSON.stringify(s)
body: JSON.stringify(r)
});

@@ -373,3 +380,3 @@ if (!i.ok)

data: e,
key: r.key
key: s.key
};

@@ -384,7 +391,7 @@ }

*/
async update(e, n, r, s, i) {
async update(e, n, s, r, i) {
const o = await p(n, i), c = {
sealed: o.ciphertext,
version: r,
status: s
version: s,
status: r
}, h = await fetch(`${this.endpoint}/${e}`, {

@@ -416,8 +423,8 @@ method: "PATCH",

async get(e, n) {
const r = await fetch(`${this.endpoint}/${e}`, {
const s = await fetch(`${this.endpoint}/${e}`, {
method: "GET"
});
if (!r.ok)
throw new Error(`Failed to get connection: ${await r.text()}`);
const s = await r.json(), i = s.sealed[s.sealed.length - 1], o = await f({
if (!s.ok)
throw new Error(`Failed to get connection: ${await s.text()}`);
const r = await s.json(), i = r.sealed[r.sealed.length - 1], o = await f({
ciphertext: i,

@@ -427,6 +434,6 @@ key: n

return {
id: s.id,
status: s.status,
version: s.version,
metadata: s.metadata,
id: r.id,
status: r.status,
version: r.version,
metadata: r.metadata,
data: o,

@@ -472,11 +479,11 @@ key: n

*/
componentUrl(e, n, r, s) {
componentUrl(e, n, s, r) {
const i = new URL(this.uxUrl);
i.pathname = e;
const o = R({
const o = D({
authToken: this.authToken,
value: n,
configuration: r
configuration: s
});
return i.hash = o, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), s && (s.callback && i.searchParams.set("callback_url", s.callback), s.redirectUri && i.searchParams.set("redirect_uri", s.redirectUri)), i.toString();
return i.hash = o, 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), r && (r.callback && i.searchParams.set("callback_url", r.callback), r.redirectUri && i.searchParams.set("redirect_uri", r.redirectUri)), i.toString();
}

@@ -493,7 +500,7 @@ /**

*/
createComponent(e, n, r, s) {
createComponent(e, n, s, r) {
return new x(
this.componentUrl(e, n, r, s),
this.componentUrl(e, n, s, r),
n,
r
s
);

@@ -509,3 +516,3 @@ }

*/
createWithdrawalAssist(e, n, r) {
createWithdrawalAssist(e, n, s) {
return this.createComponent(

@@ -515,3 +522,3 @@ "withdrawal-assist",

n,
r
s
);

@@ -528,3 +535,3 @@ }

*/
createConnectWallet(e, n, r) {
createConnectWallet(e, n, s) {
return this.createComponent(

@@ -534,3 +541,3 @@ "connect",

n,
r
s
);

@@ -547,3 +554,3 @@ }

*/
createDepositRequest(e, n, r) {
createDepositRequest(e, n, s) {
return this.createComponent(

@@ -553,3 +560,3 @@ "deposit-request",

n,
r
s
);

@@ -566,3 +573,3 @@ }

*/
createDepositAssist(e, n, r) {
createDepositAssist(e, n, s) {
return this.createComponent(

@@ -572,3 +579,3 @@ "deposit-assist",

n,
r
s
);

@@ -582,10 +589,10 @@ }

x as EmbeddedComponent,
N as ErrorIdentifierCode,
C as ErrorIdentifierCode,
E as HMType,
y as PersonType,
b as ProofStatus,
N as ProofStatus,
U as ProofTypes,
I as Status,
L as VASPSearchControl,
C as ValidationSections,
b as ValidationSections,
O as decodeFragmentToObject,

@@ -592,0 +599,0 @@ k as default,

@@ -13,3 +13,3 @@ {

"packageManager": "yarn@4.5.1",
"version": "2.9.0-next.2",
"version": "2.9.0-next.3",
"source": "src/notabene.ts",

@@ -16,0 +16,0 @@ "main": "dist/cjs/notabene.cjs",

import EmbeddedComponent from './components/EmbeddedComponent';
import type {
Account,
Agent,

@@ -101,2 +102,3 @@ BlockchainAddress,

export type {
Account,
Agent,

@@ -103,0 +105,0 @@ BlockchainAddress,

@@ -316,2 +316,14 @@ import type {

/**
* A blockchain account
* @public
*/
export interface Account {
did?: DID;
blockchainAddress?: BlockchainAddress;
chain?: CAIP2;
caip10?: CAIP10;
identifier?: string;
}
/**
* The counterparty of a transaction.

@@ -561,2 +573,3 @@ * @public

};
account?: Account;
}

@@ -563,0 +576,0 @@

import fc from 'fast-check';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { DID } from '../../types';
import { ConnectionManager, TransactionType } from '../connections';
import type { DID, RefreshSource } from '../../types';
import {
ConnectionManager,
ConnectionStatus,
getRefreshResult,
TransactionType,
} from '../connections';
import { seal } from '../encryption';

@@ -16,26 +21,28 @@

const arbTx = fc.record({
requestId: fc.option(fc.uuid(), { nil: undefined }),
customer: fc.option(
fc.record({
name: fc.string(),
email: fc.option(fc.string(), { nil: undefined }),
phone: fc.option(fc.string(), { nil: undefined }),
type: fc.constant(undefined), // Optional PersonType
accountNumber: fc.option(fc.string(), { nil: undefined }),
did: fc.option(arbDID, { nil: undefined }),
verified: fc.option(fc.boolean(), { nil: undefined }),
website: fc.option(fc.webUrl(), { nil: undefined }),
geographicAddress: fc.option(fc.constant(undefined), {
nil: undefined,
}),
nationalIdentification: fc.option(fc.constant(undefined), {
nil: undefined,
}),
}),
{ nil: undefined },
),
});
// Test helper to create arbitrary ComponentRequests
const arbComponentRequest = fc.record({
tx: fc.record({
requestId: fc.option(fc.uuid(), { nil: undefined }),
customer: fc.option(
fc.record({
name: fc.string(),
email: fc.option(fc.string(), { nil: undefined }),
phone: fc.option(fc.string(), { nil: undefined }),
type: fc.constant(undefined), // Optional PersonType
accountNumber: fc.option(fc.string(), { nil: undefined }),
did: fc.option(arbDID, { nil: undefined }),
verified: fc.option(fc.boolean(), { nil: undefined }),
website: fc.option(fc.webUrl(), { nil: undefined }),
geographicAddress: fc.option(fc.constant(undefined), {
nil: undefined,
}),
nationalIdentification: fc.option(fc.constant(undefined), {
nil: undefined,
}),
}),
{ nil: undefined },
),
}),
tx: arbTx,
authToken: fc.option(fc.string(), { nil: undefined }),

@@ -302,2 +309,131 @@ txOptions: fc.option(fc.record({}), { nil: undefined }),

});
describe('getRefreshResult', async () => {
// Create test data and sealed object
const tx = { requestId: 'test-123' };
const result = { txCreate: { requestId: 'test-123' } };
const testData = { tx, result };
const sealed = await seal(testData);
// Create a refresh source with the real key
const refreshSource: RefreshSource = {
url: 'https://test-endpoint.com',
key: sealed.key,
};
// Common metadata for all tests
const metadata = {
participants: ['participant1'],
nodeUrl: 'https://node-url.com',
transactionType: 'withdraw' as TransactionType,
};
// Helper function to create mock responses
const createMockResponse = (
status: ConnectionStatus,
sealedData = sealed.ciphertext,
) => ({
id: 'test-id',
metadata,
status,
sealed: [sealedData],
version: 1,
});
it('should return basic data for closed status', async () => {
const mockResponse = createMockResponse('closed');
fetchMock.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
});
const result = await getRefreshResult(refreshSource);
expect(result).toEqual({
id: mockResponse.id,
metadata: mockResponse.metadata,
status: 'closed',
});
});
it('should return data with tx for active status', async () => {
const mockResponse = createMockResponse('active');
fetchMock.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
});
const result = await getRefreshResult(refreshSource);
expect(result).toEqual({
id: mockResponse.id,
metadata: mockResponse.metadata,
status: 'active',
tx,
});
});
it('should return data with result for completed status', async () => {
// Create sealed data with a result
const transactionResponse = { success: true, data: { id: 'test-id' } };
const completedSealed = await seal({
tx: testData,
result: transactionResponse,
});
// Create a refresh source with the new key
const completedRefreshSource: RefreshSource = {
url: 'https://test-endpoint.com',
key: completedSealed.key,
};
const mockResponse = createMockResponse(
'completed',
completedSealed.ciphertext,
);
fetchMock.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
});
const result = await getRefreshResult(completedRefreshSource);
expect(result).toEqual({
id: mockResponse.id,
metadata: mockResponse.metadata,
status: 'completed',
result: transactionResponse,
});
});
it('should throw error when no sealed data is present', async () => {
fetchMock.mockResolvedValueOnce({
ok: true,
json: async () => ({
id: 'test-id',
metadata,
status: 'active' as ConnectionStatus,
sealed: null,
}),
});
await expect(getRefreshResult(refreshSource)).rejects.toThrow(
'Data missing from server response',
);
});
it('should throw error on failed request', async () => {
fetchMock.mockResolvedValueOnce({
ok: false,
text: async () => 'Request failed',
});
await expect(getRefreshResult(refreshSource)).rejects.toThrow(
'Failed to get connection',
);
});
});
});

@@ -37,3 +37,3 @@ import type {

status: ConnectionStatus;
tx: T;
tx?: T;
result?: TransactionResponse<T>;

@@ -55,6 +55,16 @@ }

if (!result.sealed) {
throw new Error('No data found');
if (!result.id || !result.metadata || !result.status || !result.sealed) {
throw new Error('Data missing from server response');
}
const basicData = {
id: result.id,
metadata: result.metadata,
status: result.status,
};
if (result.status === 'closed') {
return basicData;
}
// Get the latest sealed data

@@ -69,8 +79,12 @@ const latestSealed = result.sealed[result.sealed.length - 1];

if (result.status === 'completed') {
return {
...basicData,
result: data.result,
};
}
return {
id: result.id,
metadata: result.metadata,
status: result.status,
...basicData,
tx: data.tx,
result: data.result,
};

@@ -77,0 +91,0 @@ }

Sorry, the diff of this file is not supported yet