@btsd/aitu-bridge 0.7.2-canary.3 → 0.8.0-canary.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.
@@ -0,0 +1,3 @@
1
+ import type { AituBridge } from './types';
2
+ export declare const buildBridge: () => AituBridge;
3
+ //# sourceMappingURL=buildBridge.d.ts.map
package/dist/error.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- /**
2
- * @public
3
- */
4
- export declare enum BridgeErrors {
5
- PermissionDenyError = 0,
6
- PermissionSecurityDenyError = 1,
7
- OtherError = 2
8
- }
9
- /**
10
- * @public
11
- */
12
- export declare const classifyBridgeError: (e: any) => BridgeErrors;
1
+ /**
2
+ * @public
3
+ */
4
+ export declare enum BridgeErrors {
5
+ PermissionDenyError = 0,
6
+ PermissionSecurityDenyError = 1,
7
+ OtherError = 2
8
+ }
9
+ /**
10
+ * @public
11
+ */
12
+ export declare const classifyBridgeError: (e: any) => BridgeErrors;
13
13
  //# sourceMappingURL=error.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,577 +1,16 @@
1
- /**
2
- * Aitu Bridge is a JavaScript library designed to simplify integration with the Aitu Superapp.
3
- * It allows your application to access platform features such as retrieving a user’s phone number or geolocation.
4
- * {@link https://docs.aitu.io/aituapps/aitu.apps/methods | Read the official documentation to learn more.}
5
- * @packageDocumentation
6
- */
7
- export * from './error';
8
- /**
9
- * @public
10
- */
11
- export declare enum EInvokeRequest {
12
- getMe = "GetMe",
13
- getPhone = "GetPhone",
14
- getContacts = "GetContacts",
15
- getUserProfile = "GetUserProfile",
16
- enableNotifications = "AllowNotifications",
17
- disableNotifications = "DisableNotifications",
18
- enablePrivateMessaging = "EnablePrivateMessaging",
19
- disablePrivateMessaging = "DisablePrivateMessaging"
20
- }
21
- /**
22
- * @public
23
- * Represents a header menu item click handler.
24
- */
25
- export type HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;
26
- /**
27
- * @public
28
- * Represents a back arrow click handler.
29
- */
30
- export type BackArrowClickHandlerType = () => Promise<void>;
31
- /**
32
- * @public
33
- * Represents an error that can occur during NFC passport operations.
34
- */
35
- export interface NFCPassportError {
36
- /**
37
- * Error code indicating the type of NFC passport issue.
38
- *
39
- * - `nfc_passport_mismatch` — The passport does not match the requested parameters
40
- * (date of birth, passport number, expiration date).
41
- * - `nfc_document_read_failure` — Document reading error
42
- * (read errors, algorithm errors, unknown algorithms, other documents that are not passports, etc.).
43
- * - `nfc_session_timeout` — Session timeout: the document reading was not completed
44
- * in time (depends on the OS).
45
- * - `nfc_permission_denied` — The user denied NFC permission or the device has no NFC chip.
46
- * - `nfc_session_cancelled` — The user cancelled the NFC session (iOS).
47
- */
48
- code: 'nfc_passport_mismatch' | 'nfc_document_read_failure' | 'nfc_session_timeout' | 'nfc_permission_denied' | 'nfc_session_cancelled';
49
- /**
50
- * Human-readable error message describing the issue.
51
- */
52
- msg: string;
53
- }
54
- /**
55
- * @public
56
- * Represents an error indicating that the app URL does not match the expected value.
57
- */
58
- export interface AppUrlDoesntMatchError {
59
- code: 'url_does_not_match';
60
- msg: string;
61
- }
62
- /**
63
- * @public
64
- * Represents a permission denied error.
65
- */
66
- export interface PermissionDeniedError {
67
- code: 'permission_denied';
68
- msg: string;
69
- meta: {
70
- can_retry: boolean;
71
- };
72
- }
73
- /**
74
- * @public
75
- * Represents phone number response.
76
- */
77
- export interface GetPhoneResponse {
78
- phone: string;
79
- sign: string;
80
- }
81
- /**
82
- * @public
83
- * Represents user information response.
84
- */
85
- export interface GetMeResponse {
86
- name: string;
87
- lastname: string;
88
- id: string;
89
- avatar?: string;
90
- avatarThumb?: string;
91
- notifications_allowed: boolean;
92
- private_messaging_enabled: boolean;
93
- sign: string;
94
- }
95
- /**
96
- * @public
97
- * Represents a generic response object.
98
- */
99
- export interface ResponseObject {
100
- phone?: string;
101
- name?: string;
102
- lastname?: string;
103
- }
104
- /**
105
- * @public
106
- * Represents a geographic location response.
107
- */
108
- export interface GetGeoResponse {
109
- latitude: number;
110
- longitude: number;
111
- }
112
- /**
113
- * @public
114
- * Represents a contacts list response.
115
- */
116
- export interface GetContactsResponse {
117
- contacts: Array<{
118
- first_name: string;
119
- last_name: string;
120
- phone: string;
121
- }>;
122
- sign: string;
123
- }
124
- /**
125
- * @public
126
- * Represents a selected contact response.
127
- */
128
- export interface SelectContactResponse {
129
- phone: string;
130
- name: string;
131
- lastname: string;
132
- }
133
- /**
134
- * @public
135
- * Represents a user profile response.
136
- */
137
- export interface GetUserProfileResponse {
138
- name: string;
139
- lastname?: string;
140
- phone?: string;
141
- avatar?: string;
142
- avatarThumb?: string;
143
- }
144
- /**
145
- * @public
146
- * Represents header menu item icons.
147
- */
148
- export declare enum HeaderMenuIcon {
149
- Search = "Search",
150
- ShoppingCart = "ShoppingCart",
151
- Menu = "Menu",
152
- Share = "Share",
153
- Notifications = "Notifications",
154
- Help = "Help",
155
- Error = "Error",
156
- Person = "Person",
157
- Sort = "Sort",
158
- Filter = "Filter",
159
- Close = "Close",
160
- SystemNotifications = "SystemNotifications"
161
- }
162
- /**
163
- * @public
164
- * Represents navigation item display modes.
165
- */
166
- export declare enum NavigationItemMode {
167
- SystemBackArrow = "SystemBackArrow",
168
- CustomBackArrow = "CustomBackArrow",
169
- NoItem = "NoItem",
170
- UserProfile = "UserProfile"
171
- }
172
- /**
173
- * @public
174
- * Represents a header menu item.
175
- */
176
- export interface HeaderMenuItem {
177
- id: string;
178
- icon: HeaderMenuIcon;
179
- badge?: string;
180
- }
181
- /**
182
- * @public
183
- * Represents user steps per day.
184
- */
185
- export interface UserStepsPerDay {
186
- date: string;
187
- steps: number;
188
- }
189
- /**
190
- * @public
191
- * Represents a user step information response.
192
- */
193
- export interface UserStepInfoResponse {
194
- steps: UserStepsPerDay[];
195
- }
196
- /**
197
- * @public
198
- * Represents a successful response.
199
- */
200
- export type SuccessResponse = 'success';
201
- /**
202
- * @public
203
- * Represents the status of a response.
204
- *
205
- * - `success` — The operation completed successfully.
206
- * - `failed` — The operation failed.
207
- */
208
- export type ResponseType = SuccessResponse | 'failed';
209
- /**
210
- * @public
211
- * Represents biometry check response.
212
- */
213
- export type BiometryResponse = ResponseType | 'unavailable' | 'cancelled';
214
- /**
215
- * @public
216
- * Represents passport data read from an NFC chip.
217
- */
218
- export interface PassportDataResponse {
219
- documentNumber: string;
220
- dateOfBirth: string;
221
- dateOfExpiry: string;
222
- firstName: string;
223
- lastName: string;
224
- gender: string;
225
- nationality: string;
226
- documentType: string;
227
- }
228
- /**
229
- * @public
230
- * Generic bridge invocation type.
231
- */
232
- export type BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;
233
- /**
234
- * @public
235
- * Interface for persistent key-value storage.
236
- */
237
- export interface BridgeStorage {
238
- setItem: (keyName: string, keyValue: string) => Promise<void>;
239
- getItem: (keyName: string) => Promise<string | null>;
240
- clear: () => Promise<void>;
241
- }
242
- /**
243
- * @public
244
- * Main interface for interacting with the Aitu Bridge API.
245
- */
246
- export interface AituBridge {
247
- /**
248
- * Version of the Aitu Bridge API available in SemVer format.
249
- */
250
- version: string;
251
- /**
252
- * Low-level bridge invocation method used internally
253
- * to communicate with native Aitu functionality.
254
- */
255
- invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;
256
- /**
257
- * Provides access to persistent key-value storage
258
- * scoped to the current mini-app.
259
- */
260
- storage: BridgeStorage;
261
- /**
262
- * Returns basic information about the currently authorized user.
263
- * @returns A promise resolving to a {@link GetMeResponse} containing user details.
264
- */
265
- getMe: () => Promise<GetMeResponse>;
266
- /**
267
- * Requests the user's phone number after explicit user confirmation.
268
- * @returns A promise resolving to a {@link GetPhoneResponse} containing the phone number.
269
- */
270
- getPhone: () => Promise<GetPhoneResponse>;
271
- /**
272
- * Requests access to the user's contact list.
273
- * @returns A promise resolving to a {@link GetContactsResponse} containing the contacts.
274
- */
275
- getContacts: () => Promise<GetContactsResponse>;
276
- /**
277
- * Retrieves the user's current geographic location.
278
- * @returns A promise resolving to a {@link GetGeoResponse} containing latitude and longitude.
279
- */
280
- getGeo: () => Promise<GetGeoResponse>;
281
- /**
282
- * Opens the native contact picker UI and allows the user
283
- * to select a single contact.
284
- * @returns A promise resolving to a {@link SelectContactResponse} containing the selected contact details.
285
- */
286
- selectContact: () => Promise<SelectContactResponse>;
287
- /**
288
- * Opens the device camera and scans a QR code.
289
- * @returns A string with the result of scanning the QR code is returned.
290
- */
291
- getQr: () => Promise<string>;
292
- /**
293
- * Requests an SMS verification code from the user.
294
- * @returns A string with code is returned.
295
- */
296
- getSMSCode: () => Promise<string>;
297
- /**
298
- * Retrieves public profile information for a specific user.
299
- *
300
- * @param userId - Aitu user identifier
301
- * @returns A promise resolving to a {@link GetUserProfileResponse} containing the user's profile data.
302
- */
303
- getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;
304
- /**
305
- * Opens the user's profile within the host application.
306
- * @returns A promise that resolves with a {@link ResponseType} indicating the result of the operation.
307
- */
308
- openUserProfile: () => Promise<ResponseType>;
309
- /**
310
- * Opens the system share dialog with a text payload.
311
- *
312
- * @param text - Text to share
313
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the sharing operation.
314
- */
315
- share: (text: string) => Promise<ResponseType>;
316
- /**
317
- * Sets the title displayed in the mini-app header.
318
- *
319
- * @param text - Header title
320
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the operation.
321
- */
322
- setTitle: (text: string) => Promise<ResponseType>;
323
- /**
324
- * Copies the specified text to the system clipboard.
325
- *
326
- * @param text - Text to copy
327
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the copy operation.
328
- */
329
- copyToClipboard: (text: string) => Promise<ResponseType>;
330
- /**
331
- * Shares an image with an optional text description.
332
- *
333
- * @deprecated Use {@link AituBridge.shareFile} instead.
334
- * @param text - Description text
335
- * @param image - Image data encoded in Base64
336
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the sharing operation.
337
- */
338
- shareImage: (text: string, image: string) => Promise<ResponseType>;
339
- /**
340
- * Shares a file via the system sharing interface.
341
- *
342
- * @param text - Description text
343
- * @param filename - Name of the file
344
- * @param base64Data - File data encoded in Base64
345
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the sharing operation.
346
- */
347
- shareFile: (text: string, filename: string, base64Data: string) => Promise<ResponseType>;
348
- /**
349
- * Enables push notifications for the mini-app.
350
- */
351
- enableNotifications: () => Promise<{}>;
352
- /**
353
- * Disables push notifications for the mini-app.
354
- */
355
- disableNotifications: () => Promise<{}>;
356
- /**
357
- * Enables private messaging between the mini-app and the user.
358
- *
359
- * @param appId - Mini-app identifier
360
- */
361
- enablePrivateMessaging: (appId: string) => Promise<string>;
362
- /**
363
- * Disables private messaging between the mini-app and the user.
364
- *
365
- * @param appId - Mini-app identifier
366
- */
367
- disablePrivateMessaging: (appId: string) => Promise<string>;
368
- /**
369
- * Opens the Aitu application settings screen.
370
- * @returns A promise resolving to a ResponseType indicating the result of the operation.
371
- */
372
- openSettings: () => Promise<ResponseType>;
373
- /**
374
- * Closes the current mini-app.
375
- * @returns A promise resolving to a ResponseType indicating the result of the operation.
376
- */
377
- closeApplication: () => Promise<ResponseType>;
378
- /**
379
- * Registers a handler that is triggered when the device is shaken.
380
- * @param handler - Shake event handler
381
- */
382
- setShakeHandler: (handler: any) => void;
383
- /**
384
- * Registers a handler that is triggered when a tab becomes active.
385
- *
386
- * @param handler - Callback with active tab name
387
- */
388
- setTabActiveHandler: (handler: (tabname: string) => void) => void;
389
- /**
390
- * Triggers device vibration using a custom vibration pattern.
391
- *
392
- * @param pattern - Array of vibration durations in milliseconds
393
- * @returns A promise resolving to a {@link SuccessResponse} indicating the result of the vibration operation.
394
- */
395
- vibrate: (pattern: number[]) => Promise<SuccessResponse>;
396
- /**
397
- * Indicates whether the current environment supports Aitu Bridge.
398
- * @returns A boolean indicating support status.
399
- */
400
- isSupported: () => boolean;
401
- /**
402
- * Checks whether a specific bridge method is supported.
403
- *
404
- * @param method - Method name
405
- * @returns A boolean indicating support status.
406
- */
407
- supports: (method: string) => boolean;
408
- /**
409
- * Subscribes to Aitu Bridge events.
410
- */
411
- sub: any;
412
- /**
413
- * Enables protection against screenshots and screen recording.
414
- */
415
- enableScreenCapture: () => Promise<{}>;
416
- /**
417
- * Disables protection against screenshots and screen recording.
418
- */
419
- disableScreenCapture: () => Promise<{}>;
420
- /**
421
- * Sets custom menu items in the mini-app header.
422
- *
423
- * @param items - Header menu configuration
424
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the operation.
425
- */
426
- setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;
427
- /**
428
- * Registers a click handler for header menu items.
429
- * @param handler - Header menu item click handler
430
- */
431
- setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;
432
- /**
433
- * Enables or disables custom back arrow handling.
434
- *
435
- * @param enabled - Whether custom handling is enabled
436
- * @returns A promise resolving to a ResponseType indicating the result of the operation.
437
- */
438
- setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;
439
- /**
440
- * Returns whether custom back arrow mode is enabled.
441
- * @returns A promise resolving to a boolean indicating the current mode.
442
- */
443
- getCustomBackArrowMode: () => Promise<boolean>;
444
- /**
445
- * Controls the visibility of the custom back arrow.
446
- *
447
- * @param visible - Arrow visibility state
448
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the operation.
449
- */
450
- setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
451
- /**
452
- * Opens the payment interface for a specified transaction.
453
- * @param transactionId - Transaction identifier
454
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the payment operation.
455
- */
456
- openPayment: (transactionId: string) => Promise<ResponseType>;
457
- /**
458
- * Sets a custom handler for back arrow click events.
459
- * @param handler - Back arrow click handler
460
- */
461
- setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
462
- /**
463
- * Checks biometric authentication status.
464
- * @returns A promise resolving to a {@link BiometryResponse} indicating the result of the check.
465
- */
466
- checkBiometry: () => Promise<BiometryResponse>;
467
- /**
468
- * Opens an external URL outside the mini-app context.
469
- *
470
- * @param url - External URL to open
471
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the operation.
472
- */
473
- openExternalUrl: (url: string) => Promise<ResponseType>;
474
- /**
475
- * Enables swipe-back navigation gesture.
476
- * @returns A promise resolving to a {@link ResponseType} when the gesture is enabled.
477
- */
478
- enableSwipeBack: () => Promise<ResponseType>;
479
- /**
480
- * Disables swipe-back navigation gesture.
481
- * @returns A promise resolving to a {@link ResponseType} when the gesture is disabled.
482
- */
483
- disableSwipeBack: () => Promise<ResponseType>;
484
- /**
485
- * Sets the navigation item display mode.
486
- *
487
- * @param mode - Navigation item mode
488
- * @returns A promise that resolves when the mode is set.
489
- */
490
- setNavigationItemMode: (mode: NavigationItemMode) => Promise<void>;
491
- /**
492
- * Returns the current navigation item mode.
493
- * @returns A promise resolving to the current {@link NavigationItemMode}.
494
- */
495
- getNavigationItemMode: () => Promise<NavigationItemMode>;
496
- /**
497
- * Retrieves step count data from HealthKit or Google Fit.
498
- * @returns A promise resolving to a {@link UserStepInfoResponse} containing the user's step data.
499
- */
500
- getUserStepInfo: () => Promise<UserStepInfoResponse>;
501
- /**
502
- * Checks whether eSIM is supported on the device.
503
- * @returns A promise resolving to a {@link ResponseType} indicating if eSIM is supported.
504
- */
505
- isESimSupported: () => Promise<ResponseType>;
506
- /**
507
- * Activates an eSIM using the provided activation code.
508
- *
509
- * @param activationCode - eSIM activation code
510
- * @returns A promise resolving to a {@link ResponseType} indicating the result of the activation.
511
- */
512
- activateESim: (activationCode: string) => Promise<ResponseType>;
513
- /**
514
- * Reads raw data from an NFC tag.
515
- * @returns A promise resolving to a string containing the raw NFC data.
516
- */
517
- readNFCData: () => Promise<string>;
518
- /**
519
- * Subscribes to user step updates from HealthKit/Google Fit.
520
- *
521
- * Establishes a real-time subscription that listens for step count changes
522
- * from the underlying health data provider. The promise resolves once the
523
- * subscription request has been processed. To stop receiving updates, call
524
- * {@link AituBridge.unsubscribeUserStepInfo}.
525
- *
526
- * @returns A promise that resolves with a `ResponseType` indicating
527
- * whether the subscription was successfully created.
528
- */
529
- subscribeUserStepInfo: () => Promise<ResponseType>;
530
- /**
531
- * Unsubscribes from user step updates from HealthKit/Google Fit.
532
- *
533
- * Stops the active step-count subscription created by
534
- * {@link AituBridge.subscribeUserStepInfo}. Once unsubscribed, no further step updates
535
- * will be delivered.
536
- *
537
- * @returns A promise that resolves with a `ResponseType` indicating
538
- * whether the unsubscription was successful.
539
- */
540
- unsubscribeUserStepInfo: () => Promise<ResponseType>;
541
- /**
542
- * Reads data from the NFC chip of an ePassport using BAC (Basic Access Control).
543
- *
544
- * Initiates a BAC-protected NFC read operation on an ePassport. The caller must
545
- * provide the passport number, date of birth, and expiration date—values taken
546
- * from the machine-readable zone (MRZ). These values are used to derive the
547
- * cryptographic access keys required by BAC to open a secure session with the
548
- * passport’s NFC chip.
549
- *
550
- * Once BAC is successfully established, the function retrieves data groups
551
- * from the chip, typically including the holder’s biographical information
552
- * (DG1) and, if supported and permitted, biometric data such as the facial
553
- * image (DG2).
554
- *
555
- * @param passportNumber - Passport number taken from the MRZ.
556
- * @param dateOfBirth - Holder’s date of birth (MRZ format: YYMMDD).
557
- * @param expirationDate - Passport expiration date (MRZ format: YYMMDD).
558
- *
559
- * @returns A promise resolving to a `PassportDataResponse` containing the decoded
560
- * data groups read from the passport’s NFC chip.
561
- *
562
- * @throws {@link NFCPassportError} When an NFC passport operation fails. Possible codes:
563
- * - `nfc_passport_mismatch` — Passport does not match the provided MRZ values.
564
- * - `nfc_document_read_failure` — General failure to read the document.
565
- * - `nfc_session_timeout` — NFC session timed out before completion.
566
- * - `nfc_permission_denied` — NFC permission denied or NFC unavailable.
567
- * - `nfc_session_cancelled` — User cancelled the NFC session (iOS).
568
- */
569
- readNFCPassport: (passportNumber: string, dateOfBirth: string, expirationDate: string) => Promise<PassportDataResponse>;
570
- }
571
- /**
572
- * @public
573
- * AituBridge instance for interacting with the Aitu mini-app environment.
574
- */
575
- declare const bridge: AituBridge;
576
- export default bridge;
1
+ /**
2
+ * Aitu Bridge is a JavaScript library designed to simplify integration with the Aitu Superapp.
3
+ * It allows your application to access platform features such as retrieving a user’s phone number or geolocation.
4
+ * {@link https://docs.aitu.io/aituapps/aitu.apps/methods | Read the official documentation to learn more.}
5
+ * @packageDocumentation
6
+ */
7
+ export * from './error';
8
+ export type { BackArrowClickHandlerType, HeaderMenuItemClickHandlerType, NFCPassportError, PermissionDeniedError, AppUrlDoesntMatchError, AituEventHandler, GetPhoneResponse, GetMeResponse, ResponseObject, GetGeoResponse, GetContactsResponse, SelectContactResponse, GetUserProfileResponse, HeaderMenuItem, UserStepsPerDay, UserStepInfoResponse, SuccessResponse, BiometryResponse, PassportDataResponse, BridgeInvoke, BridgeStorage, AituBridge, } from './types';
9
+ export { HeaderMenuIcon, NavigationItemMode, EInvokeRequest } from './types';
10
+ /**
11
+ * @public
12
+ * AituBridge instance for interacting with the Aitu mini-app environment.
13
+ */
14
+ declare const bridge: import("./types").AituBridge;
15
+ export default bridge;
577
16
  //# sourceMappingURL=index.d.ts.map