@notabene/javascript-sdk 2.0.0-next.3 → 2.0.0-next.5

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.
Files changed (47) hide show
  1. package/package.json +12 -8
  2. package/.editorconfig +0 -10
  3. package/.gitlab-ci.yml +0 -85
  4. package/.husky/commit-msg +0 -4
  5. package/.husky/pre-commit +0 -4
  6. package/.husky/pre-push +0 -4
  7. package/.prettierrc +0 -4
  8. package/.releaserc.json +0 -16
  9. package/.vscode/extensions.json +0 -3
  10. package/.vscode/settings.json +0 -11
  11. package/.yarn/releases/yarn-berry.cjs +0 -925
  12. package/.yarnrc.yml +0 -3
  13. package/CODEOWNERS +0 -1
  14. package/api-extractor.json +0 -434
  15. package/eslint.config.js +0 -24
  16. package/etc/javascript-sdk.api.md +0 -363
  17. package/index.html +0 -135
  18. package/temp/javascript-sdk.api.json +0 -3509
  19. package/temp/javascript-sdk.api.md +0 -363
  20. package/ts-out/src/__tests__/notabene.test.d.ts +0 -1
  21. package/ts-out/src/__tests__/notabene.test.js +0 -97
  22. package/ts-out/src/arbitraries.d.ts +0 -4
  23. package/ts-out/src/arbitraries.js +0 -8
  24. package/ts-out/src/components/EmbeddedComponent.d.ts +0 -25
  25. package/ts-out/src/components/EmbeddedComponent.js +0 -87
  26. package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +0 -1
  27. package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +0 -132
  28. package/ts-out/src/ivms/types.d.ts +0 -252
  29. package/ts-out/src/ivms/types.js +0 -1
  30. package/ts-out/src/notabene.d.ts +0 -35
  31. package/ts-out/src/notabene.js +0 -60
  32. package/ts-out/src/types.d.ts +0 -357
  33. package/ts-out/src/types.js +0 -85
  34. package/ts-out/src/utils/MessageEventManager.d.ts +0 -12
  35. package/ts-out/src/utils/MessageEventManager.js +0 -45
  36. package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +0 -1
  37. package/ts-out/src/utils/__tests__/MessageEventManager.test.js +0 -73
  38. package/ts-out/src/utils/arbitraries.d.ts +0 -6
  39. package/ts-out/src/utils/arbitraries.js +0 -7
  40. package/ts-out/src/utils/caip.d.ts +0 -13
  41. package/ts-out/src/utils/caip.js +0 -15
  42. package/ts-out/src/utils/urls.d.ts +0 -1
  43. package/ts-out/src/utils/urls.js +0 -14
  44. package/ts-out/tsconfig.tsbuildinfo +0 -1
  45. package/tsconfig.json +0 -22
  46. package/tsconfig.tsbuildinfo +0 -1
  47. package/vite.config.js +0 -13
@@ -1,132 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
2
- import { CMType, HMType } from '../../types';
3
- import EmbeddedComponent from '../EmbeddedComponent';
4
- const url = 'https://example.com';
5
- const parentId = 'parent-container';
6
- const value = { amountDecimal: 100 };
7
- describe('EmbeddedComponent', () => {
8
- describe('creation', () => {
9
- let component;
10
- beforeEach(() => {
11
- component = new EmbeddedComponent(url, { amountDecimal: 100 });
12
- });
13
- test('sets value', () => {
14
- expect(component.value).toStrictEqual(value);
15
- });
16
- test('sets url', () => {
17
- expect(component.url).toBe(url);
18
- });
19
- });
20
- describe('iframe', () => {
21
- let document;
22
- let parentElement;
23
- let iframe;
24
- let window;
25
- let iframeWindow;
26
- beforeEach(() => {
27
- parentElement = {
28
- appendChild: vi.fn(),
29
- };
30
- iframe = {
31
- style: {},
32
- src: '',
33
- contentWindow: iframeWindow,
34
- setAttribute: vi.fn(),
35
- addEventListener: vi.fn(),
36
- };
37
- document = {
38
- createElement: vi.fn().mockReturnValue(iframe),
39
- querySelector: vi.fn().mockReturnValue(parentElement),
40
- };
41
- window = {
42
- addEventListener: vi.fn(),
43
- };
44
- vi.stubGlobal('document', document);
45
- vi.stubGlobal('window', window);
46
- });
47
- afterEach(() => {
48
- vi.unstubAllGlobals();
49
- });
50
- test('mount', () => {
51
- const component = new EmbeddedComponent(url, value);
52
- component.mount(parentId);
53
- expect(iframe?.src).toBe(url);
54
- expect(parentElement.appendChild).toHaveBeenCalledWith(iframe);
55
- });
56
- test('on', () => {
57
- const component = new EmbeddedComponent(url, value);
58
- const messageType = 'customEvent';
59
- const callback = vi.fn();
60
- component.on(messageType, callback);
61
- component.mount(parentId);
62
- // Simulate receiving a message of the specified type
63
- // and assert that the callback is called with the correct payload.
64
- });
65
- test('off', () => {
66
- const component = new EmbeddedComponent(url, value);
67
- const messageType = 'customEvent';
68
- const callback = vi.fn();
69
- component.on(messageType, callback);
70
- // Simulate receiving a message of the specified type
71
- // and assert that the callback is called with the correct payload.
72
- component.off(messageType, callback);
73
- // Simulate receiving another message of the specified type
74
- // and assert that the callback is not called.
75
- });
76
- describe('connected to iframe', () => {
77
- let messageHandler;
78
- let port;
79
- let handshake;
80
- let component;
81
- beforeEach(() => {
82
- port = {
83
- postMessage: vi.fn(),
84
- start: vi.fn(),
85
- onmessage: null,
86
- };
87
- handshake = {
88
- source: iframe.contentWindow,
89
- ports: [port],
90
- };
91
- window.addEventListener = vi
92
- .fn()
93
- .mockImplementation((event, handler) => {
94
- messageHandler = handler;
95
- });
96
- component = new EmbeddedComponent(url, value);
97
- component.mount(parentId);
98
- expect(messageHandler).toBeDefined();
99
- messageHandler(handshake);
100
- });
101
- test('send', () => {
102
- const message = {
103
- type: HMType.UPDATE,
104
- value: { amountDecimal: 100 },
105
- };
106
- component.send(message);
107
- // Assert that the message is sent to the embedded component
108
- // and handled correctly.
109
- });
110
- test('update', () => {
111
- const newValue = { amountDecimal: 200 };
112
- component.update(newValue);
113
- expect(component.value).toBe(newValue);
114
- });
115
- // TODO not sure this actually does what I want it to do
116
- test('completion', async () => {
117
- const response = { valid: true, value: 'completed' };
118
- expect(port.onmessage).toBeDefined();
119
- const promise = component.completion();
120
- // @ts-expect-error - we've already verified that port exists
121
- port.onmessage({
122
- data: { type: CMType.COMPLETE, response },
123
- });
124
- promise.then((result) => {
125
- expect(result).toBe(response);
126
- });
127
- return promise;
128
- // Assert that the completion promise resolves with the expected response.
129
- });
130
- });
131
- });
132
- });
@@ -1,252 +0,0 @@
1
- /**
2
- * 5.3.8
3
- * NaturalPersonNameTypeCode
4
- *
5
- * `ALIA` Alias name - A name other than the legal name by which a natural person is also known.
6
- * `BIRT` Name at birth - The name given to a natural person at birth.
7
- * `MAID` Maiden name - The original name of a natural person who has changed their name after marriage.
8
- * `LEGL` Legal name - The name that identifies a natural person for legal, official or administrative purposes.
9
- * `MISC` Unspecified - A name by which a natural person may be known but which cannot otherwise be categorized or the category of which the sender is unable to determine.
10
- */
11
- export type NaturalPersonNameTypeCode = 'ALIA' | 'BIRT' | 'MAID' | 'LEGL' | 'MISC';
12
- /**
13
- * 5.3.9
14
- * LegalPersonNameTypeCode
15
- *
16
- * `LEGL` Legal name - Official name under which an organisation is registered.
17
- * `SHRT` Short name - Specifies the short name of the organisation.
18
- * `TRAD` Trading name - Name used by a business for commercial purposes, although its registered legal name, used for contracts and other formal situations, may be another.
19
- */
20
- export type LegalPersonNameTypeCode = 'LEGL' | 'SHRT' | 'TRAD';
21
- /**
22
- * 5.3.11
23
- * AddressTypeCode
24
- *
25
- * `HOME` Residential - Address is the home address.
26
- * `BIZZ` Business - Address is the business address.
27
- * `GEOG` Geographic - Address is the unspecified physical (geographical) address suitable for identification of the natural or legal person.
28
- */
29
- export type AddressTypeCode = 'HOME' | 'BIZZ' | 'GEOG';
30
- /**
31
- * 5.3.14
32
- * NationalIdentifierTypeCode
33
- *
34
- * `ARNU` Alien registration number - Number assigned by a government agency to identify foreign nationals.
35
- * `CCPT` Passport number - Number assigned by a passport authority.
36
- * `RAID` Registration authority identifier - Identifier of a legal entity as maintained by a registration authority.
37
- * `DRLC` Driver license number - Number assigned to a driver's license.
38
- * `FIIN` Foreign investment identity number - Number assigned to a foreign investor (other than the alien number).
39
- * `TXID` Tax identification number - Number assigned by a tax authority to an entity.
40
- * `SOCS` Social security number - Number assigned by a social security agency.
41
- * `IDCD` Identity card number - Number assigned by a national authority to an identity card.
42
- * `LEIX` Legal Entity Identifier - Legal Entity Identifier (LEI) assigned in accordance with ISO 17442 11 .
43
- * `MISC` Unspecified - A national identifier which may be known but which cannot otherwise be categorized or the category of which the sender is unable to determine.
44
- */
45
- export type NationalIdentifierTypeCode = 'ARNU' | 'CCPT' | 'RAID' | 'DRLC' | 'FIIN' | 'TXID' | 'SOCS' | 'IDCD' | 'LEIX' | 'MISC';
46
- /**
47
- * 5.3.16
48
- * TransliterationMethodCode
49
- *
50
- * `arab` Arabic (Arabic language) - ISO 233-2:1993
51
- * `aran` Arabic (Persian language) - ISO 233-3:1999
52
- * `armn` Armenian - ISO 9985:1996
53
- * `cyrl` Cyrillic - ISO 9:1995
54
- * `deva` Devanagari & related Indic - ISO 15919:2001
55
- * `geor` Georgian - ISO 9984:1996
56
- * `grek` Greek - ISO 843:1997
57
- * `hani` Han (Hanzi, Kanji, Hanja) - ISO 7098:2015
58
- * `hebr` Hebrew - ISO 259-2:1994
59
- * `kana` Kana - ISO 3602:1989
60
- * `kore` Korean - Revised Romanization of Korean
61
- * `thai` Thai - ISO 11940-2:2007
62
- * `othr` Script other than those listed above - Unspecified
63
- */
64
- export type TransliterationMethodCode = 'arab' | 'aran' | 'armn' | 'cyrl' | 'deva' | 'geor' | 'grek' | 'hani' | 'hebr' | 'kana' | 'kore' | 'thai' | 'othr';
65
- /**
66
- * 5.2.8
67
- * NationalIdentification
68
- */
69
- export type NationalIdentification = {
70
- nationalIdentifier?: string;
71
- nationalIdentifierType?: NationalIdentifierTypeCode;
72
- countryOfIssue?: string;
73
- registrationAuthority?: string;
74
- };
75
- /**
76
- * 5.2.7
77
- * DateAndPlaceOfBirth
78
- */
79
- export type DateAndPlaceOfBirth = {
80
- dateOfBirth?: string;
81
- placeOfBirth?: string;
82
- };
83
- /**
84
- * 5.2.6
85
- * Address
86
- */
87
- export type Address = {
88
- addressType?: AddressTypeCode;
89
- department?: string;
90
- subDepartment?: string;
91
- streetName?: string;
92
- buildingNumber?: string;
93
- buildingName?: string;
94
- floor?: string;
95
- postBox?: string;
96
- room?: string;
97
- postCode?: string;
98
- townName?: string;
99
- townLocationName?: string;
100
- districtName?: string;
101
- countrySubDivision?: string;
102
- addressLine?: string[];
103
- country?: string;
104
- };
105
- /**
106
- * 5.2.5
107
- * LocalNaturalPersonNameID
108
- */
109
- export type LocalNaturalPersonNameID = {
110
- primaryIdentifier?: string;
111
- secondaryIdentifier?: string;
112
- nameIdentifierType?: NaturalPersonNameTypeCode;
113
- };
114
- /**
115
- * 5.2.4
116
- * NaturalPersonNameID
117
- */
118
- export type NaturalPersonNameID = {
119
- primaryIdentifier?: string;
120
- secondaryIdentifier?: string;
121
- nameIdentifierType?: NaturalPersonNameTypeCode;
122
- };
123
- /**
124
- * 5.2.3
125
- * NaturalPersonName
126
- */
127
- export type NaturalPersonName = {
128
- nameIdentifier?: NaturalPersonNameID[];
129
- localNameIdentifier?: LocalNaturalPersonNameID[];
130
- phoneticNameIdentifier?: LocalNaturalPersonNameID[];
131
- };
132
- /**
133
- * 5.2.2
134
- * NaturalPerson
135
- */
136
- export type NaturalPerson = {
137
- name?: NaturalPersonName[];
138
- geographicAddress?: Address[];
139
- nationalIdentification?: NationalIdentification;
140
- customerIdentification?: string;
141
- dateAndPlaceOfBirth?: DateAndPlaceOfBirth;
142
- countryOfResidence?: string;
143
- };
144
- /**
145
- * 5.2.12
146
- * LocalLegalPersonNameID
147
- */
148
- export type LocalLegalPersonNameID = {
149
- legalPersonName?: string;
150
- legalPersonNameIdentifierType?: LegalPersonNameTypeCode;
151
- };
152
- /**
153
- * 5.2.11
154
- * LegalPersonNameID
155
- */
156
- export type LegalPersonNameID = {
157
- legalPersonName?: string;
158
- legalPersonNameIdentifierType?: LegalPersonNameTypeCode;
159
- };
160
- /**
161
- * 5.2.10
162
- * LegalPersonName
163
- */
164
- export type LegalPersonName = {
165
- nameIdentifier?: LegalPersonNameID[];
166
- localNameIdentifier?: LocalLegalPersonNameID[];
167
- phoneticNameIdentifier?: LocalLegalPersonNameID[];
168
- };
169
- /**
170
- * 5.2.9
171
- * LegalPerson
172
- */
173
- export type LegalPerson = {
174
- name?: LegalPersonName;
175
- geographicAddress?: Address[];
176
- customerNumber?: string;
177
- nationalIdentification?: NationalIdentification;
178
- countryOfRegistration?: string;
179
- };
180
- /**
181
- * 5.2.1
182
- * Person
183
- */
184
- export type Person = {
185
- naturalPerson?: NaturalPerson;
186
- legalPerson?: LegalPerson;
187
- };
188
- /**
189
- * 5.2.13
190
- * IntermediaryVASP
191
- */
192
- export type IntermediaryVASP = {
193
- intermediaryVASP?: Person;
194
- sequence?: number;
195
- };
196
- /**
197
- * 6.2
198
- * The originator is defined in Section 1.1 as the account holder who allows the VA transfer from that account or, where there is no account, the natural or legal person that places the order with the originating VASP to perform the VA transfer.
199
- */
200
- export type Originator = {
201
- originatorPersons?: Person[];
202
- accountNumber?: string[];
203
- };
204
- /**
205
- * 6.3
206
- * The beneficiary is defined in Section 1.1 as the natural or legal person or legal arrangement who is identified by the originator as the receiver of the requested VA transfer.
207
- */
208
- export type Beneficiary = {
209
- beneficiaryPersons?: Person[];
210
- accountNumber?: string[];
211
- };
212
- /**
213
- * 6.4
214
- * The originating VASP is defined in Section 1.1 as the VASP which initiates the VA transfer, and transfers the VA upon receiving the request for a VA transfer on behalf of the originator.
215
- */
216
- export type OriginatingVASP = {
217
- originatingVASP?: Person;
218
- };
219
- /**
220
- * 6.5
221
- * The originating VASP is defined in Section 1.1 as the VASP which initiates the VA transfer, and transfers the VA upon receiving the request for a VA transfer on behalf of the originator.
222
- */
223
- export type BeneficiaryVASP = {
224
- beneficiaryVASP?: Person;
225
- };
226
- /**
227
- * 6.6
228
- * The transfer path refers to the intermediary VASP(s) participating in a serial chain that receive(s) and retransmit(s) a VA transfer on behalf of the originating VASP and the beneficiary VASP, or another intermediary VASP, together with their corresponding sequence number.
229
- */
230
- export type TransferPath = {
231
- transferPath?: IntermediaryVASP[];
232
- };
233
- /**
234
- * 6.7
235
- * Data describing the contents of the payload.
236
- */
237
- export type PayloadMetadata = {
238
- transferPath?: TransliterationMethodCode[];
239
- };
240
- /**
241
- * IVMS101 definition
242
- *
243
- * @public
244
- */
245
- export type IVMS101 = {
246
- originator?: Originator;
247
- beneficiary?: Beneficiary;
248
- originatingVASP?: OriginatingVASP;
249
- beneficiaryVASP?: BeneficiaryVASP;
250
- transferPath?: TransferPath;
251
- payloadMetadata?: PayloadMetadata;
252
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- import EmbeddedComponent from './components/EmbeddedComponent';
2
- import type { Agent, AgentType, CallbackOptions, ComponentMessage, Counterparty, DeclarationProof, Destination, HostMessage, IVMS101, MicroTransferProof, OwnershipProof, PersonType, ProofStatus, ProofTypes, ScreenshotProof, SignatureProof, Status, Theme, Transaction, TransactionAsset, VASP, Wallet, Withdrawal } from './types';
3
- import { CMType, TransactionResponse } from './types';
4
- export type { CMType, ComponentMessage, EmbeddedComponent, HostMessage, Theme, Counterparty, Withdrawal, Transaction, TransactionResponse, Destination as destination, TransactionAsset, SignatureProof, ScreenshotProof, MicroTransferProof, DeclarationProof, Notabene, ProofStatus, ProofTypes, IVMS101, PersonType, Status, VASP, Wallet, Agent, AgentType, OwnershipProof, };
5
- /**
6
- * Configuration for the Notabene SDK
7
- *
8
- * @public
9
- */
10
- export interface NotabeneConfig {
11
- nodeUrl?: string;
12
- authToken?: string;
13
- uxUrl?: string;
14
- theme?: Theme;
15
- dictionary?: {
16
- [key: string]: string;
17
- };
18
- }
19
- /**
20
- * Primary constructor for Notabene UX elements
21
- *
22
- * @public
23
- */
24
- export default class Notabene {
25
- private nodeUrl?;
26
- private authToken?;
27
- private uxUrl;
28
- private theme?;
29
- private dictionary?;
30
- constructor(config: NotabeneConfig);
31
- componentUrl(path: string, value: Partial<Transaction>, configuration?: any, callbacks?: CallbackOptions): string;
32
- createComponent(path: string, value: Partial<Transaction>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
33
- createWithdrawalAssist(value: Partial<Withdrawal>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
34
- decodeFragmentToObject(fragment: string): Record<string, string>;
35
- }
@@ -1,60 +0,0 @@
1
- import EmbeddedComponent from './components/EmbeddedComponent';
2
- import { encodeObjectToFragment } from './utils/urls';
3
- /**
4
- * Primary constructor for Notabene UX elements
5
- *
6
- * @public
7
- */
8
- export default class Notabene {
9
- nodeUrl;
10
- authToken;
11
- uxUrl;
12
- theme;
13
- dictionary;
14
- constructor(config) {
15
- this.uxUrl = config.uxUrl || 'https://connect.notabene.id';
16
- this.nodeUrl = config.nodeUrl;
17
- this.authToken = config.authToken;
18
- this.theme = config.theme;
19
- this.dictionary = config.dictionary;
20
- }
21
- componentUrl(path, value, configuration, callbacks) {
22
- const url = new URL(this.uxUrl);
23
- url.pathname = path;
24
- const hash = encodeObjectToFragment({
25
- authToken: this.authToken,
26
- value,
27
- configuration,
28
- });
29
- url.hash = hash;
30
- if (this.nodeUrl)
31
- url.searchParams.set('nodeUrl', this.nodeUrl);
32
- if (this.theme) {
33
- url.searchParams.set('theme', JSON.stringify(this.theme));
34
- }
35
- if (this.dictionary) {
36
- url.searchParams.set('dictionary', JSON.stringify(this.dictionary));
37
- }
38
- if (callbacks) {
39
- if (callbacks.callback)
40
- url.searchParams.set('callback_url', callbacks.callback);
41
- if (callbacks.redirectUri)
42
- url.searchParams.set('redirect_uri', callbacks.redirectUri);
43
- }
44
- return url.toString();
45
- }
46
- createComponent(path, value, options, callbacks) {
47
- return new EmbeddedComponent(this.componentUrl(path, value, options, callbacks), value);
48
- }
49
- createWithdrawalAssist(value, options, callbacks) {
50
- return this.createComponent('withdrawal-assist', value, options, callbacks);
51
- }
52
- decodeFragmentToObject(fragment) {
53
- const pairs = fragment.slice(1).split('&');
54
- return pairs.reduce((obj, pair) => {
55
- const [key, value] = pair.split('=');
56
- obj[decodeURIComponent(key)] = decodeURIComponent(value);
57
- return obj;
58
- }, {});
59
- }
60
- }