@notabene/javascript-sdk 2.0.0-next.18 → 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/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +440 -66
- package/dist/notabene.js +39 -1
- package/package.json +1 -1
- package/src/notabene.ts +77 -23
- package/src/types.ts +411 -40
- package/src/utils/MessageEventManager.ts +60 -1
package/dist/notabene.js
CHANGED
|
@@ -8,16 +8,50 @@ class v {
|
|
|
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
|
}
|
|
@@ -328,6 +365,7 @@ export {
|
|
|
328
365
|
u as AgentType,
|
|
329
366
|
a as CMType,
|
|
330
367
|
w as EmbeddedComponent,
|
|
368
|
+
d as HMType,
|
|
331
369
|
f as PersonType,
|
|
332
370
|
E as ProofStatus,
|
|
333
371
|
g as ProofTypes,
|
package/package.json
CHANGED
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
|
*
|