@notabene/javascript-sdk 2.0.0-next.2 → 2.0.0-next.20
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 +281 -231
- package/dist/js/notabene.js +1 -0
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +1052 -209
- package/dist/notabene.js +275 -105
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +36 -26
- package/src/__tests__/notabene.test.ts +43 -0
- package/src/components/EmbeddedComponent.ts +141 -22
- package/src/components/__tests__/EmbeddedComponent.test.ts +73 -20
- package/src/ivms/types.ts +230 -152
- package/src/locales.ts +47 -0
- package/src/notabene.ts +243 -90
- package/src/types.ts +723 -144
- package/src/utils/MessageEventManager.ts +70 -12
- package/src/utils/__tests__/MessageEventManager.test.ts +13 -5
- package/src/utils/arbitraries.ts +9 -4
- package/.editorconfig +0 -10
- package/.gitlab-ci.yml +0 -85
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.prettierrc +0 -4
- package/.releaserc.json +0 -16
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -11
- package/.yarn/releases/yarn-berry.cjs +0 -925
- package/.yarnrc.yml +0 -3
- package/CODEOWNERS +0 -1
- package/api-extractor.json +0 -434
- package/eslint.config.js +0 -24
- package/etc/javascript-sdk.api.md +0 -363
- package/index.html +0 -137
- package/temp/javascript-sdk.api.json +0 -3509
- package/temp/javascript-sdk.api.md +0 -363
- package/ts-out/src/__tests__/notabene.test.d.ts +0 -1
- package/ts-out/src/__tests__/notabene.test.js +0 -88
- package/ts-out/src/arbitraries.d.ts +0 -4
- package/ts-out/src/arbitraries.js +0 -8
- package/ts-out/src/components/EmbeddedComponent.d.ts +0 -25
- package/ts-out/src/components/EmbeddedComponent.js +0 -87
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +0 -1
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +0 -132
- package/ts-out/src/ivms/types.d.ts +0 -252
- package/ts-out/src/ivms/types.js +0 -1
- package/ts-out/src/notabene.d.ts +0 -35
- package/ts-out/src/notabene.js +0 -59
- package/ts-out/src/types.d.ts +0 -357
- package/ts-out/src/types.js +0 -85
- package/ts-out/src/utils/MessageEventManager.d.ts +0 -12
- package/ts-out/src/utils/MessageEventManager.js +0 -45
- package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +0 -1
- package/ts-out/src/utils/__tests__/MessageEventManager.test.js +0 -73
- package/ts-out/src/utils/arbitraries.d.ts +0 -6
- package/ts-out/src/utils/arbitraries.js +0 -7
- package/ts-out/src/utils/caip.d.ts +0 -13
- package/ts-out/src/utils/caip.js +0 -15
- package/ts-out/src/utils/urls.d.ts +0 -1
- package/ts-out/src/utils/urls.js +0 -14
- package/ts-out/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.json +0 -22
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.js +0 -13
package/src/notabene.ts
CHANGED
|
@@ -1,59 +1,126 @@
|
|
|
1
1
|
import EmbeddedComponent from './components/EmbeddedComponent';
|
|
2
2
|
import type {
|
|
3
3
|
Agent,
|
|
4
|
-
|
|
4
|
+
BlockchainAddress,
|
|
5
|
+
CAIP10,
|
|
6
|
+
CAIP19,
|
|
7
|
+
CAIP2,
|
|
5
8
|
CallbackOptions,
|
|
9
|
+
Cancel,
|
|
10
|
+
Completed,
|
|
6
11
|
ComponentMessage,
|
|
12
|
+
ComponentResponse,
|
|
13
|
+
ConnectionRequest,
|
|
7
14
|
Counterparty,
|
|
15
|
+
CryptoCredential,
|
|
8
16
|
DeclarationProof,
|
|
17
|
+
Deposit,
|
|
18
|
+
DepositRequest,
|
|
9
19
|
Destination,
|
|
20
|
+
DID,
|
|
21
|
+
DTI,
|
|
22
|
+
Error,
|
|
23
|
+
FieldTypes,
|
|
10
24
|
HostMessage,
|
|
25
|
+
InvalidValue,
|
|
11
26
|
IVMS101,
|
|
27
|
+
LegalPerson,
|
|
28
|
+
LEI,
|
|
12
29
|
MicroTransferProof,
|
|
30
|
+
NationalIdentification,
|
|
31
|
+
NaturalPerson,
|
|
32
|
+
NotabeneAsset,
|
|
13
33
|
OwnershipProof,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ProofTypes,
|
|
34
|
+
Ready,
|
|
35
|
+
ResizeRequest,
|
|
17
36
|
ScreenshotProof,
|
|
18
37
|
SignatureProof,
|
|
19
|
-
Status,
|
|
20
38
|
Theme,
|
|
21
39
|
Transaction,
|
|
22
40
|
TransactionAsset,
|
|
41
|
+
TransactionOptions,
|
|
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
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
AgentType,
|
|
54
|
+
CMType,
|
|
55
|
+
HMType,
|
|
56
|
+
PersonType,
|
|
57
|
+
ProofStatus,
|
|
58
|
+
ProofTypes,
|
|
59
|
+
Status,
|
|
60
|
+
} from './types';
|
|
61
|
+
import { type MessageCallback } from './utils/MessageEventManager';
|
|
28
62
|
import { encodeObjectToFragment } from './utils/urls';
|
|
29
|
-
|
|
63
|
+
// Must be exported for React Native SDK to use
|
|
64
|
+
export { default as EmbeddedComponent } from './components/EmbeddedComponent';
|
|
30
65
|
export type {
|
|
31
|
-
|
|
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,
|
|
32
83
|
ComponentMessage,
|
|
33
|
-
|
|
84
|
+
ComponentResponse,
|
|
85
|
+
ConnectionRequest,
|
|
86
|
+
Counterparty,
|
|
87
|
+
DeclarationProof,
|
|
88
|
+
Deposit,
|
|
89
|
+
DepositRequest,
|
|
90
|
+
Destination,
|
|
91
|
+
Error,
|
|
34
92
|
HostMessage,
|
|
93
|
+
InvalidValue,
|
|
94
|
+
IVMS101,
|
|
95
|
+
LegalPerson,
|
|
96
|
+
LEI,
|
|
97
|
+
MicroTransferProof,
|
|
98
|
+
NaturalPerson,
|
|
99
|
+
OwnershipProof,
|
|
100
|
+
Ready,
|
|
101
|
+
ResizeRequest,
|
|
102
|
+
ScreenshotProof,
|
|
103
|
+
SignatureProof,
|
|
35
104
|
Theme,
|
|
36
|
-
Counterparty,
|
|
37
|
-
Withdrawal,
|
|
38
105
|
Transaction,
|
|
39
|
-
TransactionResponse,
|
|
40
|
-
Destination as destination,
|
|
41
106
|
TransactionAsset,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
107
|
+
TransactionOptions,
|
|
108
|
+
TransactionResponse,
|
|
109
|
+
UpdateValue,
|
|
110
|
+
V1Transaction,
|
|
111
|
+
ValidationError,
|
|
112
|
+
VASP,
|
|
113
|
+
Wallet,
|
|
114
|
+
Withdrawal,
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
CMType,
|
|
118
|
+
HMType,
|
|
47
119
|
ProofStatus,
|
|
48
120
|
ProofTypes,
|
|
49
|
-
IVMS101,
|
|
50
121
|
PersonType,
|
|
51
122
|
Status,
|
|
52
|
-
VASP,
|
|
53
|
-
Wallet,
|
|
54
|
-
Agent,
|
|
55
123
|
AgentType,
|
|
56
|
-
OwnershipProof,
|
|
57
124
|
};
|
|
58
125
|
|
|
59
126
|
/**
|
|
@@ -62,38 +129,74 @@ export type {
|
|
|
62
129
|
* @public
|
|
63
130
|
*/
|
|
64
131
|
export interface NotabeneConfig {
|
|
65
|
-
|
|
66
|
-
|
|
132
|
+
/**
|
|
133
|
+
* The URL of the Notabene API node
|
|
134
|
+
*/
|
|
135
|
+
nodeUrl?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The authentication token for the Notabene API
|
|
139
|
+
*/
|
|
140
|
+
authToken?: string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The URL of the Notabene UX components
|
|
144
|
+
*/
|
|
67
145
|
uxUrl?: string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Custom theme configuration for the UX components
|
|
149
|
+
*/
|
|
68
150
|
theme?: Theme;
|
|
69
|
-
dictionary?: { [key: string]: string };
|
|
70
|
-
}
|
|
71
151
|
|
|
152
|
+
/**
|
|
153
|
+
* The locale to use for the UX components
|
|
154
|
+
*/
|
|
155
|
+
locale?: string;
|
|
156
|
+
}
|
|
72
157
|
/**
|
|
73
158
|
* Primary constructor for Notabene UX elements
|
|
74
159
|
*
|
|
160
|
+
* This class provides methods to create and manage various Notabene components
|
|
161
|
+
* such as withdrawal assist, deposit assist, connect, and deposit request.
|
|
162
|
+
* It also handles URL generation and fragment decoding for these components.
|
|
163
|
+
*
|
|
75
164
|
* @public
|
|
76
165
|
*/
|
|
77
|
-
|
|
78
166
|
export default class Notabene {
|
|
79
|
-
private nodeUrl
|
|
80
|
-
private authToken
|
|
167
|
+
private nodeUrl?: string;
|
|
168
|
+
private authToken?: string;
|
|
81
169
|
private uxUrl: string;
|
|
82
170
|
private theme?: Theme;
|
|
83
|
-
private
|
|
171
|
+
private locale?: string;
|
|
84
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Creates a new instance of the Notabene SDK
|
|
175
|
+
*
|
|
176
|
+
* @param config - Configuration options for the Notabene SDK
|
|
177
|
+
*/
|
|
85
178
|
constructor(config: NotabeneConfig) {
|
|
86
|
-
this.uxUrl = config.uxUrl || 'https://
|
|
179
|
+
this.uxUrl = config.uxUrl || 'https://connect.notabene.id';
|
|
87
180
|
this.nodeUrl = config.nodeUrl;
|
|
88
181
|
this.authToken = config.authToken;
|
|
89
182
|
this.theme = config.theme;
|
|
90
|
-
this.
|
|
183
|
+
this.locale = config.locale;
|
|
91
184
|
}
|
|
92
185
|
|
|
93
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Generates a URL for a Notabene component
|
|
188
|
+
*
|
|
189
|
+
* @param path - The path of the component
|
|
190
|
+
* @param value - Transaction data
|
|
191
|
+
* @param configuration - Optional transaction configuration
|
|
192
|
+
* @param callbacks - Optional callback configuration
|
|
193
|
+
* @returns component URL
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
componentUrl<V, O>(
|
|
94
197
|
path: string,
|
|
95
|
-
value:
|
|
96
|
-
configuration?:
|
|
198
|
+
value: V,
|
|
199
|
+
configuration?: O,
|
|
97
200
|
callbacks?: CallbackOptions,
|
|
98
201
|
): string {
|
|
99
202
|
const url = new URL(this.uxUrl);
|
|
@@ -105,13 +208,13 @@ export default class Notabene {
|
|
|
105
208
|
configuration,
|
|
106
209
|
});
|
|
107
210
|
url.hash = hash;
|
|
108
|
-
url.searchParams.set('nodeUrl', this.nodeUrl);
|
|
211
|
+
if (this.nodeUrl) url.searchParams.set('nodeUrl', this.nodeUrl);
|
|
109
212
|
|
|
110
213
|
if (this.theme) {
|
|
111
214
|
url.searchParams.set('theme', JSON.stringify(this.theme));
|
|
112
215
|
}
|
|
113
|
-
if (this.
|
|
114
|
-
url.searchParams.set('
|
|
216
|
+
if (this.locale) {
|
|
217
|
+
url.searchParams.set('locale', this.locale);
|
|
115
218
|
}
|
|
116
219
|
if (callbacks) {
|
|
117
220
|
if (callbacks.callback)
|
|
@@ -122,26 +225,122 @@ export default class Notabene {
|
|
|
122
225
|
return url.toString();
|
|
123
226
|
}
|
|
124
227
|
|
|
125
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Creates a new embedded component
|
|
230
|
+
*
|
|
231
|
+
* @param path - The path of the component
|
|
232
|
+
* @param value - Transaction data
|
|
233
|
+
* @param options - Optional transaction options
|
|
234
|
+
* @param callbacks - Optional callback configuration
|
|
235
|
+
* @returns A new EmbeddedComponent instance
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
createComponent<V, O>(
|
|
126
239
|
path: string,
|
|
127
|
-
value: Partial<
|
|
128
|
-
options?:
|
|
240
|
+
value: Partial<V>,
|
|
241
|
+
options?: O,
|
|
129
242
|
callbacks?: CallbackOptions,
|
|
130
243
|
) {
|
|
131
|
-
return new EmbeddedComponent(
|
|
244
|
+
return new EmbeddedComponent<V, O>(
|
|
132
245
|
this.componentUrl(path, value, options, callbacks),
|
|
133
246
|
value,
|
|
247
|
+
options,
|
|
134
248
|
);
|
|
135
249
|
}
|
|
136
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Creates a withdrawal assist component
|
|
253
|
+
*
|
|
254
|
+
* @param value - Withdrawal transaction data
|
|
255
|
+
* @param options - Optional transaction options
|
|
256
|
+
* @param callbacks - Optional callback configuration
|
|
257
|
+
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
258
|
+
*/
|
|
137
259
|
public createWithdrawalAssist(
|
|
138
260
|
value: Partial<Withdrawal>,
|
|
261
|
+
options?: TransactionOptions,
|
|
262
|
+
callbacks?: CallbackOptions,
|
|
263
|
+
) {
|
|
264
|
+
return this.createComponent<Withdrawal, TransactionOptions>(
|
|
265
|
+
'withdrawal-assist',
|
|
266
|
+
value,
|
|
267
|
+
options,
|
|
268
|
+
callbacks,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Creates a deposit assist component
|
|
274
|
+
*
|
|
275
|
+
* @param value - Deposit transaction data
|
|
276
|
+
* @param options - Optional transaction options
|
|
277
|
+
* @param callbacks - Optional callback configuration
|
|
278
|
+
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
279
|
+
* @alpha
|
|
280
|
+
*/
|
|
281
|
+
public createDepositAssist(
|
|
282
|
+
value: Partial<Deposit>,
|
|
139
283
|
options?: any,
|
|
140
284
|
callbacks?: CallbackOptions,
|
|
141
285
|
) {
|
|
142
|
-
return this.createComponent
|
|
286
|
+
return this.createComponent<Deposit, any>(
|
|
287
|
+
'deposit-assist',
|
|
288
|
+
value,
|
|
289
|
+
options,
|
|
290
|
+
callbacks,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Creates a connect component
|
|
296
|
+
*
|
|
297
|
+
* @param value - Connection request data
|
|
298
|
+
* @param options - Optional transaction options
|
|
299
|
+
* @param callbacks - Optional callback configuration
|
|
300
|
+
* @returns A new EmbeddedComponent instance for connection
|
|
301
|
+
* @alpha
|
|
302
|
+
*/
|
|
303
|
+
public createConnectWallet(
|
|
304
|
+
value: ConnectionRequest,
|
|
305
|
+
options?: TransactionOptions,
|
|
306
|
+
callbacks?: CallbackOptions,
|
|
307
|
+
) {
|
|
308
|
+
return this.createComponent<ConnectionRequest, TransactionOptions>(
|
|
309
|
+
'connect',
|
|
310
|
+
value,
|
|
311
|
+
options,
|
|
312
|
+
callbacks,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Creates a deposit request component
|
|
318
|
+
*
|
|
319
|
+
* @param value - Deposit request data
|
|
320
|
+
* @param options - Optional transaction options
|
|
321
|
+
* @param callbacks - Optional callback configuration
|
|
322
|
+
* @returns A new EmbeddedComponent instance for deposit requests
|
|
323
|
+
* @public
|
|
324
|
+
*/
|
|
325
|
+
public createDepositRequest(
|
|
326
|
+
value: DepositRequest,
|
|
327
|
+
options?: TransactionOptions,
|
|
328
|
+
callbacks?: CallbackOptions,
|
|
329
|
+
) {
|
|
330
|
+
return this.createComponent<DepositRequest, TransactionOptions>(
|
|
331
|
+
'deposit-request',
|
|
332
|
+
value,
|
|
333
|
+
options,
|
|
334
|
+
callbacks,
|
|
335
|
+
);
|
|
143
336
|
}
|
|
144
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Decodes a URL fragment into an object
|
|
340
|
+
*
|
|
341
|
+
* @param fragment - The URL fragment to decode
|
|
342
|
+
* @returns An object containing the decoded key-value pairs
|
|
343
|
+
*/
|
|
145
344
|
public decodeFragmentToObject(fragment: string): Record<string, string> {
|
|
146
345
|
const pairs = fragment.slice(1).split('&');
|
|
147
346
|
return pairs.reduce(
|
|
@@ -153,50 +352,4 @@ export default class Notabene {
|
|
|
153
352
|
{} as Record<string, string>,
|
|
154
353
|
);
|
|
155
354
|
}
|
|
156
|
-
|
|
157
|
-
// private openModal(url: string): void {
|
|
158
|
-
// if (this.modal) {
|
|
159
|
-
// this.closeModal();
|
|
160
|
-
// }
|
|
161
|
-
// this.modal = document.createElement('div');
|
|
162
|
-
// this.modal.style.position = 'fixed';
|
|
163
|
-
// this.modal.style.top = '0';
|
|
164
|
-
// this.modal.style.left = '0';
|
|
165
|
-
// this.modal.style.width = '100%';
|
|
166
|
-
// this.modal.style.height = '100%';
|
|
167
|
-
// this.modal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
|
168
|
-
// this.modal.style.display = 'flex';
|
|
169
|
-
// this.modal.style.justifyContent = 'center';
|
|
170
|
-
// this.modal.style.alignItems = 'center';
|
|
171
|
-
// const iframe = document.createElement('iframe');
|
|
172
|
-
// iframe.src = url;
|
|
173
|
-
// iframe.setAttribute('allowtransparency', 'true');
|
|
174
|
-
// // iframe.allowtransparency = true;
|
|
175
|
-
// iframe.style.backgroundColor = 'transparent';
|
|
176
|
-
// iframe.style.width = '90%';
|
|
177
|
-
// iframe.style.height = '90%';
|
|
178
|
-
// iframe.style.border = 'none';
|
|
179
|
-
// iframe.style.overflow = 'hidden';
|
|
180
|
-
// this.modal.appendChild(iframe);
|
|
181
|
-
// document.body.appendChild(this.modal);
|
|
182
|
-
// this.modal.addEventListener('click', () => {
|
|
183
|
-
// console.log('click');
|
|
184
|
-
// this.closeModal();
|
|
185
|
-
// });
|
|
186
|
-
// document.addEventListener('keydown', ({ key }) => {
|
|
187
|
-
// console.log(`key: ${key}`);
|
|
188
|
-
// if (key === 'Escape') {
|
|
189
|
-
// console.log('esc');
|
|
190
|
-
// this.closeModal();
|
|
191
|
-
// }
|
|
192
|
-
// });
|
|
193
|
-
// }
|
|
194
|
-
|
|
195
|
-
// private closeModal(): void {
|
|
196
|
-
// if (this.modal) {
|
|
197
|
-
// console.log('this.closeModal');
|
|
198
|
-
// this.modal.remove();
|
|
199
|
-
// this.modal = undefined;
|
|
200
|
-
// }
|
|
201
|
-
// }
|
|
202
355
|
}
|