@notabene/javascript-sdk 2.15.0-next.1 → 2.15.0-next.3
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 +59 -0
- package/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +509 -4
- package/dist/cjs/package.json +3 -5
- package/dist/esm/notabene.d.ts +509 -4
- package/dist/esm/notabene.js +9 -7
- package/dist/esm/package.json +3 -5
- package/dist/notabene.d.ts +509 -4
- package/dist/notabene.js +9 -7
- package/package.json +3 -5
- package/src/__tests__/notabene.test.ts +50 -0
- package/src/notabene.ts +10 -9
- package/src/types.ts +3 -3
package/dist/notabene.js
CHANGED
|
@@ -368,27 +368,29 @@ function Mn(e) {
|
|
|
368
368
|
return e.replace(/\s+/g, "").toUpperCase();
|
|
369
369
|
}
|
|
370
370
|
function kn(e) {
|
|
371
|
-
|
|
371
|
+
var l;
|
|
372
|
+
if (!((l = e.name) != null && l.nameIdentifier) || e.name.nameIdentifier.length === 0)
|
|
372
373
|
return "";
|
|
373
|
-
const d = e.name.find((
|
|
374
|
+
const d = e.name.nameIdentifier.find((s) => s.naturalPersonNameIdentifierType === "LEGL") || e.name.nameIdentifier[0], m = [];
|
|
374
375
|
return d.secondaryIdentifier && m.push(d.secondaryIdentifier), m.push(d.primaryIdentifier), m.join(" ");
|
|
375
376
|
}
|
|
376
377
|
function Cn(e) {
|
|
377
|
-
|
|
378
|
+
var m;
|
|
379
|
+
return !((m = e.name) != null && m.nameIdentifier) || e.name.nameIdentifier.length === 0 ? "" : (e.name.nameIdentifier.find((l) => l.legalPersonNameIdentifierType === "LEGL") || e.name.nameIdentifier[0]).legalPersonName;
|
|
378
380
|
}
|
|
379
381
|
function ai(e) {
|
|
380
|
-
return
|
|
382
|
+
return e.originatorPerson.map((d) => d.naturalPerson ? kn(d.naturalPerson) : d.legalPerson ? Cn(d.legalPerson) : "").filter((d) => d.length > 0);
|
|
381
383
|
}
|
|
382
384
|
function oi(e) {
|
|
383
|
-
return
|
|
385
|
+
return e.beneficiaryPerson.map((d) => d.naturalPerson ? kn(d.naturalPerson) : d.legalPerson ? Cn(d.legalPerson) : "").filter((d) => d.length > 0);
|
|
384
386
|
}
|
|
385
387
|
async function ui(e) {
|
|
386
388
|
let n;
|
|
387
389
|
if (typeof e == "string")
|
|
388
390
|
n = e;
|
|
389
|
-
else if ("
|
|
391
|
+
else if ("originatorPerson" in e)
|
|
390
392
|
n = ai(e).join(" ");
|
|
391
|
-
else if ("
|
|
393
|
+
else if ("beneficiaryPerson" in e)
|
|
392
394
|
n = oi(e).join(" ");
|
|
393
395
|
else
|
|
394
396
|
throw new Error("Invalid input type. Expected string, IVMS101 Originator, or IVMS101 Beneficiary");
|
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.
|
|
13
|
+
"version": "2.15.0-next.3",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@semantic-release/git": "^10.0.1",
|
|
73
73
|
"@semantic-release/gitlab": "^13.2.1",
|
|
74
74
|
"@semantic-release/npm": "^12.0.1",
|
|
75
|
+
"@taprsvp/types": "^1.14.0",
|
|
75
76
|
"@vitest/coverage-v8": "^2.1.8",
|
|
76
77
|
"eslint": "^9.14.0",
|
|
77
78
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"fast-check": "^3.23.1",
|
|
80
81
|
"globals": "^15.11.0",
|
|
81
82
|
"husky": "^9.1.6",
|
|
83
|
+
"jose": "^6.1.0",
|
|
82
84
|
"jsdom": "^25.0.1",
|
|
83
85
|
"lint-staged": "^15.2.10",
|
|
84
86
|
"prettier": "^3.3.3",
|
|
@@ -104,9 +106,5 @@
|
|
|
104
106
|
"extends": [
|
|
105
107
|
"@commitlint/config-conventional"
|
|
106
108
|
]
|
|
107
|
-
},
|
|
108
|
-
"dependencies": {
|
|
109
|
-
"@taprsvp/types": "^1.13.0",
|
|
110
|
-
"jose": "^6.1.0"
|
|
111
109
|
}
|
|
112
110
|
}
|
|
@@ -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;
|
package/src/types.ts
CHANGED
|
@@ -878,9 +878,9 @@ export interface ThresholdOptions {
|
|
|
878
878
|
* @public
|
|
879
879
|
*/
|
|
880
880
|
export type SectionOption =
|
|
881
|
-
| ProofTypes.SelfDeclaration
|
|
882
|
-
| ProofTypes.Screenshot
|
|
883
|
-
| ProofTypes.MicroTransfer
|
|
881
|
+
| 'self-declaration' // ProofTypes.SelfDeclaration
|
|
882
|
+
| 'screenshot' // ProofTypes.Screenshot
|
|
883
|
+
| 'microtransfer' // ProofTypes.MicroTransfer
|
|
884
884
|
| 'signature'
|
|
885
885
|
| 'manual-signing'
|
|
886
886
|
| 'add-vasp';
|