@notabene/javascript-sdk 2.15.0-next.2 → 2.15.0

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 CHANGED
@@ -64,6 +64,10 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
64
64
  - [Only allow first party transactions](#only-allow-first-party-transactions)
65
65
  - [Only VASP to VASP transactions](#only-vasp-to-vasp-transactions)
66
66
  - [Only Self-hosted wallet transactions](#only-self-hosted-wallet-transactions)
67
+ - [Agent Section Layout](#agent-section-layout)
68
+ - [Section Options](#section-options)
69
+ - [Fallback Promotion](#fallback-promotion)
70
+ - [Legacy Behavior](#legacy-behavior)
67
71
  - [Configuring ownership proofs](#configuring-ownership-proofs)
68
72
  - [Supporting Micro Transactions (aka Satoshi tests)](#supporting-micro-transactions-aka-satoshi-tests)
69
73
  - [Fallback Proof Options](#fallback-proof-options)
@@ -747,10 +751,16 @@ import Notabene, {
747
751
  AgentType,
748
752
  PersonType,
749
753
  ProofTypes,
754
+ type SectionOption,
750
755
  } from '@notabene/javascript-sdk';
751
756
 
752
757
  const options: TransactionOptions = {
753
758
  jurisdiction: "US", // Defaults to the jurisdiction associated with customer token
759
+ agentSections: { // Explicit control over agent selection layout
760
+ main: ['signature', 'screenshot', 'microtransfer'],
761
+ fallback: ['add-vasp', 'self-declaration'],
762
+ // When agentSections is set, proofs.fallbacks and vasps.addUnknown below are ignored
763
+ },
754
764
  proofs: {
755
765
  reuseProof: true, // Defaults true
756
766
  microTransfer: {
@@ -893,6 +903,55 @@ const options: TransactionOptions = {
893
903
  };
894
904
  ```
895
905
 
906
+ ### Agent Section Layout
907
+
908
+ The `agentSections` option gives explicit control over which options appear in the main selection area vs. behind the "Can't find what you're looking for?" fallback toggle in the agent selection step.
909
+
910
+ ```ts
911
+ const options: TransactionOptions = {
912
+ agentSections: {
913
+ main: ['signature', 'screenshot', 'microtransfer'],
914
+ fallback: ['add-vasp', 'self-declaration'],
915
+ },
916
+ };
917
+ ```
918
+
919
+ When `agentSections` is provided, the following legacy fields are ignored:
920
+ - `proofs.fallbacks` — use `agentSections.fallback` instead
921
+ - `vasps.addUnknown` — include `'add-vasp'` in `agentSections` instead
922
+
923
+ Fields like `proofs.deminimis`, `proofs.microTransfer`, and `proofs.reuseProof` continue to work as before.
924
+
925
+ #### Section Options
926
+
927
+ | Option | Flow | Description |
928
+ |--------|------|-------------|
929
+ | `'signature'` | Self-hosted | Wallet connection for ownership proof via signature |
930
+ | `'self-declaration'` | Self-hosted | Self-declaration of wallet ownership (`ProofTypes.SelfDeclaration`) |
931
+ | `'screenshot'` | Self-hosted | Ownership proof via screenshot upload (`ProofTypes.Screenshot`) |
932
+ | `'microtransfer'` | Self-hosted | Ownership proof via micro-transfer (`ProofTypes.MicroTransfer`) |
933
+ | `'manual-signing'` | Self-hosted | Ownership proof via manual message signing (no `ProofTypes` equivalent) |
934
+ | `'add-vasp'` | Hosted | Manually add an unlisted exchange/VASP |
935
+
936
+ Options are automatically filtered by flow — e.g. `'add-vasp'` is ignored in the self-hosted tab, `'signature'` is ignored in the hosted tab. Including an option implicitly enables that capability (e.g. `'add-vasp'` enables VASP creation without needing `vasps.addUnknown`).
937
+
938
+ #### Fallback Promotion
939
+
940
+ When the main section has **no options** (either empty, omitted, or all filtered out for the current flow), fallback options are automatically promoted and shown inline instead of behind the toggle.
941
+
942
+ ```ts
943
+ // Only fallback options — these get promoted to main since main is empty
944
+ const options: TransactionOptions = {
945
+ agentSections: {
946
+ fallback: ['self-declaration'],
947
+ },
948
+ };
949
+ ```
950
+
951
+ #### Legacy Behavior
952
+
953
+ When `agentSections` is **not** provided, the existing behavior using `proofs.fallbacks` and `vasps.addUnknown` is preserved.
954
+
896
955
  ### Configuring ownership proofs
897
956
 
898
957
  By default components support message signing proofs.
@@ -1345,6 +1345,15 @@ declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
1345
1345
  name: NaturalPersonNameV2;
1346
1346
  };
1347
1347
 
1348
+ /**
1349
+ * Primary constructor for Notabene UX elements
1350
+ *
1351
+ * This class provides methods to create and manage various Notabene components
1352
+ * such as withdrawal assist, deposit assist, connect, and deposit request.
1353
+ * It also handles URL generation and fragment decoding for these components.
1354
+ *
1355
+ * @public
1356
+ */
1348
1357
  declare class Notabene {
1349
1358
  private nodeUrl?;
1350
1359
  private authToken?;
@@ -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.15.0-next.2",
13
+ "version": "2.15.0",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
@@ -1345,6 +1345,15 @@ declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
1345
1345
  name: NaturalPersonNameV2;
1346
1346
  };
1347
1347
 
1348
+ /**
1349
+ * Primary constructor for Notabene UX elements
1350
+ *
1351
+ * This class provides methods to create and manage various Notabene components
1352
+ * such as withdrawal assist, deposit assist, connect, and deposit request.
1353
+ * It also handles URL generation and fragment decoding for these components.
1354
+ *
1355
+ * @public
1356
+ */
1348
1357
  declare class Notabene {
1349
1358
  private nodeUrl?;
1350
1359
  private authToken?;
@@ -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.15.0-next.2",
13
+ "version": "2.15.0",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
@@ -1345,6 +1345,15 @@ declare type NaturalPersonV2 = Omit<NaturalPerson_2, 'name'> & {
1345
1345
  name: NaturalPersonNameV2;
1346
1346
  };
1347
1347
 
1348
+ /**
1349
+ * Primary constructor for Notabene UX elements
1350
+ *
1351
+ * This class provides methods to create and manage various Notabene components
1352
+ * such as withdrawal assist, deposit assist, connect, and deposit request.
1353
+ * It also handles URL generation and fragment decoding for these components.
1354
+ *
1355
+ * @public
1356
+ */
1348
1357
  declare class Notabene {
1349
1358
  private nodeUrl?;
1350
1359
  private authToken?;
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.15.0-next.2",
13
+ "version": "2.15.0",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",
@@ -340,6 +340,56 @@ describe('Notabene', () => {
340
340
  });
341
341
  });
342
342
 
343
+ describe('uxUrl trailing slash normalization', () => {
344
+ it('should strip a single trailing slash', () => {
345
+ const notabene = new Notabene({
346
+ uxUrl: 'https://connect.notabene.id/',
347
+ authToken: 'token',
348
+ });
349
+ const url = new URL(notabene.componentUrl('withdrawal-assist', {}));
350
+ expect(url.origin).toBe('https://connect.notabene.id');
351
+ });
352
+
353
+ it('should strip multiple trailing slashes', () => {
354
+ const notabene = new Notabene({
355
+ uxUrl: 'https://connect.notabene.id///',
356
+ authToken: 'token',
357
+ });
358
+ const url = new URL(notabene.componentUrl('withdrawal-assist', {}));
359
+ expect(url.origin).toBe('https://connect.notabene.id');
360
+ });
361
+
362
+ it('should leave a clean URL unchanged', () => {
363
+ const notabene = new Notabene({
364
+ uxUrl: 'https://connect.notabene.id',
365
+ authToken: 'token',
366
+ });
367
+ const url = new URL(notabene.componentUrl('withdrawal-assist', {}));
368
+ expect(url.origin).toBe('https://connect.notabene.id');
369
+ });
370
+
371
+ it('should trim whitespace', () => {
372
+ const notabene = new Notabene({
373
+ uxUrl: ' https://connect.notabene.id ',
374
+ authToken: 'token',
375
+ });
376
+ const url = new URL(notabene.componentUrl('withdrawal-assist', {}));
377
+ expect(url.origin).toBe('https://connect.notabene.id');
378
+ });
379
+
380
+ it('should throw for an invalid URL', () => {
381
+ expect(
382
+ () => new Notabene({ uxUrl: 'not-a-url', authToken: 'token' }),
383
+ ).toThrow('Invalid uxUrl');
384
+ });
385
+
386
+ it('should throw for a non-http protocol', () => {
387
+ expect(
388
+ () => new Notabene({ uxUrl: 'ftp://example.com', authToken: 'token' }),
389
+ ).toThrow('must start with http:// or https://');
390
+ });
391
+ });
392
+
343
393
  describe('createDepositAssist', () => {
344
394
  test.prop([
345
395
  fc.string({ minLength: 3 }), // authToken
package/src/notabene.ts CHANGED
@@ -221,15 +221,7 @@ export interface NotabeneConfig {
221
221
  */
222
222
  locale?: string;
223
223
  }
224
- /**
225
- * Primary constructor for Notabene UX elements
226
- *
227
- * This class provides methods to create and manage various Notabene components
228
- * such as withdrawal assist, deposit assist, connect, and deposit request.
229
- * It also handles URL generation and fragment decoding for these components.
230
- *
231
- * @public
232
- */
224
+
233
225
  /** Trim whitespace, validate, and strip trailing slashes from a URL. */
234
226
  function normalizeUrl(url: string, field: string): string {
235
227
  const normalized = url.trim().replace(/\/+$/, '');
@@ -247,6 +239,15 @@ function normalizeUrl(url: string, field: string): string {
247
239
  return normalized;
248
240
  }
249
241
 
242
+ /**
243
+ * Primary constructor for Notabene UX elements
244
+ *
245
+ * This class provides methods to create and manage various Notabene components
246
+ * such as withdrawal assist, deposit assist, connect, and deposit request.
247
+ * It also handles URL generation and fragment decoding for these components.
248
+ *
249
+ * @public
250
+ */
250
251
  export default class Notabene {
251
252
  private nodeUrl?: string;
252
253
  private authToken?: string;