@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,363 +0,0 @@
1
- ## API Report File for "@notabene/javascript-sdk"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- // @public
8
- export interface Agent {
9
- // Warning: (ae-forgotten-export) The symbol "DID" needs to be exported by the entry point notabene.d.ts
10
- //
11
- // (undocumented)
12
- did: DID;
13
- // (undocumented)
14
- logo?: string;
15
- // (undocumented)
16
- name?: string;
17
- // (undocumented)
18
- type: AgentType;
19
- // (undocumented)
20
- url?: string;
21
- // (undocumented)
22
- verified?: boolean;
23
- }
24
-
25
- // @public
26
- export enum AgentType {
27
- // (undocumented)
28
- PRIVATE = "WALLET",
29
- // (undocumented)
30
- VASP = "VASP"
31
- }
32
-
33
- // Warning: (ae-internal-missing-underscore) The name "CMType" should be prefixed with an underscore because the declaration is marked as @internal
34
- //
35
- // @internal
36
- export const enum CMType {
37
- // (undocumented)
38
- CANCEL = "cancel",
39
- // (undocumented)
40
- CLOSE = "closeModal",
41
- // (undocumented)
42
- COMPLETE = "complete",
43
- // (undocumented)
44
- ERROR = "error",
45
- // (undocumented)
46
- INVALID = "invalid",
47
- // (undocumented)
48
- MODAL = "openModal",
49
- // (undocumented)
50
- READY = "ready",
51
- // (undocumented)
52
- RESIZE = "resize",
53
- // (undocumented)
54
- RESULT = "result"
55
- }
56
-
57
- // Warning: (ae-forgotten-export) The symbol "Completed" needs to be exported by the entry point notabene.d.ts
58
- // Warning: (ae-forgotten-export) The symbol "Cancel" needs to be exported by the entry point notabene.d.ts
59
- // Warning: (ae-forgotten-export) The symbol "Error_2" needs to be exported by the entry point notabene.d.ts
60
- // Warning: (ae-forgotten-export) The symbol "Result" needs to be exported by the entry point notabene.d.ts
61
- // Warning: (ae-forgotten-export) The symbol "Ready" needs to be exported by the entry point notabene.d.ts
62
- // Warning: (ae-forgotten-export) The symbol "ResizeRequest" needs to be exported by the entry point notabene.d.ts
63
- // Warning: (ae-forgotten-export) The symbol "ModalRequest" needs to be exported by the entry point notabene.d.ts
64
- // Warning: (ae-forgotten-export) The symbol "InvalidValue" needs to be exported by the entry point notabene.d.ts
65
- // Warning: (ae-forgotten-export) The symbol "CloseModal" needs to be exported by the entry point notabene.d.ts
66
- // Warning: (ae-internal-missing-underscore) The name "ComponentMessage" should be prefixed with an underscore because the declaration is marked as @internal
67
- //
68
- // @internal
69
- export type ComponentMessage = Completed | Cancel | Error_2 | Result | Ready | ResizeRequest | ModalRequest | InvalidValue | CloseModal;
70
-
71
- // @public
72
- export interface Counterparty {
73
- // (undocumented)
74
- accountNumber?: string;
75
- // (undocumented)
76
- did?: string;
77
- // (undocumented)
78
- geographicAddress?: string;
79
- // (undocumented)
80
- name?: string;
81
- // (undocumented)
82
- type?: PersonType;
83
- // (undocumented)
84
- verified?: boolean;
85
- }
86
-
87
- // @public
88
- export interface DeclarationProof extends OwnershipProof {
89
- // (undocumented)
90
- attestation: string;
91
- // (undocumented)
92
- confirmed: boolean;
93
- // (undocumented)
94
- type: ProofTypes.SelfDeclaration;
95
- }
96
-
97
- // Warning: (ae-forgotten-export) The symbol "BlockchainAddress" needs to be exported by the entry point notabene.d.ts
98
- // Warning: (ae-forgotten-export) The symbol "CAIP19" needs to be exported by the entry point notabene.d.ts
99
- // Warning: (ae-forgotten-export) The symbol "TravelAddress" needs to be exported by the entry point notabene.d.ts
100
- //
101
- // @public
102
- export type destination = BlockchainAddress | CAIP19 | TravelAddress;
103
-
104
- // @public
105
- export class EmbeddedComponent {
106
- constructor(url: string, value: Partial<Transaction>);
107
- // (undocumented)
108
- completion(): Promise<TransactionResponse>;
109
- // Warning: (ae-forgotten-export) The symbol "ValidationError" needs to be exported by the entry point notabene.d.ts
110
- //
111
- // (undocumented)
112
- get errors(): ValidationError[];
113
- // (undocumented)
114
- mount(parentId: string): void;
115
- // (undocumented)
116
- off(messageType: string, callback: MessageCallback): void;
117
- // Warning: (ae-forgotten-export) The symbol "MessageCallback" needs to be exported by the entry point notabene.d.ts
118
- //
119
- // (undocumented)
120
- on(messageType: string, callback: MessageCallback): void;
121
- // (undocumented)
122
- open(): void;
123
- // Warning: (ae-incompatible-release-tags) The symbol "send" is marked as @public, but its signature references "HostMessage" which is marked as @internal
124
- //
125
- // (undocumented)
126
- send(message: HostMessage): void;
127
- // (undocumented)
128
- update(value: Partial<Transaction>): void;
129
- // (undocumented)
130
- get url(): string;
131
- // (undocumented)
132
- get value(): Partial<Transaction>;
133
- }
134
-
135
- // Warning: (ae-forgotten-export) The symbol "UpdateValue" needs to be exported by the entry point notabene.d.ts
136
- // Warning: (ae-forgotten-export) The symbol "RequestResponse" needs to be exported by the entry point notabene.d.ts
137
- // Warning: (ae-internal-missing-underscore) The name "HostMessage" should be prefixed with an underscore because the declaration is marked as @internal
138
- //
139
- // @internal
140
- export type HostMessage = UpdateValue | RequestResponse;
141
-
142
- // @public
143
- export type IVMS101 = {
144
- originator?: Originator;
145
- beneficiary?: Beneficiary;
146
- originatingVASP?: OriginatingVASP;
147
- beneficiaryVASP?: BeneficiaryVASP;
148
- transferPath?: TransferPath;
149
- payloadMetadata?: PayloadMetadata;
150
- };
151
-
152
- // @public
153
- export interface MicroTransferProof extends OwnershipProof {
154
- // (undocumented)
155
- amount: number;
156
- // Warning: (ae-forgotten-export) The symbol "CAIP2" needs to be exported by the entry point notabene.d.ts
157
- //
158
- // (undocumented)
159
- chain: CAIP2;
160
- // (undocumented)
161
- txhash: string;
162
- // (undocumented)
163
- type: ProofTypes.MicroTransfer;
164
- }
165
-
166
- // @public
167
- class Notabene {
168
- constructor(config: NotabeneConfig);
169
- // Warning: (ae-forgotten-export) The symbol "CallbackOptions" needs to be exported by the entry point notabene.d.ts
170
- //
171
- // (undocumented)
172
- componentUrl(path: string, value: Partial<Transaction>, configuration?: any, callbacks?: CallbackOptions): string;
173
- // (undocumented)
174
- createComponent(path: string, value: Partial<Transaction>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
175
- // (undocumented)
176
- createWithdrawalAssist(value: Partial<Withdrawal>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
177
- // (undocumented)
178
- decodeFragmentToObject(fragment: string): Record<string, string>;
179
- }
180
- export { Notabene }
181
- export default Notabene;
182
-
183
- // @public
184
- export interface NotabeneConfig {
185
- // (undocumented)
186
- authToken?: string;
187
- // (undocumented)
188
- dictionary?: {
189
- [key: string]: string;
190
- };
191
- // (undocumented)
192
- nodeUrl?: string;
193
- // (undocumented)
194
- theme?: Theme;
195
- // (undocumented)
196
- uxUrl?: string;
197
- }
198
-
199
- // @public
200
- export interface OwnershipProof {
201
- // Warning: (ae-forgotten-export) The symbol "CAIP10" needs to be exported by the entry point notabene.d.ts
202
- //
203
- // (undocumented)
204
- address: CAIP10;
205
- // (undocumented)
206
- did: DID;
207
- // (undocumented)
208
- status: ProofStatus;
209
- // (undocumented)
210
- type: ProofTypes;
211
- }
212
-
213
- // @public
214
- export enum PersonType {
215
- // (undocumented)
216
- LEGAL = "legal",
217
- // (undocumented)
218
- NATURAL = "natural",
219
- // (undocumented)
220
- SELF = "self"
221
- }
222
-
223
- // @public
224
- export enum ProofStatus {
225
- // (undocumented)
226
- FAILED = "rejected",// Verification is pending
227
- // (undocumented)
228
- FLAGGED = "flagged",// Rejected
229
- // (undocumented)
230
- PENDING = "pending",// Flagged for manual review
231
- // (undocumented)
232
- VERIFIED = "verified"
233
- }
234
-
235
- // @public
236
- export enum ProofTypes {
237
- // (undocumented)
238
- MicroTransfer = "microtransfer",
239
- // (undocumented)
240
- PersonalSignBIP137 = "bip-137",
241
- // (undocumented)
242
- PersonalSignEIP191 = "eip-191",
243
- // (undocumented)
244
- PersonalSignEIP712 = "eip-712",
245
- // (undocumented)
246
- PersonalSignXPUB = "xpub",
247
- // (undocumented)
248
- Screenshot = "screenshot",
249
- // (undocumented)
250
- SelfDeclaration = "self-declaration"
251
- }
252
-
253
- // @public
254
- export interface ScreenshotProof extends OwnershipProof {
255
- // (undocumented)
256
- type: ProofTypes.Screenshot;
257
- // (undocumented)
258
- url: string;
259
- }
260
-
261
- // @public
262
- export interface SignatureProof extends OwnershipProof {
263
- // (undocumented)
264
- attestation: string;
265
- // (undocumented)
266
- proof: string;
267
- // (undocumented)
268
- type: ProofTypes.PersonalSignEIP191 | ProofTypes.PersonalSignEIP712 | ProofTypes.PersonalSignBIP137 | ProofTypes.PersonalSignXPUB;
269
- // (undocumented)
270
- wallet_provider: string;
271
- }
272
-
273
- // @public
274
- export enum Status {
275
- // (undocumented)
276
- BANNED = "banned",
277
- // (undocumented)
278
- EMPTY = "empty",
279
- // (undocumented)
280
- PENDING = "pending",
281
- // (undocumented)
282
- VERIFIED = "verified",
283
- // (undocumented)
284
- VERIFY = "verify"
285
- }
286
-
287
- // @public
288
- export type Theme = {
289
- primaryColor: string;
290
- secondaryColor: string;
291
- fontFamily: string;
292
- logo: string;
293
- };
294
-
295
- // @public
296
- export interface Transaction {
297
- // (undocumented)
298
- agent: Agent;
299
- // (undocumented)
300
- amountDecimal: number;
301
- // (undocumented)
302
- asset: TransactionAsset;
303
- // (undocumented)
304
- counterparty: Counterparty;
305
- // (undocumented)
306
- customAssetPrice?: {
307
- price: number;
308
- currency: string;
309
- };
310
- // (undocumented)
311
- customer?: Counterparty;
312
- }
313
-
314
- // Warning: (ae-forgotten-export) The symbol "NotabeneAsset" needs to be exported by the entry point notabene.d.ts
315
- // Warning: (ae-forgotten-export) The symbol "DTI" needs to be exported by the entry point notabene.d.ts
316
- //
317
- // @public
318
- export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
319
-
320
- // @public
321
- export type TransactionResponse = {
322
- value: Transaction;
323
- ivms: IVMS101;
324
- proof?: OwnershipProof;
325
- valid: boolean;
326
- status: Status;
327
- errors: ValidationError[];
328
- };
329
-
330
- // @public
331
- export interface VASP extends Agent {
332
- // (undocumented)
333
- name?: string;
334
- // (undocumented)
335
- url?: string;
336
- }
337
-
338
- // @public
339
- export interface Wallet extends Agent {
340
- // (undocumented)
341
- proof: OwnershipProof;
342
- // (undocumented)
343
- wallet_connect_id?: string;
344
- }
345
-
346
- // Warning: (ae-forgotten-export) The symbol "BeneficiaryFields" needs to be exported by the entry point notabene.d.ts
347
- //
348
- // @public
349
- export interface Withdrawal extends BeneficiaryFields, Transaction {
350
- }
351
-
352
- // Warnings were encountered during analysis:
353
- //
354
- // ts-out/src/ivms/types.d.ts:246:5 - (ae-forgotten-export) The symbol "Originator" needs to be exported by the entry point notabene.d.ts
355
- // ts-out/src/ivms/types.d.ts:247:5 - (ae-forgotten-export) The symbol "Beneficiary" needs to be exported by the entry point notabene.d.ts
356
- // ts-out/src/ivms/types.d.ts:248:5 - (ae-forgotten-export) The symbol "OriginatingVASP" needs to be exported by the entry point notabene.d.ts
357
- // ts-out/src/ivms/types.d.ts:249:5 - (ae-forgotten-export) The symbol "BeneficiaryVASP" needs to be exported by the entry point notabene.d.ts
358
- // ts-out/src/ivms/types.d.ts:250:5 - (ae-forgotten-export) The symbol "TransferPath" needs to be exported by the entry point notabene.d.ts
359
- // ts-out/src/ivms/types.d.ts:251:5 - (ae-forgotten-export) The symbol "PayloadMetadata" needs to be exported by the entry point notabene.d.ts
360
-
361
- // (No @packageDocumentation comment for this package)
362
-
363
- ```
@@ -1 +0,0 @@
1
- export {};
@@ -1,97 +0,0 @@
1
- import { fc, test } from '@fast-check/vitest';
2
- import { describe } from 'vitest';
3
- import { abitraryCallbackOptions, arbitraryComponent } from '../arbitraries';
4
- import Notabene from '../notabene';
5
- describe('Notabene', () => {
6
- describe('defaults', () => {
7
- test.prop([
8
- fc.string({ minLength: 3 }),
9
- fc.webUrl(),
10
- arbitraryComponent(),
11
- fc.object(),
12
- ])('Should set the correct values', (authToken, nodeUrl, component, value) => {
13
- const notabene = new Notabene({
14
- nodeUrl,
15
- authToken,
16
- });
17
- const url = new URL(notabene.componentUrl(component, value));
18
- return (url.hash ===
19
- `#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}` &&
20
- url.searchParams.get('nodeUrl') === nodeUrl &&
21
- url.pathname === `/${component}`);
22
- });
23
- });
24
- describe('minimal', () => {
25
- test.prop([arbitraryComponent(), fc.object()])('Should set the correct values', (component, value) => {
26
- const notabene = new Notabene({});
27
- const url = new URL(notabene.componentUrl(component, value));
28
- return (url.hash === `#value=${encodeURIComponent(JSON.stringify(value))}` &&
29
- url.hostname === 'connect.notabene.id' &&
30
- url.pathname === `/${component}`);
31
- });
32
- });
33
- describe('with uxUrl', () => {
34
- test.prop([
35
- fc.string({ minLength: 3 }),
36
- fc.webUrl(),
37
- arbitraryComponent(),
38
- fc.webAuthority(),
39
- fc.object(),
40
- ])('Should set the correct values', (authToken, nodeUrl, component, uxAuthority, value) => {
41
- const notabene = new Notabene({
42
- nodeUrl,
43
- authToken,
44
- uxUrl: `https://${uxAuthority}`,
45
- });
46
- const url = new URL(notabene.componentUrl(component, value));
47
- const [domain, port] = uxAuthority.split(':');
48
- return (url.hostname === domain &&
49
- url.port === (port || '') &&
50
- url.hash ===
51
- `#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}` &&
52
- url.searchParams.get('nodeUrl') === nodeUrl &&
53
- url.pathname === `/${component}`);
54
- });
55
- });
56
- describe('with value and configuration', () => {
57
- test.prop([
58
- fc.string({ minLength: 3 }),
59
- fc.webUrl(),
60
- arbitraryComponent(),
61
- fc.object(),
62
- fc.object(),
63
- ])('Should set the correct values', (authToken, nodeUrl, component, value, configuration) => {
64
- const notabene = new Notabene({
65
- nodeUrl,
66
- authToken,
67
- });
68
- const url = new URL(notabene.componentUrl(component, value, configuration));
69
- return (url.hash ===
70
- `#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}&configuration=${encodeURIComponent(JSON.stringify(configuration))}` &&
71
- url.searchParams.get('nodeUrl') === nodeUrl &&
72
- url.pathname === `/${component}`);
73
- });
74
- });
75
- describe('with value and configuration', () => {
76
- test.prop([
77
- fc.string({ minLength: 3 }),
78
- fc.webUrl(),
79
- arbitraryComponent(),
80
- fc.object(),
81
- fc.object(),
82
- abitraryCallbackOptions(),
83
- ])('Should set the correct values', (authToken, nodeUrl, component, value, configuration, callbacks) => {
84
- const notabene = new Notabene({
85
- nodeUrl,
86
- authToken,
87
- });
88
- const url = new URL(notabene.componentUrl(component, value, configuration, callbacks));
89
- return (url.hash ===
90
- `#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}&configuration=${encodeURIComponent(JSON.stringify(configuration))}` &&
91
- url.searchParams.get('nodeUrl') === nodeUrl &&
92
- url.pathname === `/${component}` &&
93
- url.searchParams.get('callback_url') === callbacks.callback &&
94
- url.searchParams.get('redirect_uri') === callbacks.redirectUri);
95
- });
96
- });
97
- });
@@ -1,4 +0,0 @@
1
- import fc from 'fast-check';
2
- import { CallbackOptions } from './types';
3
- export declare const arbitraryComponent: () => fc.Arbitrary<string>;
4
- export declare const abitraryCallbackOptions: () => fc.Arbitrary<CallbackOptions>;
@@ -1,8 +0,0 @@
1
- import fc from 'fast-check';
2
- const COMPONENT_MATCHER = /^[a-z0-9-_]+$/;
3
- // Arbitraries
4
- export const arbitraryComponent = () => fc.stringMatching(COMPONENT_MATCHER);
5
- export const abitraryCallbackOptions = () => fc.record({
6
- callback: fc.webUrl(),
7
- redirectUri: fc.webUrl(),
8
- });
@@ -1,25 +0,0 @@
1
- import { HostMessage, Transaction, TransactionResponse, ValidationError } from '../types';
2
- import { MessageCallback } from '../utils/MessageEventManager';
3
- /**
4
- * An embedded Notabene component
5
- * @public
6
- */
7
- export default class EmbeddedComponent {
8
- private _url;
9
- private _value;
10
- private _errors;
11
- private iframe?;
12
- private eventManager;
13
- private ready;
14
- constructor(url: string, value: Partial<Transaction>);
15
- get url(): string;
16
- get value(): Partial<Transaction>;
17
- get errors(): ValidationError[];
18
- open(): void;
19
- mount(parentId: string): void;
20
- send(message: HostMessage): void;
21
- on(messageType: string, callback: MessageCallback): void;
22
- off(messageType: string, callback: MessageCallback): void;
23
- update(value: Partial<Transaction>): void;
24
- completion(): Promise<TransactionResponse>;
25
- }
@@ -1,87 +0,0 @@
1
- import { CMType, HMType, } from '../types';
2
- import { MessageEventManager, } from '../utils/MessageEventManager';
3
- /**
4
- * An embedded Notabene component
5
- * @public
6
- */
7
- export default class EmbeddedComponent {
8
- _url;
9
- _value;
10
- _errors = [];
11
- iframe;
12
- eventManager;
13
- ready = false;
14
- constructor(url, value) {
15
- this._url = url;
16
- this._value = value;
17
- this.eventManager = new MessageEventManager();
18
- this.on(CMType.INVALID, (message) => {
19
- if (message.type === CMType.INVALID) {
20
- this._errors = message.errors;
21
- this._value = message.value;
22
- }
23
- });
24
- this.on(CMType.RESIZE, (message) => {
25
- if (message.type === CMType.RESIZE) {
26
- if (this.iframe)
27
- this.iframe.style.height = `${message.height}px`;
28
- }
29
- });
30
- }
31
- get url() {
32
- return this._url;
33
- }
34
- get value() {
35
- return this._value;
36
- }
37
- get errors() {
38
- return this._errors;
39
- }
40
- open() {
41
- document.location.href = this.url;
42
- }
43
- mount(parentId) {
44
- this.iframe = document.createElement('iframe');
45
- this.iframe.src = this.url;
46
- this.iframe.style.width = '100%';
47
- this.iframe.style.height = '100px';
48
- this.iframe.style.border = 'none';
49
- this.iframe.style.overflow = 'hidden';
50
- window.addEventListener('message', (event) => {
51
- if (event.source !== this.iframe?.contentWindow) {
52
- return;
53
- }
54
- console.log('received message from iframe', event.data);
55
- this.eventManager?.setPort(event.ports[0]);
56
- this.ready = true;
57
- });
58
- const parent = document.querySelector(parentId);
59
- if (!parent)
60
- throw new Error(`parentID ${parentId} not found`);
61
- parent.appendChild(this.iframe);
62
- this.iframe?.contentWindow?.focus();
63
- }
64
- send(message) {
65
- this.eventManager.send(message);
66
- }
67
- on(messageType, callback) {
68
- this.eventManager.on(messageType, callback);
69
- }
70
- off(messageType, callback) {
71
- this.eventManager.off(messageType, callback);
72
- }
73
- update(value) {
74
- this._value = value;
75
- this.send({ type: HMType.UPDATE, value });
76
- }
77
- completion() {
78
- return new Promise((resolve, reject) => {
79
- this.on(CMType.COMPLETE, (message) => {
80
- resolve(message.response);
81
- });
82
- this.on('error', (message) => {
83
- reject(new Error(message.message));
84
- });
85
- });
86
- }
87
- }