@notabene/javascript-sdk 2.0.0-next.15 → 2.0.0-next.17
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/README.md +32 -27
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +37 -43
- package/dist/notabene.js +36 -23
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +21 -20
- package/src/components/EmbeddedComponent.ts +20 -22
- package/src/components/__tests__/EmbeddedComponent.test.ts +12 -32
- package/src/locales.ts +47 -0
- package/src/notabene.ts +25 -20
- package/src/types.ts +23 -28
- package/src/utils/MessageEventManager.ts +8 -8
- package/src/utils/__tests__/MessageEventManager.test.ts +3 -3
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
|
|
|
36
36
|
- [Common use cases](#common-use-cases)
|
|
37
37
|
- [Configuring ownership proofs](#configuring-ownership-proofs)
|
|
38
38
|
- [Counterparty Field Properties](#counterparty-field-properties)
|
|
39
|
+
- [Locales](#locales)
|
|
39
40
|
- [License](#license)
|
|
40
41
|
|
|
41
42
|
## Installation
|
|
@@ -51,13 +52,13 @@ Or installing the library:
|
|
|
51
52
|
Using Yarn:
|
|
52
53
|
|
|
53
54
|
```bash
|
|
54
|
-
yarn add @notabene/javascript-sdk
|
|
55
|
+
yarn add @notabene/javascript-sdk@next
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
Using NPM:
|
|
58
59
|
|
|
59
60
|
```bash
|
|
60
|
-
npm install @notabene/javascript-sdk
|
|
61
|
+
npm install @notabene/javascript-sdk@next
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
If you installed the library into your project, you can import it into your project:
|
|
@@ -80,9 +81,9 @@ Create a new Notabene instance:
|
|
|
80
81
|
|
|
81
82
|
```js
|
|
82
83
|
const notabene = new Notabene({
|
|
83
|
-
nodeUrl: 'https://api.notabene.id',
|
|
84
|
+
nodeUrl: 'https://api.notabene.id', // use `https://api.notabene.dev` for testing
|
|
84
85
|
authToken: '{CUSTOMER_TOKEN}',
|
|
85
|
-
locale: 'de' // default locale
|
|
86
|
+
locale: 'de', // default locale = `en`
|
|
86
87
|
});
|
|
87
88
|
```
|
|
88
89
|
|
|
@@ -106,19 +107,20 @@ Instantiate the withdrawal element and mount it using the id from above
|
|
|
106
107
|
|
|
107
108
|
```js
|
|
108
109
|
const withdrawal = notabene.createWithdrawalAssist(tx, options);
|
|
109
|
-
withdrawal.mount(
|
|
110
|
+
withdrawal.mount('nb-withdrawal');
|
|
110
111
|
```
|
|
111
112
|
|
|
112
113
|
The simplest way to get the result is to use:
|
|
113
114
|
|
|
114
115
|
```js
|
|
115
116
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const { valid, value, txCreate, ivms101, proof } =
|
|
118
|
+
await withdrawal.completion();
|
|
119
|
+
if (valid) {
|
|
120
|
+
// Submit result to your backend
|
|
121
|
+
}
|
|
120
122
|
} catch (e) {
|
|
121
|
-
|
|
123
|
+
console.error(e);
|
|
122
124
|
}
|
|
123
125
|
```
|
|
124
126
|
|
|
@@ -130,7 +132,7 @@ To update the component as users enter transaction details:
|
|
|
130
132
|
withdrawal.update({
|
|
131
133
|
asset: 'ETH',
|
|
132
134
|
destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
133
|
-
amountDecimal: 1.12
|
|
135
|
+
amountDecimal: 1.12,
|
|
134
136
|
});
|
|
135
137
|
```
|
|
136
138
|
|
|
@@ -217,13 +219,12 @@ The `asset` field the following types of assets specified:
|
|
|
217
219
|
- [CAIP-19](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md_) is a chain agnostic format allows you to support the widest amount of assets and blockchains including NFTs.
|
|
218
220
|
- [DTI](https://www.iso.org/standard/80601.html) is the ISO Digital Token Identifier format. See [DTI registry](https://dtif.org/registry-search/) for supported tokens.
|
|
219
221
|
|
|
220
|
-
|
|
221
222
|
### Modal
|
|
222
223
|
|
|
223
224
|
Instantiate the modal and open it
|
|
224
225
|
|
|
225
226
|
```js
|
|
226
|
-
const connect = notabene.createConnectWallet({asset:'ETH'}, options);
|
|
227
|
+
const connect = notabene.createConnectWallet({ asset: 'ETH' }, options);
|
|
227
228
|
const { valid, value, txCreate, ivms101, proof } = await connect.openModal();
|
|
228
229
|
```
|
|
229
230
|
|
|
@@ -268,10 +269,10 @@ The following shows the full set of options in typescript:
|
|
|
268
269
|
|
|
269
270
|
```ts
|
|
270
271
|
import Notabene, {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
AgentType,
|
|
273
|
+
PersonType,
|
|
274
|
+
ProofTypes,
|
|
275
|
+
} from '@notabene/javascript-sdk';
|
|
275
276
|
|
|
276
277
|
const options: TransactionOptions = {
|
|
277
278
|
proofs: {
|
|
@@ -312,8 +313,8 @@ const options: TransactionOptions = {
|
|
|
312
313
|
},
|
|
313
314
|
vasps: {
|
|
314
315
|
addUnknown: true, // Allow users to add a missing VASP - Defaults to false
|
|
315
|
-
onlyActive: true // Only list active VASPs - Default false
|
|
316
|
-
}
|
|
316
|
+
onlyActive: true, // Only list active VASPs - Default false
|
|
317
|
+
},
|
|
317
318
|
},
|
|
318
319
|
};
|
|
319
320
|
const withdrawal = notabene.createWithdrawalAssist(tx, options);
|
|
@@ -351,7 +352,6 @@ const options: TransactionOptions = {
|
|
|
351
352
|
|
|
352
353
|
By default components support message signing proofs.
|
|
353
354
|
|
|
354
|
-
|
|
355
355
|
#### Supporting Micro Transactions (aka Satoshi tests)
|
|
356
356
|
|
|
357
357
|
You can support Micro Transfers (aka Satoshi tests) by adding a deposit address for the test.
|
|
@@ -367,8 +367,8 @@ const options: TransactionOptions = {
|
|
|
367
367
|
timeout: 86440, // Optional timeout in seconds, which is displayed to the user
|
|
368
368
|
},
|
|
369
369
|
fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
|
|
370
|
-
}
|
|
371
|
-
}
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
Notabene does not currently verify these tests automatically as you likely already have the infrastructure to do so.
|
|
@@ -395,9 +395,10 @@ You may accept a few options if none of the other are available. We do not recom
|
|
|
395
395
|
const options: TransactionOptions = {
|
|
396
396
|
proofs: {
|
|
397
397
|
fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
|
|
398
|
-
}
|
|
399
|
-
}
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
400
|
```
|
|
401
|
+
|
|
401
402
|
The two options are:
|
|
402
403
|
|
|
403
404
|
- `screenshot` Where a user is requested to upload a screenshot of their wallet
|
|
@@ -417,6 +418,7 @@ Each field can be configured like this:
|
|
|
417
418
|
- `{ transmit: true }` Include in beneficiary field of IVMS101 to be transmitted to counterparty
|
|
418
419
|
|
|
419
420
|
Eg:
|
|
421
|
+
|
|
420
422
|
```ts
|
|
421
423
|
{
|
|
422
424
|
naturalPerson: {
|
|
@@ -426,13 +428,13 @@ Eg:
|
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
430
|
```
|
|
431
|
+
|
|
429
432
|
The above will always ask the user for the following for natural persons:
|
|
430
433
|
|
|
431
434
|
- `name` since it is on by default (you can disable it explicitly by setting it to `false`)
|
|
432
435
|
- `website` is show but is optional
|
|
433
436
|
- `email` is required
|
|
434
437
|
|
|
435
|
-
|
|
436
438
|
#### Full Example
|
|
437
439
|
|
|
438
440
|
```ts
|
|
@@ -446,7 +448,7 @@ const options: TransactionOptions = {
|
|
|
446
448
|
geographicAddress: false,
|
|
447
449
|
nationalIdentification: false,
|
|
448
450
|
dateOfBirth: {
|
|
449
|
-
transmit: true
|
|
451
|
+
transmit: true,
|
|
450
452
|
},
|
|
451
453
|
placeOfBirth: false,
|
|
452
454
|
countryOfResidence: true,
|
|
@@ -468,7 +470,7 @@ const options: TransactionOptions = {
|
|
|
468
470
|
#### Field reference
|
|
469
471
|
|
|
470
472
|
| Field name | Natural | Legal | IVMS101 | Transmitted | description |
|
|
471
|
-
|
|
473
|
+
| ------------------------ | ------- | ----- | ------- | ----------- | --------------------------------------------- |
|
|
472
474
|
| `name` | ✅ | ✅ | ✅ | ✅ | Full name |
|
|
473
475
|
| `email` | 🟩 | 🟩 | -- | -- | Email (for your internal purposes) |
|
|
474
476
|
| `website` | -- | ✅ | -- | -- | Business Website (for your internal purposes) |
|
|
@@ -481,6 +483,9 @@ const options: TransactionOptions = {
|
|
|
481
483
|
| `lei` | -- | ✅ | ✅ | ✅ | LEI (Legal Entity Identifier) |
|
|
482
484
|
| `countryOfRegistration` | -- | 🟩 | ✅ | 🟩 | Country of Registration |
|
|
483
485
|
|
|
486
|
+
## Locales
|
|
487
|
+
|
|
488
|
+
See [locales](src/locales.ts) for the list of supported locales.
|
|
484
489
|
|
|
485
490
|
## [License](LICENSE.md)
|
|
486
491
|
|
package/dist/notabene.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var v=(t,e,s)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>v(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(d||{}),c=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(c||{}),m=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(m||{}),a=(t=>(t.COMPLETE="complete",t.RESIZE="resize",t.RESULT="result",t.READY="ready",t.INVALID="invalid",t.ERROR="error",t.CANCEL="cancel",t))(a||{}),u=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(u||{}),p=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(p||{}),f=(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))(f||{});class w{constructor(){o(this,"listeners",new Map);o(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,s){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(s)}off(e,s){const r=this.listeners.get(e);r&&(r.delete(s),r.size===0&&this.listeners.delete(e))}handleMessage(e){const s=e.data;if(typeof s=="object"&&s!==null&&"type"in s){const r=s.type,i=this.listeners.get(r);i&&i.forEach(n=>n(s))}}send(e){this.port&&this.port.postMessage(e)}}class E{constructor(e,s){o(this,"_url");o(this,"_value");o(this,"_errors",[]);o(this,"iframe");o(this,"eventManager");o(this,"modal");this._url=e,this._value=s,this.eventManager=new w,this.on(a.INVALID,r=>{r.type===a.INVALID&&(this._errors=r.errors,this._value=r.value)}),this.on(a.RESIZE,r=>{r.type===a.RESIZE&&this.iframe&&(this.iframe.style.height=`${r.height}px`)})}get url(){return this._url}get value(){return this._value}get errors(){return this._errors}open(){document.location.href=this.url}mount(e){const s=document.querySelector(e);if(!s)throw new Error(`parentID ${e} not found`);this.embed(s)}embed(e,s=!1){var r,i;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=>{var l,h;n.source===((l=this.iframe)==null?void 0:l.contentWindow)&&((h=this.eventManager)==null||h.setPort(n.ports[0]))}),(i=(r=this.iframe)==null?void 0:r.contentWindow)==null||i.focus()}send(e){this.eventManager.send(e)}on(e,s){this.eventManager.on(e,s)}off(e,s){this.eventManager.off(e,s)}update(e){this._value=e,this.send({type:u.UPDATE,value:e})}completion(){return new Promise((e,s)=>{this.on(a.COMPLETE,r=>{e(r.response)}),this.on("error",r=>{s(new Error(r.message))})})}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,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&((e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function I(t){return Object.entries(t).map(([e,s])=>{if(!(e&&s))return;const r=encodeURIComponent(e),i=encodeURIComponent(typeof s=="object"?JSON.stringify(s):s);return`${r}=${i}`}).filter(e=>!!e).join("&")}class U{constructor(e){o(this,"nodeUrl");o(this,"authToken");o(this,"uxUrl");o(this,"theme");o(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,s,r,i){const n=new URL(this.uxUrl);n.pathname=e;const l=I({authToken:this.authToken,value:s,configuration:r});return n.hash=l,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()}createComponent(e,s,r,i){return new E(this.componentUrl(e,s,r,i),s)}createWithdrawalAssist(e,s,r){return this.createComponent("withdrawal-assist",e,s,r)}createWalletAssist(e,s,r){return this.createComponent("wallet-assist",e,s,r)}createDepositAssist(e,s,r){return this.createComponent("deposit-assist",e,s,r)}createConnectWallet(e,s,r){return this.createComponent("connect",e,s,r)}createDepositRequest(e,s,r){return this.createComponent("deposit-request",e,s,r)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((r,i)=>{const[n,l]=i.split("=");return r[decodeURIComponent(n)]=decodeURIComponent(l),r},{})}}exports.AgentType=d;exports.CMType=a;exports.EmbeddedComponent=E;exports.PersonType=c;exports.ProofStatus=p;exports.ProofTypes=f;exports.Status=m;exports.default=U;
|
package/dist/notabene.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export declare interface CallbackOptions {
|
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Represents a cancel component message
|
|
144
|
-
* @
|
|
144
|
+
* @internal
|
|
145
145
|
*/
|
|
146
146
|
declare type Cancel = {
|
|
147
147
|
type: CMType.CANCEL;
|
|
@@ -157,26 +157,26 @@ export declare const enum CMType {
|
|
|
157
157
|
RESULT = "result",
|
|
158
158
|
READY = "ready",
|
|
159
159
|
INVALID = "invalid",
|
|
160
|
-
MODAL = "openModal",
|
|
161
160
|
ERROR = "error",
|
|
162
|
-
CLOSE = "closeModal",
|
|
163
161
|
CANCEL = "cancel"
|
|
164
162
|
}
|
|
165
163
|
|
|
166
164
|
/**
|
|
167
165
|
* Represents a completed component message
|
|
166
|
+
* @typeParam T - The overall Value type being returned
|
|
167
|
+
* @param response - The Response object which wraps T
|
|
168
168
|
* @public
|
|
169
169
|
*/
|
|
170
|
-
declare type Completed = {
|
|
170
|
+
declare type Completed<T> = {
|
|
171
171
|
type: CMType.COMPLETE;
|
|
172
|
-
response:
|
|
172
|
+
response: TransactionResponse<T>;
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
176
|
* Component Message
|
|
177
177
|
* @public
|
|
178
178
|
*/
|
|
179
|
-
export declare type ComponentMessage = Completed | Cancel | Error_2 | Ready | ResizeRequest | InvalidValue
|
|
179
|
+
export declare type ComponentMessage<T> = Completed<T> | Cancel | Error_2 | Ready | ResizeRequest | InvalidValue<T>;
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
182
|
* An abstract request for communicating with a component
|
|
@@ -202,17 +202,6 @@ export declare interface ConnectionRequest extends ComponentRequest {
|
|
|
202
202
|
asset: TransactionAsset;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
/**
|
|
206
|
-
* An object representing a connection response
|
|
207
|
-
* @public
|
|
208
|
-
*/
|
|
209
|
-
export declare interface ConnectionResponse extends ComponentResponse {
|
|
210
|
-
value: ConnectionRequest;
|
|
211
|
-
ivms: IVMS101;
|
|
212
|
-
proof?: OwnershipProof;
|
|
213
|
-
txCreate?: V1Transaction;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
205
|
/**
|
|
217
206
|
* The counterparty of a transaction.
|
|
218
207
|
* @public
|
|
@@ -304,7 +293,7 @@ declare type DTI = string;
|
|
|
304
293
|
* An embedded Notabene component
|
|
305
294
|
* @public
|
|
306
295
|
*/
|
|
307
|
-
export declare class EmbeddedComponent<V
|
|
296
|
+
export declare class EmbeddedComponent<V> {
|
|
308
297
|
private _url;
|
|
309
298
|
private _value;
|
|
310
299
|
private _errors;
|
|
@@ -316,7 +305,7 @@ export declare class EmbeddedComponent<V, R> {
|
|
|
316
305
|
* @param url - The URL of the embedded component
|
|
317
306
|
* @param value - The initial transaction value
|
|
318
307
|
*/
|
|
319
|
-
constructor(url: string, value: V);
|
|
308
|
+
constructor(url: string, value: Partial<V>);
|
|
320
309
|
/**
|
|
321
310
|
* Gets the URL of the embedded component
|
|
322
311
|
* @returns The URL of the embedded component
|
|
@@ -326,7 +315,7 @@ export declare class EmbeddedComponent<V, R> {
|
|
|
326
315
|
* Gets the current transaction value
|
|
327
316
|
* @returns The current transaction value
|
|
328
317
|
*/
|
|
329
|
-
get value(): V
|
|
318
|
+
get value(): Partial<V>;
|
|
330
319
|
get errors(): ValidationError[];
|
|
331
320
|
/**
|
|
332
321
|
* Opens the component URL in the current window
|
|
@@ -347,33 +336,33 @@ export declare class EmbeddedComponent<V, R> {
|
|
|
347
336
|
* Sends a message to the embedded component
|
|
348
337
|
* @param message - The message to send
|
|
349
338
|
*/
|
|
350
|
-
send(message: HostMessage): void;
|
|
339
|
+
send(message: HostMessage<V>): void;
|
|
351
340
|
/**
|
|
352
341
|
* Adds an event listener for a specific message type
|
|
353
342
|
* @param messageType - The type of message to listen for
|
|
354
343
|
* @param callback - The callback function to execute when the message is received
|
|
355
344
|
*/
|
|
356
|
-
on(messageType: string, callback: MessageCallback): void;
|
|
345
|
+
on(messageType: string, callback: MessageCallback<V>): void;
|
|
357
346
|
/**
|
|
358
347
|
* Removes an event listener for a specific message type
|
|
359
348
|
* @param messageType - The type of message to stop listening for
|
|
360
349
|
* @param callback - The callback function to remove
|
|
361
350
|
*/
|
|
362
|
-
off(messageType: string, callback: MessageCallback): void;
|
|
351
|
+
off(messageType: string, callback: MessageCallback<V>): void;
|
|
363
352
|
/**
|
|
364
353
|
* Updates the transaction value and sends an update message to the component
|
|
365
354
|
* @param value - The new transaction value
|
|
366
355
|
*/
|
|
367
|
-
update(value: V): void;
|
|
356
|
+
update(value: Partial<V>): void;
|
|
368
357
|
/**
|
|
369
358
|
* Waits for the component to complete and returns the transaction response
|
|
370
359
|
* @returns A promise that resolves with the transaction response
|
|
371
360
|
*/
|
|
372
|
-
completion(): Promise<
|
|
361
|
+
completion(): Promise<TransactionResponse<V>>;
|
|
373
362
|
/**
|
|
374
363
|
* Opens the component in a modal dialog
|
|
375
364
|
*/
|
|
376
|
-
openModal(): Promise<
|
|
365
|
+
openModal(): Promise<TransactionResponse<V>>;
|
|
377
366
|
/**
|
|
378
367
|
* Closes the modal dialog
|
|
379
368
|
*
|
|
@@ -383,6 +372,7 @@ export declare class EmbeddedComponent<V, R> {
|
|
|
383
372
|
|
|
384
373
|
/**
|
|
385
374
|
* Represents an error component message
|
|
375
|
+
* @param message - Error message
|
|
386
376
|
* @public
|
|
387
377
|
*/
|
|
388
378
|
declare type Error_2 = {
|
|
@@ -417,7 +407,7 @@ declare const enum HMType {
|
|
|
417
407
|
* Host Messages
|
|
418
408
|
* @public
|
|
419
409
|
*/
|
|
420
|
-
export declare type HostMessage = UpdateValue
|
|
410
|
+
export declare type HostMessage<T> = UpdateValue<T>;
|
|
421
411
|
|
|
422
412
|
/**
|
|
423
413
|
* Intermediary VASP
|
|
@@ -433,11 +423,14 @@ declare type IntermediaryVASP = {
|
|
|
433
423
|
|
|
434
424
|
/**
|
|
435
425
|
* Represents an invalid value component message
|
|
436
|
-
* @
|
|
426
|
+
* @typeParam T - The overall Value type being returned
|
|
427
|
+
* @param value - The current Partial value
|
|
428
|
+
* @param errors - Array of validation errors
|
|
429
|
+
* @internal
|
|
437
430
|
*/
|
|
438
|
-
declare type InvalidValue = {
|
|
431
|
+
declare type InvalidValue<T> = {
|
|
439
432
|
type: CMType.INVALID;
|
|
440
|
-
value:
|
|
433
|
+
value: Partial<T>;
|
|
441
434
|
errors: ValidationError[];
|
|
442
435
|
};
|
|
443
436
|
|
|
@@ -573,7 +566,7 @@ declare type LocalNaturalPersonNameID = {
|
|
|
573
566
|
nameIdentifierType?: NaturalPersonNameTypeCode;
|
|
574
567
|
};
|
|
575
568
|
|
|
576
|
-
declare type MessageCallback = (message: ComponentMessage) => void;
|
|
569
|
+
declare type MessageCallback<T> = (message: ComponentMessage<T>) => void;
|
|
577
570
|
|
|
578
571
|
/**
|
|
579
572
|
* Ownership Proof using Micro Transfer
|
|
@@ -721,7 +714,7 @@ declare class Notabene {
|
|
|
721
714
|
* @returns A new EmbeddedComponent instance
|
|
722
715
|
* @internal
|
|
723
716
|
*/
|
|
724
|
-
createComponent<V
|
|
717
|
+
createComponent<V>(path: string, value: Partial<V>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<V>;
|
|
725
718
|
/**
|
|
726
719
|
* Creates a withdrawal assist component
|
|
727
720
|
*
|
|
@@ -730,7 +723,7 @@ declare class Notabene {
|
|
|
730
723
|
* @param callbacks - Optional callback configuration
|
|
731
724
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
732
725
|
*/
|
|
733
|
-
createWithdrawalAssist(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<
|
|
726
|
+
createWithdrawalAssist(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<Withdrawal>;
|
|
734
727
|
/**
|
|
735
728
|
* Creates a wallet assist component
|
|
736
729
|
*
|
|
@@ -740,7 +733,7 @@ declare class Notabene {
|
|
|
740
733
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
741
734
|
* @alpha
|
|
742
735
|
*/
|
|
743
|
-
createWalletAssist(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<
|
|
736
|
+
createWalletAssist(value: Partial<Withdrawal>, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<Withdrawal>;
|
|
744
737
|
/**
|
|
745
738
|
* Creates a deposit assist component
|
|
746
739
|
*
|
|
@@ -750,7 +743,7 @@ declare class Notabene {
|
|
|
750
743
|
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
751
744
|
* @alpha
|
|
752
745
|
*/
|
|
753
|
-
createDepositAssist(value: Partial<Deposit>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent<
|
|
746
|
+
createDepositAssist(value: Partial<Deposit>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent<Deposit>;
|
|
754
747
|
/**
|
|
755
748
|
* Creates a connect component
|
|
756
749
|
*
|
|
@@ -760,7 +753,7 @@ declare class Notabene {
|
|
|
760
753
|
* @returns A new EmbeddedComponent instance for connection
|
|
761
754
|
* @alpha
|
|
762
755
|
*/
|
|
763
|
-
createConnectWallet(value: ConnectionRequest, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<ConnectionRequest
|
|
756
|
+
createConnectWallet(value: ConnectionRequest, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<ConnectionRequest>;
|
|
764
757
|
/**
|
|
765
758
|
* Creates a deposit request component
|
|
766
759
|
*
|
|
@@ -770,7 +763,7 @@ declare class Notabene {
|
|
|
770
763
|
* @returns A new EmbeddedComponent instance for deposit requests
|
|
771
764
|
* @public
|
|
772
765
|
*/
|
|
773
|
-
createDepositRequest(value: DepositRequest, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<DepositRequest
|
|
766
|
+
createDepositRequest(value: DepositRequest, options?: TransactionOptions, callbacks?: CallbackOptions): EmbeddedComponent<DepositRequest>;
|
|
774
767
|
/**
|
|
775
768
|
* Decodes a URL fragment into an object
|
|
776
769
|
*
|
|
@@ -923,6 +916,7 @@ export declare enum ProofStatus {
|
|
|
923
916
|
export declare enum ProofTypes {
|
|
924
917
|
SelfDeclaration = "self-declaration",
|
|
925
918
|
PersonalSignEIP191 = "eip-191",
|
|
919
|
+
SIWE = "siwe",
|
|
926
920
|
PersonalSignEIP712 = "eip-712",
|
|
927
921
|
PersonalSignBIP137 = "bip-137",
|
|
928
922
|
PersonalSignXPUB = "xpub",
|
|
@@ -941,8 +935,8 @@ declare type Ready = {
|
|
|
941
935
|
declare type RequestID = UUID;
|
|
942
936
|
|
|
943
937
|
/**
|
|
944
|
-
* Represents a resize request component message
|
|
945
|
-
* @
|
|
938
|
+
* Represents a resize request component message. This is handled by the library.
|
|
939
|
+
* @internal
|
|
946
940
|
*/
|
|
947
941
|
declare type ResizeRequest = {
|
|
948
942
|
type: CMType.RESIZE;
|
|
@@ -963,7 +957,7 @@ export declare interface ScreenshotProof extends OwnershipProof {
|
|
|
963
957
|
* @public
|
|
964
958
|
*/
|
|
965
959
|
export declare interface SignatureProof extends OwnershipProof {
|
|
966
|
-
type: ProofTypes.PersonalSignEIP191 | ProofTypes.PersonalSignEIP712 | ProofTypes.PersonalSignBIP137 | ProofTypes.PersonalSignXPUB;
|
|
960
|
+
type: ProofTypes.PersonalSignEIP191 | ProofTypes.PersonalSignEIP712 | ProofTypes.PersonalSignBIP137 | ProofTypes.SIWE | ProofTypes.PersonalSignXPUB;
|
|
967
961
|
proof: string;
|
|
968
962
|
attestation: string;
|
|
969
963
|
wallet_provider: string;
|
|
@@ -1074,12 +1068,12 @@ declare type TransliterationMethodCode = 'arab' | 'aran' | 'armn' | 'cyrl' | 'de
|
|
|
1074
1068
|
declare type TravelAddress = `ta${string}`;
|
|
1075
1069
|
|
|
1076
1070
|
/**
|
|
1077
|
-
* Represents an update value host message
|
|
1071
|
+
* Represents an update value host message. This is sent from Host to component.
|
|
1078
1072
|
* @public
|
|
1079
1073
|
*/
|
|
1080
|
-
declare type UpdateValue = {
|
|
1074
|
+
declare type UpdateValue<T> = {
|
|
1081
1075
|
type: HMType.UPDATE;
|
|
1082
|
-
value:
|
|
1076
|
+
value: Partial<T>;
|
|
1083
1077
|
};
|
|
1084
1078
|
|
|
1085
1079
|
/**
|
package/dist/notabene.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 || {}), 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 || {}), 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 || {}), p = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(p || {}), 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());
|
|
@@ -19,7 +19,6 @@ class v {
|
|
|
19
19
|
r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
|
|
20
20
|
}
|
|
21
21
|
handleMessage(e) {
|
|
22
|
-
console.log("received message", e.data);
|
|
23
22
|
const s = e.data;
|
|
24
23
|
if (typeof s == "object" && s !== null && "type" in s) {
|
|
25
24
|
const r = s.type, i = this.listeners.get(r);
|
|
@@ -31,7 +30,7 @@ class v {
|
|
|
31
30
|
this.port && this.port.postMessage(e);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
class
|
|
33
|
+
class w {
|
|
35
34
|
/**
|
|
36
35
|
* Creates an instance of EmbeddedComponent.
|
|
37
36
|
* @param url - The URL of the embedded component
|
|
@@ -89,9 +88,9 @@ class I {
|
|
|
89
88
|
*/
|
|
90
89
|
embed(e, s = !1) {
|
|
91
90
|
var r, i;
|
|
92
|
-
|
|
93
|
-
var
|
|
94
|
-
n.source === ((
|
|
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) => {
|
|
92
|
+
var h, l;
|
|
93
|
+
n.source === ((h = this.iframe) == null ? void 0 : h.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
|
|
95
94
|
}), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
@@ -141,9 +140,7 @@ class I {
|
|
|
141
140
|
* Opens the component in a modal dialog
|
|
142
141
|
*/
|
|
143
142
|
openModal() {
|
|
144
|
-
return this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "
|
|
145
|
-
this.closeModal();
|
|
146
|
-
}), this.on(a.CLOSE, () => {
|
|
143
|
+
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, () => {
|
|
147
144
|
this.closeModal();
|
|
148
145
|
}), this.on(a.COMPLETE, () => {
|
|
149
146
|
this.closeModal();
|
|
@@ -157,10 +154,10 @@ class I {
|
|
|
157
154
|
*/
|
|
158
155
|
closeModal() {
|
|
159
156
|
var e;
|
|
160
|
-
this.modal && (
|
|
157
|
+
this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
|
-
function
|
|
160
|
+
function I(t) {
|
|
164
161
|
return Object.entries(t).map(([e, s]) => {
|
|
165
162
|
if (!(e && s)) return;
|
|
166
163
|
const r = encodeURIComponent(e), i = encodeURIComponent(
|
|
@@ -169,7 +166,7 @@ function U(t) {
|
|
|
169
166
|
return `${r}=${i}`;
|
|
170
167
|
}).filter((e) => !!e).join("&");
|
|
171
168
|
}
|
|
172
|
-
class
|
|
169
|
+
class R {
|
|
173
170
|
/**
|
|
174
171
|
* Creates a new instance of the Notabene SDK
|
|
175
172
|
*
|
|
@@ -196,12 +193,12 @@ class L {
|
|
|
196
193
|
componentUrl(e, s, r, i) {
|
|
197
194
|
const n = new URL(this.uxUrl);
|
|
198
195
|
n.pathname = e;
|
|
199
|
-
const
|
|
196
|
+
const h = I({
|
|
200
197
|
authToken: this.authToken,
|
|
201
198
|
value: s,
|
|
202
199
|
configuration: r
|
|
203
200
|
});
|
|
204
|
-
return n.hash =
|
|
201
|
+
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();
|
|
205
202
|
}
|
|
206
203
|
/**
|
|
207
204
|
* Creates a new embedded component
|
|
@@ -214,7 +211,7 @@ class L {
|
|
|
214
211
|
* @internal
|
|
215
212
|
*/
|
|
216
213
|
createComponent(e, s, r, i) {
|
|
217
|
-
return new
|
|
214
|
+
return new w(
|
|
218
215
|
this.componentUrl(e, s, r, i),
|
|
219
216
|
s
|
|
220
217
|
);
|
|
@@ -228,7 +225,12 @@ class L {
|
|
|
228
225
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
229
226
|
*/
|
|
230
227
|
createWithdrawalAssist(e, s, r) {
|
|
231
|
-
return this.createComponent(
|
|
228
|
+
return this.createComponent(
|
|
229
|
+
"withdrawal-assist",
|
|
230
|
+
e,
|
|
231
|
+
s,
|
|
232
|
+
r
|
|
233
|
+
);
|
|
232
234
|
}
|
|
233
235
|
/**
|
|
234
236
|
* Creates a wallet assist component
|
|
@@ -240,7 +242,12 @@ class L {
|
|
|
240
242
|
* @alpha
|
|
241
243
|
*/
|
|
242
244
|
createWalletAssist(e, s, r) {
|
|
243
|
-
return this.createComponent(
|
|
245
|
+
return this.createComponent(
|
|
246
|
+
"wallet-assist",
|
|
247
|
+
e,
|
|
248
|
+
s,
|
|
249
|
+
r
|
|
250
|
+
);
|
|
244
251
|
}
|
|
245
252
|
/**
|
|
246
253
|
* Creates a deposit assist component
|
|
@@ -286,7 +293,12 @@ class L {
|
|
|
286
293
|
* @public
|
|
287
294
|
*/
|
|
288
295
|
createDepositRequest(e, s, r) {
|
|
289
|
-
return this.createComponent(
|
|
296
|
+
return this.createComponent(
|
|
297
|
+
"deposit-request",
|
|
298
|
+
e,
|
|
299
|
+
s,
|
|
300
|
+
r
|
|
301
|
+
);
|
|
290
302
|
}
|
|
291
303
|
/**
|
|
292
304
|
* Decodes a URL fragment into an object
|
|
@@ -297,8 +309,8 @@ class L {
|
|
|
297
309
|
decodeFragmentToObject(e) {
|
|
298
310
|
return e.slice(1).split("&").reduce(
|
|
299
311
|
(r, i) => {
|
|
300
|
-
const [n,
|
|
301
|
-
return r[decodeURIComponent(n)] = decodeURIComponent(
|
|
312
|
+
const [n, h] = i.split("=");
|
|
313
|
+
return r[decodeURIComponent(n)] = decodeURIComponent(h), r;
|
|
302
314
|
},
|
|
303
315
|
{}
|
|
304
316
|
);
|
|
@@ -307,9 +319,10 @@ class L {
|
|
|
307
319
|
export {
|
|
308
320
|
u as AgentType,
|
|
309
321
|
a as CMType,
|
|
310
|
-
|
|
322
|
+
w as EmbeddedComponent,
|
|
323
|
+
E as PersonType,
|
|
311
324
|
p as ProofStatus,
|
|
312
325
|
g as ProofTypes,
|
|
313
|
-
|
|
314
|
-
|
|
326
|
+
f as Status,
|
|
327
|
+
R as default
|
|
315
328
|
};
|