@notabene/javascript-sdk 2.0.0-next.17 → 2.0.0-next.19
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/LICENSE.md +21 -0
- package/README.md +19 -0
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +456 -76
- package/dist/notabene.js +62 -16
- package/package.json +1 -1
- package/src/components/EmbeddedComponent.ts +20 -8
- package/src/components/__tests__/EmbeddedComponent.test.ts +61 -16
- package/src/notabene.ts +88 -33
- package/src/types.ts +414 -40
- package/src/utils/MessageEventManager.ts +62 -3
- package/src/utils/__tests__/MessageEventManager.test.ts +12 -4
package/dist/notabene.js
CHANGED
|
@@ -1,23 +1,57 @@
|
|
|
1
1
|
var c = Object.defineProperty;
|
|
2
2
|
var m = (t, e, s) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
3
|
var o = (t, e, s) => m(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
-
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}),
|
|
4
|
+
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), f = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(f || {}), p = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(p || {}), 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 || {}), E = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(E || {}), g = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.PersonalSignEIP191 = "eip-191", t.SIWE = "siwe", t.PersonalSignEIP712 = "eip-712", t.PersonalSignBIP137 = "bip-137", t.PersonalSignXPUB = "xpub", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(g || {});
|
|
5
5
|
class v {
|
|
6
6
|
constructor() {
|
|
7
7
|
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
8
|
o(this, "port");
|
|
9
9
|
this.handleMessage = this.handleMessage.bind(this);
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Sets up the message port for communication.
|
|
13
|
+
*
|
|
14
|
+
* Initializes the MessagePort for receiving messages by setting up the message handler
|
|
15
|
+
* and starting the port.
|
|
16
|
+
*
|
|
17
|
+
* @param port - The MessagePort instance to use for communication
|
|
18
|
+
*/
|
|
11
19
|
setPort(e) {
|
|
12
20
|
this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
|
|
13
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers a callback for a specific message type.
|
|
24
|
+
*
|
|
25
|
+
* When messages of the specified type are received, the callback will be executed
|
|
26
|
+
* with the message data.
|
|
27
|
+
*
|
|
28
|
+
* @param messageType - The type of message to listen for
|
|
29
|
+
* @param callback - The callback function to execute when matching messages are received
|
|
30
|
+
*/
|
|
14
31
|
on(e, s) {
|
|
15
32
|
this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s);
|
|
16
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Removes a callback for a specific message type.
|
|
36
|
+
*
|
|
37
|
+
* If the callback is the last one registered for the message type,
|
|
38
|
+
* the message type entry will be removed entirely.
|
|
39
|
+
*
|
|
40
|
+
* @param messageType - The type of message to remove listener from
|
|
41
|
+
* @param callback - The callback function to remove
|
|
42
|
+
*/
|
|
17
43
|
off(e, s) {
|
|
18
44
|
const r = this.listeners.get(e);
|
|
19
45
|
r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
|
|
20
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Internal message handler for processing received messages.
|
|
49
|
+
*
|
|
50
|
+
* Validates incoming messages and dispatches them to registered callbacks
|
|
51
|
+
* based on the message type.
|
|
52
|
+
*
|
|
53
|
+
* @param event - The message event containing the component message
|
|
54
|
+
*/
|
|
21
55
|
handleMessage(e) {
|
|
22
56
|
const s = e.data;
|
|
23
57
|
if (typeof s == "object" && s !== null && "type" in s) {
|
|
@@ -25,7 +59,10 @@ class v {
|
|
|
25
59
|
i && i.forEach((n) => n(s));
|
|
26
60
|
}
|
|
27
61
|
}
|
|
28
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Sends a message through the message port
|
|
64
|
+
* @param message The host message to send
|
|
65
|
+
*/
|
|
29
66
|
send(e) {
|
|
30
67
|
this.port && this.port.postMessage(e);
|
|
31
68
|
}
|
|
@@ -36,17 +73,18 @@ class w {
|
|
|
36
73
|
* @param url - The URL of the embedded component
|
|
37
74
|
* @param value - The initial transaction value
|
|
38
75
|
*/
|
|
39
|
-
constructor(e, s) {
|
|
76
|
+
constructor(e, s, r) {
|
|
40
77
|
o(this, "_url");
|
|
41
78
|
o(this, "_value");
|
|
79
|
+
o(this, "_options");
|
|
42
80
|
o(this, "_errors", []);
|
|
43
81
|
o(this, "iframe");
|
|
44
82
|
o(this, "eventManager");
|
|
45
83
|
o(this, "modal");
|
|
46
|
-
this._url = e, this._value = s, this.eventManager = new v(), this.on(a.INVALID, (
|
|
47
|
-
|
|
48
|
-
}), this.on(a.RESIZE, (
|
|
49
|
-
|
|
84
|
+
this._url = e, this._value = s, this._options = r, this.eventManager = new v(), this.on(a.INVALID, (i) => {
|
|
85
|
+
i.type === a.INVALID && (this._errors = i.errors, this._value = i.value);
|
|
86
|
+
}), this.on(a.RESIZE, (i) => {
|
|
87
|
+
i.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
|
|
50
88
|
});
|
|
51
89
|
}
|
|
52
90
|
/**
|
|
@@ -63,6 +101,9 @@ class w {
|
|
|
63
101
|
get value() {
|
|
64
102
|
return this._value;
|
|
65
103
|
}
|
|
104
|
+
get options() {
|
|
105
|
+
return this._options;
|
|
106
|
+
}
|
|
66
107
|
get errors() {
|
|
67
108
|
return this._errors;
|
|
68
109
|
}
|
|
@@ -88,11 +129,14 @@ class w {
|
|
|
88
129
|
*/
|
|
89
130
|
embed(e, s = !1) {
|
|
90
131
|
var r, i;
|
|
91
|
-
this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (s ? "" : "&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) => {
|
|
132
|
+
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (s ? "" : "&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) => {
|
|
92
133
|
var h, l;
|
|
93
134
|
n.source === ((h = this.iframe) == null ? void 0 : h.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
|
|
94
135
|
}), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
|
|
95
136
|
}
|
|
137
|
+
removeEmbed() {
|
|
138
|
+
this.iframe && this.iframe.remove();
|
|
139
|
+
}
|
|
96
140
|
/**
|
|
97
141
|
* Sends a message to the embedded component
|
|
98
142
|
* @param message - The message to send
|
|
@@ -120,8 +164,8 @@ class w {
|
|
|
120
164
|
* Updates the transaction value and sends an update message to the component
|
|
121
165
|
* @param value - The new transaction value
|
|
122
166
|
*/
|
|
123
|
-
update(e) {
|
|
124
|
-
this._value = e, this.send({ type: d.UPDATE, value: e });
|
|
167
|
+
update(e, s) {
|
|
168
|
+
this._value = e, s && (this._options = s), this.send({ type: d.UPDATE, value: e, options: this._options });
|
|
125
169
|
}
|
|
126
170
|
/**
|
|
127
171
|
* Waits for the component to complete and returns the transaction response
|
|
@@ -166,7 +210,7 @@ function I(t) {
|
|
|
166
210
|
return `${r}=${i}`;
|
|
167
211
|
}).filter((e) => !!e).join("&");
|
|
168
212
|
}
|
|
169
|
-
class
|
|
213
|
+
class b {
|
|
170
214
|
/**
|
|
171
215
|
* Creates a new instance of the Notabene SDK
|
|
172
216
|
*
|
|
@@ -213,7 +257,8 @@ class R {
|
|
|
213
257
|
createComponent(e, s, r, i) {
|
|
214
258
|
return new w(
|
|
215
259
|
this.componentUrl(e, s, r, i),
|
|
216
|
-
s
|
|
260
|
+
s,
|
|
261
|
+
r
|
|
217
262
|
);
|
|
218
263
|
}
|
|
219
264
|
/**
|
|
@@ -320,9 +365,10 @@ export {
|
|
|
320
365
|
u as AgentType,
|
|
321
366
|
a as CMType,
|
|
322
367
|
w as EmbeddedComponent,
|
|
323
|
-
|
|
324
|
-
|
|
368
|
+
d as HMType,
|
|
369
|
+
f as PersonType,
|
|
370
|
+
E as ProofStatus,
|
|
325
371
|
g as ProofTypes,
|
|
326
|
-
|
|
327
|
-
|
|
372
|
+
p as Status,
|
|
373
|
+
b as default
|
|
328
374
|
};
|
package/package.json
CHANGED
|
@@ -15,13 +15,14 @@ import {
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
export default class EmbeddedComponent<V> {
|
|
18
|
+
export default class EmbeddedComponent<V, O> {
|
|
19
19
|
private _url: string;
|
|
20
20
|
private _value: Partial<V>;
|
|
21
|
+
private _options?: O;
|
|
21
22
|
private _errors: ValidationError[] = [];
|
|
22
23
|
|
|
23
24
|
private iframe?: HTMLIFrameElement;
|
|
24
|
-
private eventManager: MessageEventManager<V>;
|
|
25
|
+
private eventManager: MessageEventManager<V, O>;
|
|
25
26
|
private modal?: HTMLDialogElement;
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -30,10 +31,11 @@ export default class EmbeddedComponent<V> {
|
|
|
30
31
|
* @param value - The initial transaction value
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
|
-
constructor(url: string, value: Partial<V
|
|
34
|
+
constructor(url: string, value: Partial<V>, options?: O) {
|
|
34
35
|
this._url = url;
|
|
35
36
|
this._value = value;
|
|
36
|
-
this.
|
|
37
|
+
this._options = options;
|
|
38
|
+
this.eventManager = new MessageEventManager<V, O>();
|
|
37
39
|
this.on(CMType.INVALID, (message) => {
|
|
38
40
|
if (message.type === CMType.INVALID) {
|
|
39
41
|
this._errors = message.errors;
|
|
@@ -63,6 +65,10 @@ export default class EmbeddedComponent<V> {
|
|
|
63
65
|
return this._value;
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
public get options(): O | undefined {
|
|
69
|
+
return this._options;
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
public get errors(): ValidationError[] {
|
|
67
73
|
return this._errors;
|
|
68
74
|
}
|
|
@@ -86,13 +92,14 @@ export default class EmbeddedComponent<V> {
|
|
|
86
92
|
if (!parent) throw new Error(`parentID ${parentId} not found`);
|
|
87
93
|
this.embed(parent);
|
|
88
94
|
}
|
|
95
|
+
|
|
89
96
|
/**
|
|
90
97
|
* Embeds the component into a parent element
|
|
91
98
|
* @param parent - The parent element to embed the component into
|
|
92
99
|
*/
|
|
93
|
-
|
|
94
100
|
embed(parent: Element, modal: boolean = false) {
|
|
95
101
|
// console.log(this.url);
|
|
102
|
+
this.removeEmbed();
|
|
96
103
|
this.iframe = document.createElement('iframe');
|
|
97
104
|
this.iframe.src = this.url + (!modal ? '&embedded=true' : '');
|
|
98
105
|
this.iframe.allow = 'web-share';
|
|
@@ -115,11 +122,15 @@ export default class EmbeddedComponent<V> {
|
|
|
115
122
|
this.iframe?.contentWindow?.focus();
|
|
116
123
|
}
|
|
117
124
|
|
|
125
|
+
removeEmbed() {
|
|
126
|
+
if (this.iframe) this.iframe.remove();
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
/**
|
|
119
130
|
* Sends a message to the embedded component
|
|
120
131
|
* @param message - The message to send
|
|
121
132
|
*/
|
|
122
|
-
send(message: HostMessage<V>): void {
|
|
133
|
+
send(message: HostMessage<V, O>): void {
|
|
123
134
|
this.eventManager.send(message);
|
|
124
135
|
}
|
|
125
136
|
|
|
@@ -147,9 +158,10 @@ export default class EmbeddedComponent<V> {
|
|
|
147
158
|
* Updates the transaction value and sends an update message to the component
|
|
148
159
|
* @param value - The new transaction value
|
|
149
160
|
*/
|
|
150
|
-
update(value: Partial<V
|
|
161
|
+
update(value: Partial<V>, options?: O) {
|
|
151
162
|
this._value = value;
|
|
152
|
-
|
|
163
|
+
if (options) this._options = options;
|
|
164
|
+
this.send({ type: HMType.UPDATE, value, options: this._options });
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
/**
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
2
|
import {
|
|
3
|
+
AgentType,
|
|
3
4
|
CMType,
|
|
4
5
|
HMType,
|
|
5
|
-
HostMessage,
|
|
6
|
-
Transaction,
|
|
7
|
-
|
|
6
|
+
type HostMessage,
|
|
7
|
+
type Transaction,
|
|
8
|
+
type TransactionOptions,
|
|
9
|
+
type Withdrawal,
|
|
8
10
|
} from '../../types';
|
|
9
11
|
import EmbeddedComponent from '../EmbeddedComponent';
|
|
10
12
|
|
|
@@ -14,9 +16,9 @@ const value: Partial<Transaction> = { amountDecimal: 100 };
|
|
|
14
16
|
|
|
15
17
|
describe('EmbeddedComponent', () => {
|
|
16
18
|
describe('creation', () => {
|
|
17
|
-
let component: EmbeddedComponent<Withdrawal>;
|
|
19
|
+
let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
|
|
18
20
|
beforeEach(() => {
|
|
19
|
-
component = new EmbeddedComponent<Withdrawal>(url, {
|
|
21
|
+
component = new EmbeddedComponent<Withdrawal, TransactionOptions>(url, {
|
|
20
22
|
amountDecimal: 100,
|
|
21
23
|
});
|
|
22
24
|
});
|
|
@@ -68,14 +70,20 @@ describe('EmbeddedComponent', () => {
|
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
test('mount', () => {
|
|
71
|
-
const component = new EmbeddedComponent<Withdrawal>(
|
|
73
|
+
const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
|
|
74
|
+
url,
|
|
75
|
+
value,
|
|
76
|
+
);
|
|
72
77
|
component.mount(parentId);
|
|
73
78
|
expect(iframe?.src).toBe(url + '&embedded=true');
|
|
74
79
|
expect(parentElement.appendChild).toHaveBeenCalledWith(iframe);
|
|
75
80
|
});
|
|
76
81
|
|
|
77
82
|
test('on', () => {
|
|
78
|
-
const component = new EmbeddedComponent<Withdrawal>(
|
|
83
|
+
const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
|
|
84
|
+
url,
|
|
85
|
+
value,
|
|
86
|
+
);
|
|
79
87
|
const messageType = 'customEvent';
|
|
80
88
|
const callback = vi.fn();
|
|
81
89
|
component.on(messageType, callback);
|
|
@@ -86,7 +94,10 @@ describe('EmbeddedComponent', () => {
|
|
|
86
94
|
});
|
|
87
95
|
|
|
88
96
|
test('off', () => {
|
|
89
|
-
const component = new EmbeddedComponent<Withdrawal>(
|
|
97
|
+
const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
|
|
98
|
+
url,
|
|
99
|
+
value,
|
|
100
|
+
);
|
|
90
101
|
const messageType = 'customEvent';
|
|
91
102
|
const callback = vi.fn();
|
|
92
103
|
component.on(messageType, callback);
|
|
@@ -104,7 +115,8 @@ describe('EmbeddedComponent', () => {
|
|
|
104
115
|
let messageHandler: (event: MessageEvent) => void;
|
|
105
116
|
let port: MessagePort;
|
|
106
117
|
let handshake: MessageEvent;
|
|
107
|
-
let component: EmbeddedComponent<Withdrawal>;
|
|
118
|
+
let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
|
|
119
|
+
let options: TransactionOptions;
|
|
108
120
|
|
|
109
121
|
beforeEach(() => {
|
|
110
122
|
port = {
|
|
@@ -121,7 +133,12 @@ describe('EmbeddedComponent', () => {
|
|
|
121
133
|
.mockImplementation((event, handler) => {
|
|
122
134
|
messageHandler = handler;
|
|
123
135
|
});
|
|
124
|
-
|
|
136
|
+
options = { allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP] };
|
|
137
|
+
component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
|
|
138
|
+
url,
|
|
139
|
+
value,
|
|
140
|
+
options,
|
|
141
|
+
);
|
|
125
142
|
component.mount(parentId);
|
|
126
143
|
|
|
127
144
|
expect(messageHandler).toBeDefined();
|
|
@@ -129,23 +146,51 @@ describe('EmbeddedComponent', () => {
|
|
|
129
146
|
});
|
|
130
147
|
|
|
131
148
|
test('send', () => {
|
|
132
|
-
const message: HostMessage<Withdrawal> = {
|
|
149
|
+
const message: HostMessage<Withdrawal, TransactionOptions> = {
|
|
133
150
|
type: HMType.UPDATE,
|
|
134
151
|
value: {
|
|
135
152
|
requestId: 'id',
|
|
136
153
|
},
|
|
154
|
+
options: { allowedAgentTypes: [AgentType.PRIVATE] },
|
|
137
155
|
};
|
|
138
156
|
component.send(message);
|
|
139
157
|
expect(port.postMessage).toHaveBeenCalledWith(message);
|
|
140
158
|
});
|
|
141
159
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
describe('update', () => {
|
|
161
|
+
test('with out options', () => {
|
|
162
|
+
const newValue: Partial<Transaction> = { amountDecimal: 200 };
|
|
145
163
|
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
const message: HostMessage<Withdrawal, TransactionOptions> = {
|
|
165
|
+
type: HMType.UPDATE,
|
|
166
|
+
value: newValue,
|
|
167
|
+
options,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
component.update(newValue);
|
|
171
|
+
|
|
172
|
+
expect(component.value).toBe(newValue);
|
|
173
|
+
expect(component.options).toBe(options);
|
|
174
|
+
expect(port.postMessage).toHaveBeenCalledWith(message);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('with options', () => {
|
|
178
|
+
const newValue: Partial<Transaction> = { amountDecimal: 200 };
|
|
179
|
+
const newOptions = { allowedAgentTypes: [AgentType.PRIVATE] };
|
|
148
180
|
|
|
181
|
+
const message: HostMessage<Withdrawal, TransactionOptions> = {
|
|
182
|
+
type: HMType.UPDATE,
|
|
183
|
+
value: newValue,
|
|
184
|
+
options: newOptions,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
component.update(newValue, newOptions);
|
|
188
|
+
|
|
189
|
+
expect(component.value).toBe(newValue);
|
|
190
|
+
expect(component.options).toBe(newOptions);
|
|
191
|
+
expect(port.postMessage).toHaveBeenCalledWith(message);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
149
194
|
// TODO not sure this actually does what I want it to do
|
|
150
195
|
test('completion', async () => {
|
|
151
196
|
const response = { valid: true, value: 'completed' };
|
package/src/notabene.ts
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
import EmbeddedComponent from './components/EmbeddedComponent';
|
|
2
2
|
import type {
|
|
3
3
|
Agent,
|
|
4
|
+
BlockchainAddress,
|
|
5
|
+
CAIP10,
|
|
6
|
+
CAIP19,
|
|
7
|
+
CAIP2,
|
|
4
8
|
CallbackOptions,
|
|
9
|
+
Cancel,
|
|
10
|
+
Completed,
|
|
5
11
|
ComponentMessage,
|
|
12
|
+
ComponentResponse,
|
|
6
13
|
ConnectionRequest,
|
|
7
14
|
Counterparty,
|
|
15
|
+
CryptoCredential,
|
|
8
16
|
DeclarationProof,
|
|
9
17
|
Deposit,
|
|
10
18
|
DepositRequest,
|
|
11
19
|
Destination,
|
|
20
|
+
DID,
|
|
21
|
+
DTI,
|
|
22
|
+
Error,
|
|
23
|
+
FieldTypes,
|
|
12
24
|
HostMessage,
|
|
25
|
+
InvalidValue,
|
|
13
26
|
IVMS101,
|
|
27
|
+
LegalPerson,
|
|
28
|
+
LEI,
|
|
14
29
|
MicroTransferProof,
|
|
30
|
+
NationalIdentification,
|
|
31
|
+
NaturalPerson,
|
|
32
|
+
NotabeneAsset,
|
|
15
33
|
OwnershipProof,
|
|
34
|
+
Ready,
|
|
35
|
+
ResizeRequest,
|
|
16
36
|
ScreenshotProof,
|
|
17
37
|
SignatureProof,
|
|
18
38
|
Theme,
|
|
@@ -20,55 +40,89 @@ import type {
|
|
|
20
40
|
TransactionAsset,
|
|
21
41
|
TransactionOptions,
|
|
22
42
|
TransactionResponse,
|
|
43
|
+
TravelAddress,
|
|
44
|
+
UpdateValue,
|
|
45
|
+
V1Transaction,
|
|
46
|
+
ValidationError,
|
|
23
47
|
VASP,
|
|
48
|
+
VASPOptions,
|
|
24
49
|
Wallet,
|
|
25
50
|
Withdrawal,
|
|
26
51
|
} from './types';
|
|
27
52
|
import {
|
|
28
53
|
AgentType,
|
|
29
54
|
CMType,
|
|
55
|
+
HMType,
|
|
30
56
|
PersonType,
|
|
31
57
|
ProofStatus,
|
|
32
58
|
ProofTypes,
|
|
33
59
|
Status,
|
|
34
60
|
} from './types';
|
|
61
|
+
import { type MessageCallback } from './utils/MessageEventManager';
|
|
35
62
|
import { encodeObjectToFragment } from './utils/urls';
|
|
36
|
-
|
|
37
63
|
// Must be exported for React Native SDK to use
|
|
38
64
|
export { default as EmbeddedComponent } from './components/EmbeddedComponent';
|
|
39
65
|
export type {
|
|
66
|
+
Agent,
|
|
67
|
+
BlockchainAddress,
|
|
68
|
+
CAIP2,
|
|
69
|
+
CAIP10,
|
|
70
|
+
CAIP19,
|
|
71
|
+
CryptoCredential,
|
|
72
|
+
TravelAddress,
|
|
73
|
+
NotabeneAsset,
|
|
74
|
+
DTI,
|
|
75
|
+
VASPOptions,
|
|
76
|
+
NationalIdentification,
|
|
77
|
+
FieldTypes,
|
|
78
|
+
DID,
|
|
79
|
+
MessageCallback,
|
|
80
|
+
CallbackOptions,
|
|
81
|
+
Cancel,
|
|
82
|
+
Completed,
|
|
40
83
|
ComponentMessage,
|
|
84
|
+
ComponentResponse,
|
|
41
85
|
ConnectionRequest,
|
|
42
|
-
HostMessage,
|
|
43
|
-
Theme,
|
|
44
86
|
Counterparty,
|
|
45
|
-
|
|
87
|
+
DeclarationProof,
|
|
46
88
|
Deposit,
|
|
47
|
-
Transaction,
|
|
48
89
|
DepositRequest,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ScreenshotProof,
|
|
54
|
-
MicroTransferProof,
|
|
55
|
-
DeclarationProof,
|
|
56
|
-
Notabene,
|
|
90
|
+
Destination,
|
|
91
|
+
Error,
|
|
92
|
+
HostMessage,
|
|
93
|
+
InvalidValue,
|
|
57
94
|
IVMS101,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
LegalPerson,
|
|
96
|
+
LEI,
|
|
97
|
+
MicroTransferProof,
|
|
98
|
+
NaturalPerson,
|
|
61
99
|
OwnershipProof,
|
|
100
|
+
Ready,
|
|
101
|
+
ResizeRequest,
|
|
102
|
+
ScreenshotProof,
|
|
103
|
+
SignatureProof,
|
|
104
|
+
Theme,
|
|
105
|
+
Transaction,
|
|
106
|
+
TransactionAsset,
|
|
62
107
|
TransactionOptions,
|
|
63
|
-
|
|
108
|
+
TransactionResponse,
|
|
109
|
+
UpdateValue,
|
|
110
|
+
V1Transaction,
|
|
111
|
+
ValidationError,
|
|
112
|
+
VASP,
|
|
113
|
+
Wallet,
|
|
114
|
+
Withdrawal,
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
CMType,
|
|
118
|
+
HMType,
|
|
119
|
+
ProofStatus,
|
|
120
|
+
ProofTypes,
|
|
121
|
+
PersonType,
|
|
122
|
+
Status,
|
|
123
|
+
AgentType,
|
|
64
124
|
};
|
|
65
|
-
export { CMType, ProofStatus, ProofTypes, PersonType, Status, AgentType };
|
|
66
125
|
|
|
67
|
-
/**
|
|
68
|
-
* Configuration for the Notabene SDK
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
126
|
/**
|
|
73
127
|
* Configuration for the Notabene SDK
|
|
74
128
|
*
|
|
@@ -139,10 +193,10 @@ export default class Notabene {
|
|
|
139
193
|
* @returns component URL
|
|
140
194
|
* @internal
|
|
141
195
|
*/
|
|
142
|
-
componentUrl<V>(
|
|
196
|
+
componentUrl<V, O>(
|
|
143
197
|
path: string,
|
|
144
198
|
value: V,
|
|
145
|
-
configuration?:
|
|
199
|
+
configuration?: O,
|
|
146
200
|
callbacks?: CallbackOptions,
|
|
147
201
|
): string {
|
|
148
202
|
const url = new URL(this.uxUrl);
|
|
@@ -181,15 +235,16 @@ export default class Notabene {
|
|
|
181
235
|
* @returns A new EmbeddedComponent instance
|
|
182
236
|
* @internal
|
|
183
237
|
*/
|
|
184
|
-
createComponent<V>(
|
|
238
|
+
createComponent<V, O>(
|
|
185
239
|
path: string,
|
|
186
240
|
value: Partial<V>,
|
|
187
|
-
options?:
|
|
241
|
+
options?: O,
|
|
188
242
|
callbacks?: CallbackOptions,
|
|
189
243
|
) {
|
|
190
|
-
return new EmbeddedComponent<V>(
|
|
244
|
+
return new EmbeddedComponent<V, O>(
|
|
191
245
|
this.componentUrl(path, value, options, callbacks),
|
|
192
246
|
value,
|
|
247
|
+
options,
|
|
193
248
|
);
|
|
194
249
|
}
|
|
195
250
|
|
|
@@ -206,7 +261,7 @@ export default class Notabene {
|
|
|
206
261
|
options?: TransactionOptions,
|
|
207
262
|
callbacks?: CallbackOptions,
|
|
208
263
|
) {
|
|
209
|
-
return this.createComponent<Withdrawal>(
|
|
264
|
+
return this.createComponent<Withdrawal, TransactionOptions>(
|
|
210
265
|
'withdrawal-assist',
|
|
211
266
|
value,
|
|
212
267
|
options,
|
|
@@ -228,7 +283,7 @@ export default class Notabene {
|
|
|
228
283
|
options?: TransactionOptions,
|
|
229
284
|
callbacks?: CallbackOptions,
|
|
230
285
|
) {
|
|
231
|
-
return this.createComponent<Withdrawal>(
|
|
286
|
+
return this.createComponent<Withdrawal, TransactionOptions>(
|
|
232
287
|
'wallet-assist',
|
|
233
288
|
value,
|
|
234
289
|
options,
|
|
@@ -250,7 +305,7 @@ export default class Notabene {
|
|
|
250
305
|
options?: any,
|
|
251
306
|
callbacks?: CallbackOptions,
|
|
252
307
|
) {
|
|
253
|
-
return this.createComponent<Deposit>(
|
|
308
|
+
return this.createComponent<Deposit, any>(
|
|
254
309
|
'deposit-assist',
|
|
255
310
|
value,
|
|
256
311
|
options,
|
|
@@ -272,7 +327,7 @@ export default class Notabene {
|
|
|
272
327
|
options?: TransactionOptions,
|
|
273
328
|
callbacks?: CallbackOptions,
|
|
274
329
|
) {
|
|
275
|
-
return this.createComponent<ConnectionRequest>(
|
|
330
|
+
return this.createComponent<ConnectionRequest, TransactionOptions>(
|
|
276
331
|
'connect',
|
|
277
332
|
value,
|
|
278
333
|
options,
|
|
@@ -294,7 +349,7 @@ export default class Notabene {
|
|
|
294
349
|
options?: TransactionOptions,
|
|
295
350
|
callbacks?: CallbackOptions,
|
|
296
351
|
) {
|
|
297
|
-
return this.createComponent<DepositRequest>(
|
|
352
|
+
return this.createComponent<DepositRequest, TransactionOptions>(
|
|
298
353
|
'deposit-request',
|
|
299
354
|
value,
|
|
300
355
|
options,
|