Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@notabene/javascript-sdk

Package Overview
Dependencies
Maintainers
0
Versions
73
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 2.0.0-next.21 to 2.0.0-next.22

2

dist/notabene.d.ts

@@ -480,3 +480,3 @@ /**

*/
on(messageType: string, callback: MessageCallback<V>): void;
on(messageType: string, callback: MessageCallback<V>): () => void;
/**

@@ -483,0 +483,0 @@ * Removes an event listener for a specific message type

var c = Object.defineProperty;
var m = (t, e, r) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var o = (t, e, r) => m(t, typeof e != "symbol" ? e + "" : e, r);
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), E = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(E || {}), p = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(p || {}), f = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(f || {}), a = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(a || {}), d = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(d || {}), g = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(g || {}), v = /* @__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.BIP137_XPUB = "xpub", t.ED25519 = "ed25519", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(v || {});
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), E = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(E || {}), f = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(f || {}), p = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(p || {}), h = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(h || {}), d = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(d || {}), v = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(v || {}), g = /* @__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.BIP137_XPUB = "xpub", t.ED25519 = "ed25519", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(g || {});
class I {

@@ -23,12 +23,13 @@ constructor() {

/**
* Registers a callback for a specific message type.
*
* When messages of the specified type are received, the callback will be executed
* with the message data.
*
* @param messageType - The type of message to listen for
* @param callback - The callback function to execute when matching messages are received
*/
* Registers a callback for a specific message type.
*
* When messages of the specified type are received, the callback will be executed
* with the message data.
*
* @param messageType - The type of message to listen for
* @param callback - The callback function to execute when matching messages are received
*/
on(e, r) {
this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r);
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), () => this.off(e, r);
}

@@ -85,6 +86,6 @@ /**

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

@@ -135,4 +136,4 @@ }

this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (n) => {
var h, l;
n.source === ((h = this.iframe) == null ? void 0 : h.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
var a, l;
n.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
}), (i = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || i.focus();

@@ -156,3 +157,3 @@ }

on(e, r) {
this.eventManager.on(e, r);
return this.eventManager.on(e, r);
}

@@ -180,6 +181,10 @@ /**

return new Promise((e, r) => {
this.on(a.COMPLETE, (s) => {
e(s.response);
}), this.on("error", (s) => {
r(new Error(s.message));
let s, i;
function n() {
s && s(), i && i();
}
s = this.on(h.COMPLETE, (a) => {
e(a.response), n();
}), i = this.on("error", (a) => {
r(new Error(a.message)), n();
});

@@ -192,5 +197,5 @@ });

openModal() {
return this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0), this.on(a.CANCEL, () => {
return this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0), this.on(h.CANCEL, () => {
this.closeModal();
}), this.on(a.COMPLETE, () => {
}), this.on(h.COMPLETE, () => {
this.closeModal();

@@ -219,3 +224,3 @@ }), this.modal.showModal(), this.modal.addEventListener("click", () => {

}
class b {
class A {
/**

@@ -247,3 +252,3 @@ * Creates a new instance of the Notabene SDK

n.pathname = e;
const h = U({
const a = U({
authToken: this.authToken,

@@ -253,3 +258,3 @@ value: r,

});
return n.hash = h, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
return n.hash = a, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
}

@@ -349,4 +354,4 @@ /**

(s, i) => {
const [n, h] = i.split("=");
return s[decodeURIComponent(n)] = decodeURIComponent(h), s;
const [n, a] = i.split("=");
return s[decodeURIComponent(n)] = decodeURIComponent(a), s;
},

@@ -359,11 +364,11 @@ {}

u as AgentType,
a as CMType,
h as CMType,
w as EmbeddedComponent,
d as HMType,
E as PersonType,
g as ProofStatus,
v as ProofTypes,
p as Status,
f as ValidationSections,
b as default
v as ProofStatus,
g as ProofTypes,
f as Status,
p as ValidationSections,
A as default
};

@@ -12,3 +12,3 @@ {

"license": "MIT",
"version": "2.0.0-next.21",
"version": "2.0.0-next.22",
"source": "src/notabene.ts",

@@ -15,0 +15,0 @@ "main": "dist/notabene.js",

@@ -110,3 +110,3 @@ <div align="center">

const withdrawal = notabene.createWithdrawalAssist(tx, options);
withdrawal.mount('nb-withdrawal');
withdrawal.mount('#nb-withdrawal');
```

@@ -146,3 +146,3 @@

To be notified of any errors use:
To be notified of any validation errors use:

@@ -153,2 +153,12 @@ ```js

Calling `on` returns a function that will allow you to cleanly unsubscribe.
```js
const unsubscribe = withdrawal.on('complete', { valid, value, txCreate, ivms101, proof } => ...)
// Clean up
unsubscribe()
```
### Linked Component

@@ -269,3 +279,3 @@

All components can be configured using an optional [TransactionOptions](./docs/interfaces/TransactionOptions.md) object.
All components can be configured using an optional [TransactionOptions](./docs/types/interfaces/TransactionOptions.md) object.

@@ -447,3 +457,2 @@ The following shows the full set of options in typescript:

- `{ optional: true }` show but don't require
- `{ transmit: true }` Include in beneficiary field of IVMS101 to be transmitted to counterparty

@@ -502,15 +511,15 @@ Eg:

| Field name | Natural | Legal | IVMS101 | Transmitted | description |
| ------------------------ | ------- | ----- | ------- | ----------- | --------------------------------------------- |
| `name` | ✅ | ✅ | ✅ | ✅ | Full name |
| `email` | 🟩 | 🟩 | -- | -- | Email (for your internal purposes) |
| `website` | -- | ✅ | -- | -- | Business Website (for your internal purposes) |
| `phone` | 🟩 | 🟩 | -- | -- | Mobile Phone (for your internal purposes) |
| `geographicAddress` | 🟩 | 🟩 | ✅ | 🟩 | Residencial or business address |
| `nationalIdentification` | 🟩 | 🟩 | ✅ | 🟩 | National Identification number |
| `dateOfBirth` | 🟩 | -- | ✅ | 🟩 | Date of birth |
| `placeOfBirth` | 🟩 | -- | ✅ | 🟩 | Place of birth |
| `countryOfResidence` | 🟩 | -- | ✅ | 🟩 | Country of Residence |
| `lei` | -- | ✅ | ✅ | ✅ | LEI (Legal Entity Identifier) |
| `countryOfRegistration` | -- | 🟩 | ✅ | 🟩 | Country of Registration |
| Field name | Natural | Legal | IVMS101 | description |
| ------------------------ | ------- | ----- | ------- | --------------------------------------------- |
| `name` | ✅ | ✅ | 🟩 | Full name |
| `email` | 🟩 | 🟩 | -- | Email (for your internal purposes) |
| `website` | -- | ✅ | -- | Business Website (for your internal purposes) |
| `phone` | 🟩 | 🟩 | -- | Mobile Phone (for your internal purposes) |
| `geographicAddress` | 🟩 | 🟩 | 🟩 | Residencial or business address |
| `nationalIdentification` | 🟩 | 🟩 | 🟩 | National Identification number |
| `dateOfBirth` | 🟩 | -- | 🟩 | Date of birth |
| `placeOfBirth` | 🟩 | -- | 🟩 | Place of birth |
| `countryOfResidence` | 🟩 | -- | 🟩 | Country of Residence |
| `lei` | -- | ✅ | 🟩 | LEI (Legal Entity Identifier) |
| `countryOfRegistration` | -- | 🟩 | 🟩 | Country of Registration |

@@ -517,0 +526,0 @@ ## Locales

@@ -195,17 +195,41 @@ import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';

// TODO not sure this actually does what I want it to do
test('completion', async () => {
const response = { valid: true, value: 'completed' };
expect(port.onmessage).toBeDefined();
describe('completion', () => {
test('resolves with response and cleans up listeners', async () => {
const response = { valid: true, value: 'completed' };
const completionPromise = component.completion();
const promise = component.completion();
// @ts-expect-error - we've already verified that port exists
port.onmessage({
data: { type: CMType.COMPLETE, response },
});
port.onmessage!({
data: { type: CMType.COMPLETE, response },
} as unknown as MessageEvent);
promise.then((result) => {
const result = await completionPromise;
expect(result).toBe(response);
// Verify cleanup by sending another complete message - should not trigger anything
port.onmessage!({
data: { type: CMType.COMPLETE, response: { valid: false } },
} as unknown as MessageEvent);
// Original result should remain unchanged
expect(result).toBe(response);
});
return promise;
// Assert that the completion promise resolves with the expected response.
test('rejects with error and cleans up listeners', async () => {
const errorMessage = 'Test error';
const completionPromise = component.completion();
port.onmessage!({
data: { type: 'error', message: errorMessage },
} as unknown as MessageEvent);
await expect(completionPromise).rejects.toThrow(errorMessage);
// Verify cleanup by sending another error - should not trigger anything
port.onmessage!({
data: { type: 'error', message: 'Different error' },
} as unknown as MessageEvent);
// Original rejection should remain
await expect(completionPromise).rejects.toThrow(errorMessage);
});
});

@@ -212,0 +236,0 @@ });

@@ -143,4 +143,4 @@ import {

on(messageType: string, callback: MessageCallback<V>): void {
this.eventManager.on(messageType, callback);
on(messageType: string, callback: MessageCallback<V>): () => void {
return this.eventManager.on(messageType, callback);
}

@@ -175,7 +175,15 @@

return new Promise((resolve, reject) => {
this.on(CMType.COMPLETE, (message) => {
let removeComplete: undefined | (() => void) = undefined;
let removeError: undefined | (() => void) = undefined;
function cleanup() {
if (removeComplete) removeComplete();
if (removeError) removeError();
}
removeComplete = this.on(CMType.COMPLETE, (message) => {
resolve((message as any).response);
cleanup();
});
this.on('error', (message) => {
removeError = this.on('error', (message) => {
reject(new Error((message as any).message));
cleanup();
});

@@ -182,0 +190,0 @@ });

@@ -429,3 +429,3 @@ import {

type LegalPersonFieldName =
export type LegalPersonFieldName =
| 'name' // Full legal name

@@ -432,0 +432,0 @@ | 'lei' // Legal Entity Identifier

@@ -102,3 +102,19 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';

});
it('on returns unsubscribe function', () => {
const messageType = 'customEvent';
const callback = vi.fn();
const unsubscribe = messageEventManager.on(messageType, callback);
// Verify it's a function
expect(typeof unsubscribe).toBe('function');
// Call it and verify the handler is removed
unsubscribe();
// Simulate a message - callback should not be called
mockPort.onmessage!({ data: { type: messageType } } as MessageEvent);
expect(callback).not.toHaveBeenCalled();
});
});
});

@@ -54,5 +54,6 @@ import { ComponentMessage, HostMessage } from '../types';

* @param callback - The callback function to execute when matching messages are received
*/
on(messageType: string, callback: MessageCallback<T>): void {
on(messageType: string, callback: MessageCallback<T>): () => void {
if (!this.listeners.has(messageType)) {

@@ -62,2 +63,3 @@ this.listeners.set(messageType, new Set());

this.listeners.get(messageType)!.add(callback);
return () => this.off(messageType, callback);
}

@@ -64,0 +66,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc