New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@notabene/javascript-sdk

Package Overview
Dependencies
Maintainers
0
Versions
75
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.7 to 2.0.0-next.8

72

dist/notabene.d.ts

@@ -155,2 +155,4 @@ /**

declare type CryptoCredential = `${string}.${string}.mastercard`;
/**

@@ -176,6 +178,24 @@ * 5.2.7

/**
* An object representing a deposit transaction
* @public
*/
export declare interface Deposit extends OriginatorFields, Transaction {
}
/**
* An object representing a request for a deposit
* @public
*/
export declare interface DepositRequest extends DepositRequestFields, Transaction {
}
declare type DepositRequestFields = {
destinations: destination[];
};
/**
* The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
* @public
*/
export declare type destination = BlockchainAddress | CAIP10 | TravelAddress;
export declare type destination = BlockchainAddress | CAIP10 | CryptoCredential | TravelAddress;

@@ -197,2 +217,3 @@ declare type DID = `did:${string}:${string}`;

private ready;
private modal?;
constructor(url: string, value: Partial<Transaction>);

@@ -204,2 +225,3 @@ get url(): string;

mount(parentId: string): void;
embed(parent: Element): void;
send(message: HostMessage): void;

@@ -210,2 +232,4 @@ on(messageType: string, callback: MessageCallback): void;

completion(): Promise<TransactionResponse>;
openModal(): void;
private closeModal;
}

@@ -439,5 +463,8 @@

constructor(config: NotabeneConfig);
componentUrl(path: string, value: Partial<Transaction>, configuration?: any, callbacks?: CallbackOptions): string;
createComponent(path: string, value: Partial<Transaction>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
createWithdrawalAssist(value: Partial<Withdrawal>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
componentUrl(path: string, value: Partial<Transaction>, configuration?: TransactionOptions, callbacks?: CallbackOptions): string;
createComponent(path: string, value: Partial<Transaction>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent;
createWithdrawalAssist(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent;
createDepositAssist(value: Partial<Deposit>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
createConnect(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent;
createDepositRequest(value: Partial<DepositRequest>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent;
decodeFragmentToObject(fragment: string): Record<string, string>;

@@ -480,2 +507,6 @@ }

declare type OriginatorFields = {
source?: Source;
};
/**

@@ -599,2 +630,4 @@ * Ownership Proof

declare type Source = BlockchainAddress | CAIP10;
/**

@@ -647,2 +680,11 @@ * The verification status of a transaction

/**
* Configuration options for Transaction components
* @public
*/
export declare interface TransactionOptions {
microTransactionAddress?: BlockchainAddress;
proofFallbacks?: ProofTypes[];
}
/**
* The response of a transaction

@@ -658,2 +700,3 @@ * @public

errors: ValidationError[];
txCreate?: V1Transaction;
};

@@ -689,3 +732,3 @@

declare type TravelAddress = string;
declare type TravelAddress = `ta${string}`;

@@ -699,2 +742,21 @@ declare type UpdateValue = {

declare type V1Asset = {
caip19: CAIP19;
} | string;
/**
* Transaction payload suitable for calling Notabene v1 tx/create
* @public
*/
declare type V1Transaction = {
transactionAsset: V1Asset;
transactionAmount: string;
originatorEqualsBeneficiary?: boolean;
originatorVASPdid: DID;
beneficiaryVASPdid: DID;
beneficiaryProof: OwnershipProof;
originator: Originator;
beneficiary: Beneficiary;
};
declare type ValidationError = {

@@ -701,0 +763,0 @@ attribute: string;

178

dist/notabene.js
var d = Object.defineProperty;
var u = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var o = (s, e, t) => u(s, typeof e != "symbol" ? e + "" : e, t);
var h = /* @__PURE__ */ ((s) => (s.COMPLETE = "complete", s.RESIZE = "resize", s.RESULT = "result", s.READY = "ready", s.INVALID = "invalid", s.MODAL = "openModal", s.ERROR = "error", s.CLOSE = "closeModal", s.CANCEL = "cancel", s))(h || {}), c = /* @__PURE__ */ ((s) => (s.UPDATE = "update", s.REQUEST_RESPONSE = "requestResponse", s))(c || {});
var c = (r, e, t) => e in r ? d(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var n = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
var h = /* @__PURE__ */ ((r) => (r.COMPLETE = "complete", r.RESIZE = "resize", r.RESULT = "result", r.READY = "ready", r.INVALID = "invalid", r.MODAL = "openModal", r.ERROR = "error", r.CLOSE = "closeModal", r.CANCEL = "cancel", r))(h || {}), l = /* @__PURE__ */ ((r) => (r.UPDATE = "update", r.REQUEST_RESPONSE = "requestResponse", r))(l || {});
class m {
constructor() {
o(this, "listeners", /* @__PURE__ */ new Map());
o(this, "port");
n(this, "listeners", /* @__PURE__ */ new Map());
n(this, "port");
this.handleMessage = this.handleMessage.bind(this);

@@ -18,4 +18,4 @@ }

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

@@ -26,4 +26,4 @@ handleMessage(e) {

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

@@ -36,14 +36,16 @@ }

}
class f {
class u {
// private popup?: HTMLElement;
constructor(e, t) {
o(this, "_url");
o(this, "_value");
o(this, "_errors", []);
o(this, "iframe");
o(this, "eventManager");
o(this, "ready", !1);
this._url = e, this._value = t, this.eventManager = new m(), this.on(h.INVALID, (r) => {
r.type === h.INVALID && (this._errors = r.errors, this._value = r.value);
}), this.on(h.RESIZE, (r) => {
r.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
n(this, "_url");
n(this, "_value");
n(this, "_errors", []);
n(this, "iframe");
n(this, "eventManager");
n(this, "ready", !1);
n(this, "modal");
this._url = e, this._value = t, this.eventManager = new m(), this.on(h.INVALID, (s) => {
s.type === h.INVALID && (this._errors = s.errors, this._value = s.value);
}), this.on(h.RESIZE, (s) => {
s.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
});

@@ -64,11 +66,13 @@ }

mount(e) {
var r, n;
this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", window.addEventListener("message", (i) => {
var a, l;
i.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && (console.log("received message from iframe", i.data), (l = this.eventManager) == null || l.setPort(i.ports[0]), this.ready = !0);
});
const t = document.querySelector(e);
if (!t) throw new Error(`parentID ${e} not found`);
t.appendChild(this.iframe), (n = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || n.focus();
this.embed(t);
}
embed(e) {
var t, s;
this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("allowtransparency", "true"), this.iframe.style.backgroundColor = "transparent", e.appendChild(this.iframe), window.addEventListener("message", (o) => {
var i, a;
o.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", o.data), (a = this.eventManager) == null || a.setPort(o.ports[0]), this.ready = !0);
}), (s = (t = this.iframe) == null ? void 0 : t.contentWindow) == null || s.focus();
}
send(e) {

@@ -84,56 +88,78 @@ this.eventManager.send(e);

update(e) {
this._value = e, this.send({ type: c.UPDATE, value: e });
this._value = e, this.send({ type: l.UPDATE, value: e });
}
completion() {
return new Promise((e, t) => {
this.on(h.COMPLETE, (r) => {
e(r.response);
}), this.on("error", (r) => {
t(new Error(r.message));
this.closeModal(), this.on(h.COMPLETE, (s) => {
e(s.response);
}), this.on("error", (s) => {
t(new Error(s.message));
});
});
}
// popup(): void {
// this.popup = document.createElement('div');
// this.popup.style;
// }
openModal() {
this.modal && this.closeModal(), this.modal = document.createElement("dialog"), document.body.appendChild(this.modal), this.embed(this.modal), this.modal.show(), this.modal.addEventListener("click", () => {
this.closeModal();
});
}
closeModal() {
var e;
this.modal && (console.log("closeModal"), (e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
}
}
function p(s) {
return Object.entries(s).map(([e, t]) => {
function f(r) {
return Object.entries(r).map(([e, t]) => {
if (!(e && t)) return;
const r = encodeURIComponent(e), n = encodeURIComponent(
const s = encodeURIComponent(e), o = encodeURIComponent(
typeof t == "object" ? JSON.stringify(t) : t
);
return `${r}=${n}`;
return `${s}=${o}`;
}).filter((e) => !!e).join("&");
}
class g {
class E {
constructor(e) {
o(this, "nodeUrl");
o(this, "authToken");
o(this, "uxUrl");
o(this, "theme");
o(this, "locale");
n(this, "nodeUrl");
n(this, "authToken");
n(this, "uxUrl");
n(this, "theme");
n(this, "locale");
this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
}
componentUrl(e, t, r, n) {
componentUrl(e, t, s, o) {
const i = new URL(this.uxUrl);
i.pathname = e;
const a = p({
const a = f({
authToken: this.authToken,
value: t,
configuration: r
configuration: s
});
return i.hash = a, 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), n && (n.callback && i.searchParams.set("callback_url", n.callback), n.redirectUri && i.searchParams.set("redirect_uri", n.redirectUri)), i.toString();
return i.hash = a, 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();
}
createComponent(e, t, r, n) {
return new f(
this.componentUrl(e, t, r, n),
createComponent(e, t, s, o) {
return new u(
this.componentUrl(e, t, s, o),
t
);
}
createWithdrawalAssist(e, t, r) {
return this.createComponent("withdrawal-assist", e, t, r);
createWithdrawalAssist(e, t, s) {
return this.createComponent("withdrawal-assist", e, t, s);
}
createDepositAssist(e, t, s) {
return this.createComponent("deposit-assist", e, t, s);
}
createConnect(e, t, s) {
return this.createComponent("connect", e, t, s);
}
createDepositRequest(e, t, s) {
return this.createComponent("deposit-request", e, t, s);
}
decodeFragmentToObject(e) {
return e.slice(1).split("&").reduce(
(r, n) => {
const [i, a] = n.split("=");
return r[decodeURIComponent(i)] = decodeURIComponent(a), r;
(s, o) => {
const [i, a] = o.split("=");
return s[decodeURIComponent(i)] = decodeURIComponent(a), s;
},

@@ -143,49 +169,5 @@ {}

}
// private openModal(url: string): void {
// if (this.modal) {
// this.closeModal();
// }
// this.modal = document.createElement('div');
// this.modal.style.position = 'fixed';
// this.modal.style.top = '0';
// this.modal.style.left = '0';
// this.modal.style.width = '100%';
// this.modal.style.height = '100%';
// this.modal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
// this.modal.style.display = 'flex';
// this.modal.style.justifyContent = 'center';
// this.modal.style.alignItems = 'center';
// const iframe = document.createElement('iframe');
// iframe.src = url;
// iframe.setAttribute('allowtransparency', 'true');
// // iframe.allowtransparency = true;
// iframe.style.backgroundColor = 'transparent';
// iframe.style.width = '90%';
// iframe.style.height = '90%';
// iframe.style.border = 'none';
// iframe.style.overflow = 'hidden';
// this.modal.appendChild(iframe);
// document.body.appendChild(this.modal);
// this.modal.addEventListener('click', () => {
// console.log('click');
// this.closeModal();
// });
// document.addEventListener('keydown', ({ key }) => {
// console.log(`key: ${key}`);
// if (key === 'Escape') {
// console.log('esc');
// this.closeModal();
// }
// });
// }
// private closeModal(): void {
// if (this.modal) {
// console.log('this.closeModal');
// this.modal.remove();
// this.modal = undefined;
// }
// }
}
export {
g as default
E as default
};

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

"license": "MIT",
"version": "2.0.0-next.7",
"version": "2.0.0-next.8",
"source": "src/notabene.ts",

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

@@ -26,2 +26,4 @@ import {

private ready = false;
private modal?: HTMLDialogElement;
// private popup?: HTMLElement;

@@ -62,2 +64,8 @@ constructor(url: string, value: Partial<Transaction>) {

mount(parentId: string) {
const parent = document.querySelector(parentId);
if (!parent) throw new Error(`parentID ${parentId} not found`);
this.embed(parent);
}
embed(parent: Element) {
this.iframe = document.createElement('iframe');

@@ -69,4 +77,7 @@ this.iframe.src = this.url;

this.iframe.style.overflow = 'hidden';
this.iframe.setAttribute('allowtransparency', 'true');
this.iframe.style.backgroundColor = 'transparent';
parent.appendChild(this.iframe);
window.addEventListener('message', (event) => {
window.addEventListener('message', (event: MessageEvent) => {
if (event.source !== this.iframe?.contentWindow) {

@@ -80,5 +91,2 @@ return;

const parent = document.querySelector(parentId);
if (!parent) throw new Error(`parentID ${parentId} not found`);
parent.appendChild(this.iframe);
this.iframe?.contentWindow?.focus();

@@ -106,2 +114,3 @@ }

return new Promise((resolve, reject) => {
this.closeModal();
this.on(CMType.COMPLETE, (message) => {

@@ -115,2 +124,58 @@ resolve((message as any).response);

}
// popup(): void {
// this.popup = document.createElement('div');
// this.popup.style;
// }
openModal(): void {
if (this.modal) {
this.closeModal();
}
this.modal = document.createElement('dialog');
// this.modal.style.maxWidth = '600px';
// this.modal.style.border = 'none !important';
// this.modal.style.background = 'transparent';
// this.modal.style.flexDirection = 'column';
// this.modal.style.alignItems = 'end';
// const close = document.createElement('button');
// close.innerText = 'X';
// close.style.fontSize = '1rem';
// close.style.padding = '0.25rem 0.5rem';
// close.style.display = 'block';
// close.style.background = 'white';
// close.style.color = '#aaa';
// close.style.border = '#aaa';
// close.addEventListener('click', () => this.closeModal());
// this.modal.appendChild(close);
// this.modal.css;
// this.modal.style.position = 'fixed';
// this.modal.style.bottom = '0';
// this.modal.style.left = '0';
// this.modal.style.right = '0';
// this.modal.style.top = '0';
// this.modal.style.left = '0';
// this.modal.style.width = '100%';
// this.modal.style.height = '100%';
// this.modal.style.backgroundColor = 'transparent';
// this.modal.style.display = 'flex';
// this.modal.style.justifyContent = 'center';
// this.modal.style.alignItems = 'center';
document.body.appendChild(this.modal);
this.embed(this.modal);
this.modal.show();
this.modal.addEventListener('click', () => {
// console.log('click');
this.closeModal();
});
}
private closeModal(): void {
if (this.modal) {
console.log('closeModal');
this.modal?.close();
this.modal.remove();
this.modal = undefined;
}
}
}

@@ -9,2 +9,4 @@ import EmbeddedComponent from './components/EmbeddedComponent';

DeclarationProof,
Deposit,
DepositRequest,
Destination,

@@ -24,2 +26,3 @@ HostMessage,

TransactionAsset,
TransactionOptions,
VASP,

@@ -40,3 +43,5 @@ Wallet,

Withdrawal,
Deposit,
Transaction,
DepositRequest,
TransactionResponse,

@@ -60,2 +65,3 @@ Destination as destination,

OwnershipProof,
TransactionOptions,
};

@@ -100,3 +106,3 @@

value: Partial<Transaction>,
configuration?: any,
configuration?: TransactionOptions,
callbacks?: CallbackOptions,

@@ -133,3 +139,3 @@ ): string {

value: Partial<Transaction>,
options?: any,
options?: TransactionOptions,
callbacks?: CallbackOptions,

@@ -145,3 +151,3 @@ ) {

value: Partial<Withdrawal>,
options?: any,
options?: TransactionOptions,
callbacks?: CallbackOptions,

@@ -152,2 +158,26 @@ ) {

public createDepositAssist(
value: Partial<Deposit>,
options?: any,
callbacks?: CallbackOptions,
) {
return this.createComponent('deposit-assist', value, options, callbacks);
}
public createConnect(
value: Partial<Withdrawal>,
options?: TransactionOptions,
callbacks?: CallbackOptions,
) {
return this.createComponent('connect', value, options, callbacks);
}
public createDepositRequest(
value: Partial<DepositRequest>,
options?: TransactionOptions,
callbacks?: CallbackOptions,
) {
return this.createComponent('deposit-request', value, options, callbacks);
}
public decodeFragmentToObject(fragment: string): Record<string, string> {

@@ -164,48 +194,2 @@ const pairs = fragment.slice(1).split('&');

}
// private openModal(url: string): void {
// if (this.modal) {
// this.closeModal();
// }
// this.modal = document.createElement('div');
// this.modal.style.position = 'fixed';
// this.modal.style.top = '0';
// this.modal.style.left = '0';
// this.modal.style.width = '100%';
// this.modal.style.height = '100%';
// this.modal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
// this.modal.style.display = 'flex';
// this.modal.style.justifyContent = 'center';
// this.modal.style.alignItems = 'center';
// const iframe = document.createElement('iframe');
// iframe.src = url;
// iframe.setAttribute('allowtransparency', 'true');
// // iframe.allowtransparency = true;
// iframe.style.backgroundColor = 'transparent';
// iframe.style.width = '90%';
// iframe.style.height = '90%';
// iframe.style.border = 'none';
// iframe.style.overflow = 'hidden';
// this.modal.appendChild(iframe);
// document.body.appendChild(this.modal);
// this.modal.addEventListener('click', () => {
// console.log('click');
// this.closeModal();
// });
// document.addEventListener('keydown', ({ key }) => {
// console.log(`key: ${key}`);
// if (key === 'Escape') {
// console.log('esc');
// this.closeModal();
// }
// });
// }
// private closeModal(): void {
// if (this.modal) {
// console.log('this.closeModal');
// this.modal.remove();
// this.modal = undefined;
// }
// }
}
import {
Beneficiary,
DateAndPlaceOfBirth,
IVMS101,
NationalIdentification,
Originator,
} from './ivms/types';

@@ -26,3 +28,4 @@

export type BlockchainAddress = string;
export type TravelAddress = string;
export type TravelAddress = `ta${string}`;
export type CryptoCredential = `${string}.${string}.mastercard`;

@@ -33,3 +36,7 @@ /**

*/
export type Destination = BlockchainAddress | CAIP10 | TravelAddress;
export type Destination =
| BlockchainAddress
| CAIP10
| CryptoCredential
| TravelAddress;
export type Source = BlockchainAddress | CAIP10;

@@ -50,6 +57,2 @@ export type URI = string;

export enum ComponentTypes {
WITHDRAW_ASSIST = 'WITHDRAW_ASSIST',
}
// export type TransactionType = 'VASP_2_VASP' | 'SELF_HOSTED';

@@ -166,10 +169,14 @@

export type OriginatorFields = {
type OriginatorFields = {
source?: Source;
};
export type BeneficiaryFields = {
type BeneficiaryFields = {
destination?: Destination;
};
type DepositRequestFields = {
destinations: Destination[];
};
/**

@@ -197,2 +204,3 @@ * An abstract transaction object

export interface Withdrawal extends BeneficiaryFields, Transaction {}
/**

@@ -205,2 +213,18 @@ * An object representing a deposit transaction

/**
* An object representing a request for a deposit
* @public
*/
export interface DepositRequest extends DepositRequestFields, Transaction {}
/**
* Configuration options for Transaction components
* @public
*/
export interface TransactionOptions {
microTransactionAddress?: BlockchainAddress;
proofFallbacks?: ProofTypes[];
}
/**
* The verification status of a transaction

@@ -217,3 +241,24 @@ * @public

type V1Asset =
| {
caip19: CAIP19;
}
| string;
/**
* Transaction payload suitable for calling Notabene v1 tx/create
* @public
*/
export type V1Transaction = {
transactionAsset: V1Asset;
transactionAmount: string;
originatorEqualsBeneficiary?: boolean;
originatorVASPdid: DID;
beneficiaryVASPdid: DID;
beneficiaryProof: OwnershipProof;
originator: Originator;
beneficiary: Beneficiary;
};
/**
* The response of a transaction

@@ -230,2 +275,3 @@ * @public

errors: ValidationError[];
txCreate?: V1Transaction;
};

@@ -255,12 +301,2 @@

export type WalletNotSupportedFlow = {
flow: 'WALLET_NOT_SUPPORTED';
action: 'DECLARATION' | 'REJECT';
};
// This is going to be union type
export type Fallback = WalletNotSupportedFlow;
export type OptInFeature = 'REUSE_ADDRESS_OWNERSHIP_PROOF';
/**

@@ -267,0 +303,0 @@ * Component Message Types

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