@notabene/javascript-sdk 2.12.0 → 2.13.0-next.2
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 +45 -4
- package/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +237 -2
- package/dist/cjs/package.json +6 -2
- package/dist/esm/notabene.d.ts +237 -2
- package/dist/esm/notabene.js +447 -133
- package/dist/esm/package.json +6 -2
- package/dist/notabene.d.ts +237 -2
- package/dist/notabene.js +447 -133
- package/docs/README.md +0 -4
- package/docs/_media/TransactionOptions.md +0 -4
- package/docs/types/interfaces/TransactionOptions.md +0 -4
- package/package.json +6 -2
- package/src/ivms/index.ts +5 -0
- package/src/ivms/v2Types.ts +35 -0
- package/src/notabene.ts +14 -0
- package/src/responseTransformer/README.md +164 -0
- package/src/responseTransformer/index.ts +21 -0
- package/src/responseTransformer/mappers.ts +293 -0
- package/src/responseTransformer/transformer.ts +278 -0
- package/src/responseTransformer/types.ts +60 -0
- package/src/responseTransformer/utils.ts +61 -0
- package/src/types.ts +15 -2
- package/src/utils/arbitraries.ts +0 -1
package/dist/esm/notabene.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Agent as Agent_2 } from '@taprsvp/types';
|
|
2
|
+
import type { DID as DID_2 } from '@taprsvp/types';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* A blockchain account
|
|
3
6
|
* @public
|
|
@@ -99,6 +102,11 @@ declare type BeneficiaryFields = {
|
|
|
99
102
|
destination?: Destination;
|
|
100
103
|
};
|
|
101
104
|
|
|
105
|
+
declare type BeneficiaryV2 = {
|
|
106
|
+
beneficiaryPerson: PersonV2[];
|
|
107
|
+
customerIdentification?: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
102
110
|
/**
|
|
103
111
|
* Beneficiary VASP
|
|
104
112
|
* Represents the VASP which receives the VA transfer
|
|
@@ -320,6 +328,151 @@ export declare interface ComponentResponse {
|
|
|
320
328
|
errors: ValidationError[];
|
|
321
329
|
}
|
|
322
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Transforms a Notabene component response to IVMS101 format
|
|
333
|
+
*
|
|
334
|
+
* @param response - The response from the Notabene Embedded Component
|
|
335
|
+
* @param delegateToken - The JWT delegate token for extracting the originator ID
|
|
336
|
+
* @param config - Configuration object with optional IDs
|
|
337
|
+
* @param config.originatorId - Optional originator ID (auto-extracted from delegateToken if not provided)
|
|
338
|
+
* @param config.beneficiaryId - Optional beneficiary ID (auto-generated if not provided)
|
|
339
|
+
* @param config.referenceId - Optional reference ID for the transaction
|
|
340
|
+
* @param config.originator - Optional originator data in V2 format
|
|
341
|
+
* @returns The transformed request body in IVMS101 format
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* import { componentResponseToIVMS101 } from '$lib/notabene-tx-transformer';
|
|
346
|
+
*
|
|
347
|
+
* const requestBody = componentResponseToIVMS101(
|
|
348
|
+
* result.response,
|
|
349
|
+
* session.user.token,
|
|
350
|
+
* { originator: myOriginatorData }
|
|
351
|
+
* );
|
|
352
|
+
*
|
|
353
|
+
* await fetch('/entity/${vaspDid}/tx/${txId}/append', {
|
|
354
|
+
* method: 'POST',
|
|
355
|
+
* body: JSON.stringify(requestBody)
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
export declare function componentResponseToIVMS101(response: TransactionResponse<Withdrawal>, delegateToken: string, config?: ResponseToTxRequestConfig): TransactionIVMS101Request;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Transforms a Notabene component response to a Version 2 transaction create API request body
|
|
363
|
+
*
|
|
364
|
+
* @param response - The response from the Notabene Embedded Component
|
|
365
|
+
* @param delegateToken - The JWT delegate token for extracting the originator ID
|
|
366
|
+
* @param config - Configuration object with optional IDs
|
|
367
|
+
* @param config.originatorId - Optional originator ID (auto-extracted from delegateToken if not provided)
|
|
368
|
+
* @param config.beneficiaryId - Optional beneficiary ID (auto-generated if not provided)
|
|
369
|
+
* @param config.referenceId - Optional reference ID for the transaction
|
|
370
|
+
* @returns The transformed request body ready for the Version 2 transaction create API
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* import { componentResponseToTxCreateRequest } from '$lib/notabene-tx-transformer';
|
|
375
|
+
*
|
|
376
|
+
* withdrawal.on('complete', async (result) => {
|
|
377
|
+
* const requestBody = componentResponseToTxCreateRequest(
|
|
378
|
+
* result.response,
|
|
379
|
+
* {
|
|
380
|
+
* originatorId: 'mailto:user@example.com',
|
|
381
|
+
* beneficiaryId: 'urn:beneficiary:recipient',
|
|
382
|
+
* referenceId: 'tx-12345'
|
|
383
|
+
* }
|
|
384
|
+
* );
|
|
385
|
+
*
|
|
386
|
+
* await fetch('/entity/${vaspDid}/tx', {
|
|
387
|
+
* method: 'POST',
|
|
388
|
+
* body: JSON.stringify(requestBody)
|
|
389
|
+
* });
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare function componentResponseToTxCreateRequest(response: TransactionResponse<Withdrawal>, delegateToken: string, config?: Omit<ResponseToTxRequestConfig, 'originator'>): TransactionCreateRequestV2;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Transforms a Notabene component response into txCreate, IVMS101, and confirmRelationship request bodies
|
|
397
|
+
*
|
|
398
|
+
* This is a convenience function that generates the transaction creation request,
|
|
399
|
+
* the IVMS101 data, and optionally the relationship confirmation proof in a single call,
|
|
400
|
+
* which is useful for V2 workflows where you need to create a transaction first,
|
|
401
|
+
* then append IVMS101 data to it, and finally confirm the relationship.
|
|
402
|
+
*
|
|
403
|
+
* @param response - The response from the Notabene Embedded Component
|
|
404
|
+
* @param delegateToken - The JWT delegate token for extracting the originator ID
|
|
405
|
+
* @param config - Optional configuration for IDs and reference
|
|
406
|
+
* @param config.originatorId - Optional originator ID (auto-extracted from delegateToken if not provided)
|
|
407
|
+
* @param config.beneficiaryId - Optional beneficiary ID (auto-generated if not provided)
|
|
408
|
+
* @param config.referenceId - Optional reference ID (auto-generated if not provided)
|
|
409
|
+
* @param config.originator - Optional originator data in V2 format
|
|
410
|
+
* @returns Object with `createTx`, `ivms101`, and optional `confirmRelationship` properties containing the respective request bodies
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* import { componentResponseToTxRequests } from '$lib/notabene-tx-transformer';
|
|
415
|
+
*
|
|
416
|
+
* withdrawal.on('complete', async (result) => {
|
|
417
|
+
* const { createTx, ivms101, confirmRelationship } = componentResponseToTxRequests(
|
|
418
|
+
* result.response,
|
|
419
|
+
* session.user.token,
|
|
420
|
+
* { originator: originatorData }
|
|
421
|
+
* );
|
|
422
|
+
*
|
|
423
|
+
* // First, create the transaction
|
|
424
|
+
* const txResponse = await fetch('/entity/${vaspDid}/tx', {
|
|
425
|
+
* method: 'POST',
|
|
426
|
+
* body: JSON.stringify(createTx)
|
|
427
|
+
* });
|
|
428
|
+
*
|
|
429
|
+
* // Then, append IVMS101 data
|
|
430
|
+
* const txId = txResponse.transfer['@id'];
|
|
431
|
+
* await fetch(`/entity/${vaspDid}/tx/${txId}/append`, {
|
|
432
|
+
* method: 'POST',
|
|
433
|
+
* body: JSON.stringify(ivms101)
|
|
434
|
+
* });
|
|
435
|
+
*
|
|
436
|
+
* // Finally, confirm relationship
|
|
437
|
+
* if (confirmRelationship) {
|
|
438
|
+
* await fetch(`/entity/${vaspDid}/relationship?to=${to}&from=${from}`, {
|
|
439
|
+
* method: 'PATCH',
|
|
440
|
+
* body: JSON.stringify({ proof: confirmRelationship.proof })
|
|
441
|
+
* });
|
|
442
|
+
* }
|
|
443
|
+
* });
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
export declare function componentResponseToTxRequests(response: TransactionResponse<Withdrawal>, delegateToken: string, config?: ResponseToTxRequestConfig): {
|
|
447
|
+
createTx: TransactionCreateRequestV2;
|
|
448
|
+
ivms101: TransactionIVMS101Request;
|
|
449
|
+
confirmRelationship?: {
|
|
450
|
+
proof: OwnershipProof;
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Transforms a Notabene component response to a Version 1 API request body
|
|
456
|
+
*
|
|
457
|
+
* @param response - The response from the Notabene TX Create component
|
|
458
|
+
* @returns The transformed request body ready for the Version 1 API
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* import { componentResponseToV1TxCreateRequest } from '$lib/notabene-tx-transformer';
|
|
463
|
+
*
|
|
464
|
+
* withdrawal.on('complete', async (result) => {
|
|
465
|
+
* const requestBody = componentResponseToV1TxCreateRequest(result.response);
|
|
466
|
+
*
|
|
467
|
+
* await fetch(endpointUrl, {
|
|
468
|
+
* method: 'POST',
|
|
469
|
+
* body: JSON.stringify(requestBody)
|
|
470
|
+
* });
|
|
471
|
+
* });
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
export declare function componentResponseToV1TxCreateRequest(response: TransactionResponse<Withdrawal>): TransactionCreateRequest;
|
|
475
|
+
|
|
323
476
|
export declare interface ConnectionData<T extends ComponentRequest> {
|
|
324
477
|
readonly tx: T;
|
|
325
478
|
readonly authToken?: string;
|
|
@@ -1132,6 +1285,12 @@ declare type NaturalPersonNameID = {
|
|
|
1132
1285
|
nameIdentifierType?: NaturalPersonNameTypeCode;
|
|
1133
1286
|
};
|
|
1134
1287
|
|
|
1288
|
+
declare type NaturalPersonNameIDV2 = {
|
|
1289
|
+
primaryIdentifier?: string;
|
|
1290
|
+
secondaryIdentifier?: string;
|
|
1291
|
+
naturalPersonNameIdentifierType?: NaturalPersonNameTypeCode;
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1135
1294
|
/**
|
|
1136
1295
|
* Natural Person Name Type Code
|
|
1137
1296
|
* Specifies the type of name for a natural person
|
|
@@ -1140,6 +1299,14 @@ declare type NaturalPersonNameID = {
|
|
|
1140
1299
|
*/
|
|
1141
1300
|
declare type NaturalPersonNameTypeCode = 'ALIA' | 'BIRT' | 'MAID' | 'LEGL' | 'MISC';
|
|
1142
1301
|
|
|
1302
|
+
declare type NaturalPersonNameV2 = Omit<NaturalPersonName, 'nameIdentifier'> & {
|
|
1303
|
+
nameIdentifier?: NaturalPersonNameIDV2[];
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
|
|
1307
|
+
name: NaturalPersonNameV2;
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1143
1310
|
/**
|
|
1144
1311
|
* Primary constructor for Notabene UX elements
|
|
1145
1312
|
*
|
|
@@ -1308,7 +1475,12 @@ declare type Originator = {
|
|
|
1308
1475
|
* @public
|
|
1309
1476
|
*/
|
|
1310
1477
|
declare type OriginatorFields = {
|
|
1311
|
-
source?: Source;
|
|
1478
|
+
source?: Source | Source[];
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
declare type OriginatorV2 = {
|
|
1482
|
+
originatorPerson: PersonV2[];
|
|
1483
|
+
customerIdentification?: string;
|
|
1312
1484
|
};
|
|
1313
1485
|
|
|
1314
1486
|
/**
|
|
@@ -1399,6 +1571,11 @@ export declare enum PersonType {
|
|
|
1399
1571
|
SELF = "self"
|
|
1400
1572
|
}
|
|
1401
1573
|
|
|
1574
|
+
declare type PersonV2 = Omit<Person, 'naturalPerson'> & {
|
|
1575
|
+
naturalPerson?: NaturalPersonV2;
|
|
1576
|
+
accountNumber?: string[];
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1402
1579
|
/**
|
|
1403
1580
|
* Status of the ownership proof verification process
|
|
1404
1581
|
*
|
|
@@ -1497,6 +1674,13 @@ export declare type ResizeRequest = {
|
|
|
1497
1674
|
height: number;
|
|
1498
1675
|
};
|
|
1499
1676
|
|
|
1677
|
+
export declare interface ResponseToTxRequestConfig {
|
|
1678
|
+
originatorId?: DID_2;
|
|
1679
|
+
beneficiaryId?: DID_2;
|
|
1680
|
+
referenceId?: string;
|
|
1681
|
+
originator?: OriginatorV2;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1500
1684
|
/**
|
|
1501
1685
|
* Ownership Proof using Screenshot
|
|
1502
1686
|
* @public
|
|
@@ -1680,6 +1864,44 @@ export declare interface Transaction extends ComponentRequest {
|
|
|
1680
1864
|
*/
|
|
1681
1865
|
export declare type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
|
|
1682
1866
|
|
|
1867
|
+
export declare interface TransactionCreateRequest {
|
|
1868
|
+
transactionAsset: any;
|
|
1869
|
+
transactionAmount: string;
|
|
1870
|
+
beneficiaryDid?: string;
|
|
1871
|
+
originatorVASPdid: string;
|
|
1872
|
+
beneficiaryVASPdid?: string;
|
|
1873
|
+
beneficiaryVASPname?: string;
|
|
1874
|
+
beneficiaryVASPwebsite?: string;
|
|
1875
|
+
transactionBlockchainInfo: {
|
|
1876
|
+
origin?: string;
|
|
1877
|
+
destination?: string;
|
|
1878
|
+
};
|
|
1879
|
+
beneficiaryProof?: any;
|
|
1880
|
+
beneficiary?: any;
|
|
1881
|
+
originator?: any;
|
|
1882
|
+
originatorEqualsBeneficiary?: boolean;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
export declare interface TransactionCreateRequestV2 {
|
|
1886
|
+
originator: {
|
|
1887
|
+
'@id': string;
|
|
1888
|
+
};
|
|
1889
|
+
beneficiary: {
|
|
1890
|
+
'@id': string;
|
|
1891
|
+
};
|
|
1892
|
+
asset: string;
|
|
1893
|
+
amount: string;
|
|
1894
|
+
agents: Agent_2[];
|
|
1895
|
+
ref: string;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
export declare interface TransactionIVMS101Request {
|
|
1899
|
+
ivms101: {
|
|
1900
|
+
originator?: OriginatorV2;
|
|
1901
|
+
beneficiary?: BeneficiaryV2;
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1683
1905
|
/**
|
|
1684
1906
|
* Configuration options for Transaction components
|
|
1685
1907
|
* @public
|
|
@@ -1690,7 +1912,6 @@ export declare interface TransactionOptions {
|
|
|
1690
1912
|
microTransfer?: {
|
|
1691
1913
|
destination: BlockchainAddress;
|
|
1692
1914
|
amountSubunits: string;
|
|
1693
|
-
timeout?: number;
|
|
1694
1915
|
};
|
|
1695
1916
|
fallbacks?: ProofTypes[];
|
|
1696
1917
|
deminimis?: ThresholdOptions;
|
|
@@ -1915,14 +2136,28 @@ export declare interface Wallet extends Agent {
|
|
|
1915
2136
|
* Represents a warning component message
|
|
1916
2137
|
* @param message - Warning message
|
|
1917
2138
|
* @param description - Description of the warning message
|
|
2139
|
+
* @param identifier - Identifier code of the warning message
|
|
1918
2140
|
* @public
|
|
1919
2141
|
*/
|
|
1920
2142
|
declare type Warning = {
|
|
1921
2143
|
type: CMType.WARNING;
|
|
1922
2144
|
message: string;
|
|
1923
2145
|
description?: string;
|
|
2146
|
+
identifier?: WarningIdentifierCode;
|
|
1924
2147
|
};
|
|
1925
2148
|
|
|
2149
|
+
/**
|
|
2150
|
+
* Identifier codes for warning messages
|
|
2151
|
+
* @public
|
|
2152
|
+
*/
|
|
2153
|
+
export declare enum WarningIdentifierCode {
|
|
2154
|
+
WALLET_ADDRESS_NOT_CONNECTED = "WALLET_ADDRESS_NOT_CONNECTED",
|
|
2155
|
+
WALLET_LOCKED = "WALLET_LOCKED",
|
|
2156
|
+
WALLET_UNREACHABLE = "WALLET_UNREACHABLE",
|
|
2157
|
+
JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE = "JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE",
|
|
2158
|
+
IDV_UNAVAILABLE = "IDV_UNAVAILABLE"
|
|
2159
|
+
}
|
|
2160
|
+
|
|
1926
2161
|
/**
|
|
1927
2162
|
* An object representing a withdrawal transaction
|
|
1928
2163
|
* @public
|