@notabene/javascript-sdk 2.16.0-next.4 → 2.16.0-next.6

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.
@@ -878,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
878
878
  declare type DepositRequestFields = {
879
879
  destination: BlockchainAddress | CAIP10;
880
880
  asset: TransactionAsset;
881
- amountDecimal: number;
881
+ amountDecimal: string | number;
882
882
  travelAddress?: TravelAddress;
883
883
  cryptoCredential?: CryptoCredential;
884
884
  };
@@ -3219,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
3219
3219
  agent: Agent;
3220
3220
  counterparty: Counterparty;
3221
3221
  asset: TransactionAsset;
3222
- amountDecimal: number;
3222
+ amountDecimal: string | number;
3223
3223
  proof?: OwnershipProof;
3224
3224
  assetPrice?: {
3225
3225
  price: number;
@@ -3516,13 +3516,37 @@ export declare interface VASP extends Agent {
3516
3516
  }
3517
3517
 
3518
3518
  /**
3519
- * Options for which VASPs to be searchable
3519
+ * Options controlling which VASPs are listed and searchable in the picker.
3520
+ *
3521
+ * Two mutually exclusive variants:
3522
+ *
3523
+ * - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
3524
+ * - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
3525
+ *
3526
+ * `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
3527
+ * TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
3528
+ *
3529
+ * @example V1
3530
+ * ```ts
3531
+ * { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
3532
+ * ```
3533
+ *
3534
+ * @example V2
3535
+ * ```ts
3536
+ * { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
3537
+ * ```
3538
+ *
3520
3539
  * @public
3521
3540
  */
3522
3541
  export declare type VASPOptions = {
3523
3542
  addUnknown?: boolean;
3524
3543
  onlyActive?: boolean;
3525
3544
  searchable?: VASPSearchControl[];
3545
+ } | {
3546
+ searchable?: undefined;
3547
+ addUnknown?: boolean;
3548
+ onlyActive?: boolean;
3549
+ showTrustStatus?: VASPTrustStatus[];
3526
3550
  };
3527
3551
 
3528
3552
  /**
@@ -3538,6 +3562,15 @@ export declare enum VASPSearchControl {
3538
3562
  PENDING = "pending"
3539
3563
  }
3540
3564
 
3565
+ /**
3566
+ * Trust status assigned to a VASP in the Notabene network.
3567
+ *
3568
+ * Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
3569
+ *
3570
+ * @public
3571
+ */
3572
+ export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
3573
+
3541
3574
  /**
3542
3575
  * A wallet agent acting on behalf of the counterparty
3543
3576
  * @public
@@ -10,7 +10,7 @@
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
12
  "packageManager": "yarn@4.5.1",
13
- "version": "2.16.0-next.4",
13
+ "version": "2.16.0-next.6",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
@@ -878,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
878
878
  declare type DepositRequestFields = {
879
879
  destination: BlockchainAddress | CAIP10;
880
880
  asset: TransactionAsset;
881
- amountDecimal: number;
881
+ amountDecimal: string | number;
882
882
  travelAddress?: TravelAddress;
883
883
  cryptoCredential?: CryptoCredential;
884
884
  };
@@ -3219,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
3219
3219
  agent: Agent;
3220
3220
  counterparty: Counterparty;
3221
3221
  asset: TransactionAsset;
3222
- amountDecimal: number;
3222
+ amountDecimal: string | number;
3223
3223
  proof?: OwnershipProof;
3224
3224
  assetPrice?: {
3225
3225
  price: number;
@@ -3516,13 +3516,37 @@ export declare interface VASP extends Agent {
3516
3516
  }
3517
3517
 
3518
3518
  /**
3519
- * Options for which VASPs to be searchable
3519
+ * Options controlling which VASPs are listed and searchable in the picker.
3520
+ *
3521
+ * Two mutually exclusive variants:
3522
+ *
3523
+ * - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
3524
+ * - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
3525
+ *
3526
+ * `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
3527
+ * TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
3528
+ *
3529
+ * @example V1
3530
+ * ```ts
3531
+ * { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
3532
+ * ```
3533
+ *
3534
+ * @example V2
3535
+ * ```ts
3536
+ * { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
3537
+ * ```
3538
+ *
3520
3539
  * @public
3521
3540
  */
3522
3541
  export declare type VASPOptions = {
3523
3542
  addUnknown?: boolean;
3524
3543
  onlyActive?: boolean;
3525
3544
  searchable?: VASPSearchControl[];
3545
+ } | {
3546
+ searchable?: undefined;
3547
+ addUnknown?: boolean;
3548
+ onlyActive?: boolean;
3549
+ showTrustStatus?: VASPTrustStatus[];
3526
3550
  };
3527
3551
 
3528
3552
  /**
@@ -3538,6 +3562,15 @@ export declare enum VASPSearchControl {
3538
3562
  PENDING = "pending"
3539
3563
  }
3540
3564
 
3565
+ /**
3566
+ * Trust status assigned to a VASP in the Notabene network.
3567
+ *
3568
+ * Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
3569
+ *
3570
+ * @public
3571
+ */
3572
+ export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
3573
+
3541
3574
  /**
3542
3575
  * A wallet agent acting on behalf of the counterparty
3543
3576
  * @public
@@ -12223,7 +12223,7 @@ function _c(e) {
12223
12223
  account: n == null ? void 0 : n.account,
12224
12224
  proof: m,
12225
12225
  asset: (n == null ? void 0 : n.asset) || (typeof l.transactionAsset == "string" ? l.transactionAsset : (h = l.transactionAsset) == null ? void 0 : h.caip19) || "",
12226
- amountDecimal: (n == null ? void 0 : n.amountDecimal) || (l.transactionAmount ? parseFloat(l.transactionAmount) : 0),
12226
+ amountDecimal: (n == null ? void 0 : n.amountDecimal) ?? l.transactionAmount ?? 0,
12227
12227
  customer: n == null ? void 0 : n.customer
12228
12228
  };
12229
12229
  return mc(s, l, d);
@@ -10,7 +10,7 @@
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
12
  "packageManager": "yarn@4.5.1",
13
- "version": "2.16.0-next.4",
13
+ "version": "2.16.0-next.6",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
@@ -878,7 +878,7 @@ export declare interface DepositRequest extends DepositRequestFields, ComponentR
878
878
  declare type DepositRequestFields = {
879
879
  destination: BlockchainAddress | CAIP10;
880
880
  asset: TransactionAsset;
881
- amountDecimal: number;
881
+ amountDecimal: string | number;
882
882
  travelAddress?: TravelAddress;
883
883
  cryptoCredential?: CryptoCredential;
884
884
  };
@@ -3219,7 +3219,7 @@ export declare interface Transaction extends ComponentRequest {
3219
3219
  agent: Agent;
3220
3220
  counterparty: Counterparty;
3221
3221
  asset: TransactionAsset;
3222
- amountDecimal: number;
3222
+ amountDecimal: string | number;
3223
3223
  proof?: OwnershipProof;
3224
3224
  assetPrice?: {
3225
3225
  price: number;
@@ -3516,13 +3516,37 @@ export declare interface VASP extends Agent {
3516
3516
  }
3517
3517
 
3518
3518
  /**
3519
- * Options for which VASPs to be searchable
3519
+ * Options controlling which VASPs are listed and searchable in the picker.
3520
+ *
3521
+ * Two mutually exclusive variants:
3522
+ *
3523
+ * - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
3524
+ * - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
3525
+ *
3526
+ * `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
3527
+ * TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
3528
+ *
3529
+ * @example V1
3530
+ * ```ts
3531
+ * { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
3532
+ * ```
3533
+ *
3534
+ * @example V2
3535
+ * ```ts
3536
+ * { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
3537
+ * ```
3538
+ *
3520
3539
  * @public
3521
3540
  */
3522
3541
  export declare type VASPOptions = {
3523
3542
  addUnknown?: boolean;
3524
3543
  onlyActive?: boolean;
3525
3544
  searchable?: VASPSearchControl[];
3545
+ } | {
3546
+ searchable?: undefined;
3547
+ addUnknown?: boolean;
3548
+ onlyActive?: boolean;
3549
+ showTrustStatus?: VASPTrustStatus[];
3526
3550
  };
3527
3551
 
3528
3552
  /**
@@ -3538,6 +3562,15 @@ export declare enum VASPSearchControl {
3538
3562
  PENDING = "pending"
3539
3563
  }
3540
3564
 
3565
+ /**
3566
+ * Trust status assigned to a VASP in the Notabene network.
3567
+ *
3568
+ * Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
3569
+ *
3570
+ * @public
3571
+ */
3572
+ export declare type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
3573
+
3541
3574
  /**
3542
3575
  * A wallet agent acting on behalf of the counterparty
3543
3576
  * @public
package/dist/notabene.js CHANGED
@@ -12223,7 +12223,7 @@ function _c(e) {
12223
12223
  account: n == null ? void 0 : n.account,
12224
12224
  proof: m,
12225
12225
  asset: (n == null ? void 0 : n.asset) || (typeof l.transactionAsset == "string" ? l.transactionAsset : (h = l.transactionAsset) == null ? void 0 : h.caip19) || "",
12226
- amountDecimal: (n == null ? void 0 : n.amountDecimal) || (l.transactionAmount ? parseFloat(l.transactionAmount) : 0),
12226
+ amountDecimal: (n == null ? void 0 : n.amountDecimal) ?? l.transactionAmount ?? 0,
12227
12227
  customer: n == null ? void 0 : n.customer
12228
12228
  };
12229
12229
  return mc(s, l, d);
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
12
  "packageManager": "yarn@4.5.1",
13
- "version": "2.16.0-next.4",
13
+ "version": "2.16.0-next.6",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
package/src/notabene.ts CHANGED
@@ -63,6 +63,7 @@ import type {
63
63
  ValidationError,
64
64
  VASP,
65
65
  VASPOptions,
66
+ VASPTrustStatus,
66
67
  Wallet,
67
68
  Withdrawal,
68
69
  } from './types';
@@ -189,6 +190,7 @@ export type {
189
190
  ValidationError,
190
191
  VASP,
191
192
  VASPOptions,
193
+ VASPTrustStatus,
192
194
  Wallet,
193
195
  Withdrawal,
194
196
  };
@@ -191,9 +191,7 @@ export function componentResponseToV1TxCreateRequest(
191
191
  ? txCreate.transactionAsset
192
192
  : txCreate.transactionAsset?.caip19) ||
193
193
  '',
194
- amountDecimal:
195
- value?.amountDecimal ||
196
- (txCreate.transactionAmount ? parseFloat(txCreate.transactionAmount) : 0),
194
+ amountDecimal: value?.amountDecimal ?? txCreate.transactionAmount ?? 0,
197
195
  customer: value?.customer,
198
196
  } as Withdrawal;
199
197
 
package/src/types.ts CHANGED
@@ -516,7 +516,7 @@ type BeneficiaryFields = {
516
516
  type DepositRequestFields = {
517
517
  destination: BlockchainAddress | CAIP10;
518
518
  asset: TransactionAsset;
519
- amountDecimal: number;
519
+ amountDecimal: string | number;
520
520
  travelAddress?: TravelAddress;
521
521
  cryptoCredential?: CryptoCredential;
522
522
  };
@@ -572,7 +572,7 @@ export interface Transaction extends ComponentRequest {
572
572
  agent: Agent;
573
573
  counterparty: Counterparty;
574
574
  asset: TransactionAsset;
575
- amountDecimal: number;
575
+ amountDecimal: string | number;
576
576
  proof?: OwnershipProof;
577
577
  assetPrice?: {
578
578
  price: number;
@@ -789,14 +789,53 @@ export enum VASPSearchControl {
789
789
  }
790
790
 
791
791
  /**
792
- * Options for which VASPs to be searchable
792
+ * Trust status assigned to a VASP in the Notabene network.
793
+ *
794
+ * Used by {@link VASPOptions.showTrustStatus} to filter which VASPs are listed in the picker.
795
+ *
793
796
  * @public
794
797
  */
795
- export type VASPOptions = {
796
- addUnknown?: boolean;
797
- onlyActive?: boolean;
798
- searchable?: VASPSearchControl[]; // If array left empty all VASPs will be searchable
799
- };
798
+ export type VASPTrustStatus = 'TRUSTED' | 'NEW' | 'FLAGGED' | 'BANNED';
799
+
800
+ /**
801
+ * Options controlling which VASPs are listed and searchable in the picker.
802
+ *
803
+ * Two mutually exclusive variants:
804
+ *
805
+ * - **V1** — `addUnknown`, `onlyActive`, `searchable` (filters by {@link VASPSearchControl} status).
806
+ * - **V2** — `addUnknown`, `onlyActive`, `showTrustStatus` (filters by {@link VASPTrustStatus}).
807
+ *
808
+ * `searchable` (V1-only) cannot be combined with `showTrustStatus` (V2-only);
809
+ * TypeScript will reject the mix at compile time. `addUnknown` and `onlyActive` are valid in both variants.
810
+ *
811
+ * @example V1
812
+ * ```ts
813
+ * { addUnknown: true, onlyActive: true, searchable: [VASPSearchControl.ALLOWED] }
814
+ * ```
815
+ *
816
+ * @example V2
817
+ * ```ts
818
+ * { addUnknown: true, onlyActive: true, showTrustStatus: ['TRUSTED', 'NEW'] }
819
+ * ```
820
+ *
821
+ * @public
822
+ */
823
+ export type VASPOptions =
824
+ // V1 vasps options
825
+ | {
826
+ addUnknown?: boolean;
827
+ onlyActive?: boolean;
828
+ searchable?: VASPSearchControl[]; // If array left empty all VASPs will be searchable
829
+ }
830
+ // V2 vasps options
831
+ | {
832
+ // Typing `searchable` as `undefined` (rather than omitting it) makes TS reject
833
+ // mixing V1 and V2 options, e.g. { searchable: [...], showTrustStatus: [...] }.
834
+ searchable?: undefined;
835
+ addUnknown?: boolean;
836
+ onlyActive?: boolean;
837
+ showTrustStatus?: VASPTrustStatus[];
838
+ };
800
839
 
801
840
  /**
802
841
  * Available methods for identity verification
@@ -24,6 +24,7 @@ import type {
24
24
  TransactionOptions,
25
25
  TravelAddress,
26
26
  VASPOptions,
27
+ VASPTrustStatus,
27
28
  Withdrawal,
28
29
  } from '../types';
29
30
  import {
@@ -31,6 +32,7 @@ import {
31
32
  PersonType,
32
33
  ProofTypes,
33
34
  ValidationSections,
35
+ VASPSearchControl,
34
36
  } from '../types';
35
37
  import {
36
38
  CAIP10_MATCHER,
@@ -91,6 +93,18 @@ export const arbitraryAgent = (): fc.Arbitrary<Agent> =>
91
93
  verified: fc.boolean(),
92
94
  });
93
95
 
96
+ // Generates decimal strings with 18+ fractional digits to test precision beyond float64
97
+ const arbitraryHighPrecisionDecimal = (): fc.Arbitrary<string> =>
98
+ fc
99
+ .tuple(
100
+ fc.integer({ min: 0, max: 999999 }),
101
+ fc.stringMatching(/^\d{18,24}$/),
102
+ )
103
+ .map(([integer, fractional]) => `${integer}.${fractional}`);
104
+
105
+ const arbitraryAmountDecimal = (): fc.Arbitrary<string | number> =>
106
+ fc.oneof(fc.float({ min: 0, noNaN: true }), arbitraryHighPrecisionDecimal());
107
+
94
108
  export const arbitraryCounterparty = (): fc.Arbitrary<Counterparty> =>
95
109
  arbitraryNaturalPerson(); // For simplicity we'll just use NaturalPerson
96
110
 
@@ -99,7 +113,7 @@ export const arbitraryWithdrawal = (): fc.Arbitrary<Withdrawal> =>
99
113
  agent: arbitraryAgent(),
100
114
  counterparty: arbitraryCounterparty(),
101
115
  asset: arbitraryTransactionAsset(),
102
- amountDecimal: fc.float(),
116
+ amountDecimal: arbitraryAmountDecimal(),
103
117
  destination: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
104
118
  });
105
119
 
@@ -149,7 +163,7 @@ export const arbitraryDepositRequest = (): fc.Arbitrary<DepositRequest> =>
149
163
  agent: arbitraryAgent(),
150
164
  counterparty: arbitraryCounterparty(),
151
165
  asset: arbitraryTransactionAsset(),
152
- amountDecimal: fc.float(),
166
+ amountDecimal: arbitraryAmountDecimal(),
153
167
  destination: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
154
168
  travelAddress: fc.option(arbitraryTravelAddress()),
155
169
  cryptoCredential: fc.option(arbitraryCryptoCredential()),
@@ -194,10 +208,33 @@ export const arbitraryFieldTypes = (): fc.Arbitrary<FieldTypes> =>
194
208
  });
195
209
 
196
210
  export const arbitraryVASPOptions = (): fc.Arbitrary<VASPOptions> =>
197
- fc.record({
198
- addUnknown: fc.option(fc.boolean()),
199
- onlyActive: fc.option(fc.boolean()),
200
- });
211
+ fc.oneof(
212
+ fc.record({
213
+ addUnknown: fc.option(fc.boolean(), { nil: undefined }),
214
+ onlyActive: fc.option(fc.boolean(), { nil: undefined }),
215
+ searchable: fc.option(
216
+ fc.array(
217
+ fc.constantFrom(VASPSearchControl.ALLOWED, VASPSearchControl.PENDING),
218
+ ),
219
+ { nil: undefined },
220
+ ),
221
+ }),
222
+ fc.record({
223
+ addUnknown: fc.option(fc.boolean(), { nil: undefined }),
224
+ onlyActive: fc.option(fc.boolean(), { nil: undefined }),
225
+ showTrustStatus: fc.option(
226
+ fc.array(
227
+ fc.constantFrom<VASPTrustStatus>(
228
+ 'TRUSTED',
229
+ 'NEW',
230
+ 'FLAGGED',
231
+ 'BANNED',
232
+ ),
233
+ ),
234
+ { nil: undefined },
235
+ ),
236
+ }),
237
+ );
201
238
 
202
239
  export const arbitraryTransactionOptions =
203
240
  (): fc.Arbitrary<TransactionOptions> =>
@@ -249,7 +286,7 @@ export const arbitraryDeposit = (): fc.Arbitrary<Deposit> =>
249
286
  agent: arbitraryAgent(),
250
287
  counterparty: arbitraryCounterparty(),
251
288
  asset: arbitraryTransactionAsset(),
252
- amountDecimal: fc.float({ min: 0, max: 1e6 }),
289
+ amountDecimal: arbitraryAmountDecimal(),
253
290
  origin: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
254
291
  source: fc.oneof(arbitraryBlockchainAddress(), arbitraryCAIP10()),
255
292
  });