-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoby.d.ts
More file actions
355 lines (355 loc) · 12.3 KB
/
moby.d.ts
File metadata and controls
355 lines (355 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
declare module moby {
export module info {
interface AppInfo {
locale?: LocaleDetails;
url: string;
version: string;
build: string;
bundle: string;
id: string;
}
interface MiniappInfo {
locale?: LocaleDetails;
id: string;
name: string;
version: string;
tags?: string[];
url?: string;
}
interface LocaleDetails {
currencyCode: string;
currencySymbol: string;
decimalSeparator: string;
groupingSeparator: string;
identifier: string;
languageCode: string;
regionCode: string;
}
function miniapp(): Promise<MiniappInfo>;
function app(): Promise<AppInfo>;
function sdk(): any;
}
export module auth {
interface MobyToken {
jwt?: JwtToken;
info: TokenInfo;
expire?: Date;
}
interface JwtToken {
access_token: string;
external_token: string;
refresh_token: string;
token_type: string;
expire: string;
}
interface TokenInfo {
type: string | null;
uid: string;
}
interface StoredTokens {
type: string | null;
uid: string;
phone?: string;
url?: string;
external: string[];
}
function parse_jwt(token: string): any;
module user {
function get_token(): Promise<MobyToken>;
function is_token_exist(): Promise<boolean>;
function logout(): Promise<boolean>;
module sms {
function login(number: string): Promise<boolean>;
function request_code(): void;
function confirm_code(code: string): Promise<boolean>;
}
module openid {
function login(url: string): Promise<boolean>;
}
}
module service {
function is_token_exist(url: string): Promise<boolean>;
function login(url: string): Promise<boolean>;
function get_token(url: string): Promise<MobyToken>;
function logout(url: string): Promise<boolean>;
}
}
export module camera {
function scan_qr(): Promise<string>;
interface CardDetails {
pan: string;
month?: string;
year?: string;
name?: string;
}
function scan_emv(): Promise<CardDetails>;
interface ImageDetails {
data: string;
width: number;
height: number;
format: string;
}
module photo {
function shot(): Promise<ImageDetails>;
}
module stream {
function start(handler: (image: ImageDetails) => void): Promise<void>;
function stop(): Promise<boolean>;
}
}
export module nfc {
function open(handler: (data: any) => void): Promise<any>;
function close(): Promise<any>;
function exchange(capdu: string[]): Promise<any>;
}
export module vpn {
module ipsec {
function open(server: string, user: string, pass: string, secret: string, just_in_app: boolean): Promise<any>;
}
module ikev2 {
function open(server: string, user: string, pass: string, remote_id: string, local_id: string, just_in_app: boolean): Promise<any>;
}
function close(): Promise<any>;
function info(): Promise<any>;
}
export module geo {
interface GeoPosition {
latitude: number;
longitude: number;
}
function get_position(): Promise<GeoPosition>;
}
export module sqlite {
function run(sql: string): Promise<any>;
function get(sql: string): Promise<any>;
function all(sql: string): Promise<any>;
}
export module storage {
function create(): Promise<boolean>;
function drop(): Promise<boolean>;
function lenght(): Promise<number>;
function keys(): Promise<string[]>;
function values(): Promise<string[]>;
interface StorageItem {
key: string;
value: string;
}
function items(): Promise<StorageItem[]>;
function includes(key: string): Promise<boolean>;
function get(key: string): Promise<string | null>;
function set(key: string, value: string): Promise<boolean>;
function del(key: string): Promise<boolean>;
}
export module firebase {
function get_token(): Promise<any>;
}
export module share {
function link(data: string): Promise<any>;
function text(data: string): Promise<any>;
function image(data: string): Promise<any>;
function file(data: string): Promise<any>;
}
export module miniapp {
function get_init_data(): Promise<string>;
function open(uuid: string, init_data: string, device_id: string): Promise<any>;
function open_url(url: string, init_data: string): Promise<any>;
function close(response_data: string): Promise<any>;
function show(uuid: string, init_data: string, device_id: string): Promise<any>;
function show_navbar(uuid: string, init_data: string, device_id: string): Promise<any>;
function show_url(url: string, init_data: string): Promise<any>;
function pop(to_root: boolean, response_data: string): Promise<any>;
interface AppDetails {
id: string;
tags: string[];
device_id?: string;
name: string;
version: string;
}
function get_installed_apps(): Promise<AppDetails[]>;
function get_app_icon(uuid: string, type: string): Promise<string>;
}
export module marketplace {
interface LinkedInfo {
wearableId: string;
}
interface InstalledInfo {
wearableId: string;
installedVersionNumber: string;
updateAvailable: boolean;
}
interface ProviderInfo {
name: string;
email: string;
site: string;
id: string;
isDefault: boolean;
}
interface ProductTypes {
id: number;
name: string;
iconUrl: string;
}
interface VirtualFeatures {
isBoot: boolean;
isDefault: boolean;
menuIndex: number;
sidebarIndex: number;
}
interface WearableFeatures {
hasGeneralCommands: boolean;
hasKeys: boolean;
hasSystemCommands: boolean;
hasJsCommands: boolean;
hasSeCommands: boolean;
hasFingerprint: boolean;
}
interface SupportedWearables {
wearableId: string;
versionNumber: string;
}
interface InfoDetails {
iconUrl: string;
id: string;
created: string;
provider: ProviderInfo;
productTypes: ProductTypes[];
comment: string;
name: string;
tags: string[];
maxInstallationsCount: number;
isVirtual: boolean;
wearableFeatures: WearableFeatures;
virtualFeatures: VirtualFeatures;
}
interface ProductInfo {
lastVersion: string;
availableInstallationSlotCount: number;
linkedWith: LinkedInfo[];
installedOn: InstalledInfo[];
info: InfoDetails;
supportedWearables: SupportedWearables[];
}
interface Products {
totalCount: number;
list: ProductInfo[];
}
function get_apps(from?: number, lenght?: number): Promise<Products>;
module app {
module sub {
function install(): Promise<unknown>;
function uninstall(): Promise<unknown>;
}
function about(id: string): ProductInfo | undefined;
function purchase(product: ProductInfo, device_id: string): Promise<boolean>;
function install(product: ProductInfo, device_id: string): Promise<boolean>;
function update(product: ProductInfo, device_id: string): Promise<boolean>;
function uninstall(product: ProductInfo, device_id: string): Promise<boolean>;
}
}
export module devices {
interface DeviceInfo {
inner_id: string;
is_virtual: boolean;
device_id: string;
name: string;
uuid: string | null;
}
interface Datagram {
session: number;
data: string;
number: number;
encrypted: boolean;
}
function list(): Promise<DeviceInfo[]>;
function scan(timeout: number, handler: (list: DeviceInfo[]) => void): Promise<DeviceInfo[]>;
function add(data: any): Promise<boolean>;
function del(device_id: string): Promise<boolean>;
function exchange(device_id: string, uuid: string, timeout: number, data: Datagram[]): Promise<Datagram[]>;
function script(device_id: string, product_id: string, type: string, variables: Object, subproduct_id?: string): Promise<boolean>;
function connect(device_id: string, uuid: string): Promise<boolean>;
function disconnect(device_id: string, uuid: string): Promise<boolean>;
}
export module utils {
function hexstring_to_bytearray(hexString: string): any[];
function bytearray_to_map(byteArray: number[]): any;
function hexstring_to_map(hexString: string): any;
function to_hex(string: string): string;
function to_string(hex: string): string;
}
enum ApiMethod {
AUTH = "AUTH",
INFO = "INFO",
SCAN_QR_CODE = "SCAN_QR_CODE",
SCAN_BANK_CARD = "SCAN_BANK_CARD",
GET_GEO = "GET_GEO",
SQLITE = "SQLITE",
VPN_SESSION = "VPN_SESSION",
NFC_SESSION = "NFC_SESSION",
NAVIGATION = "NAVIGATION",
GET_INIT_DATA = "GET_INIT_DATA",
GET_INSTALLED_APPS = "GET_INSTALLED_APPS",
GET_APP_ICON = "GET_APP_ICON",
SHARE_DATA = "SHARE_DATA",
GET_LOCALE = "GET_LOCALE",
MARKETPLACE = "MARKETPLACE",
MOBY_DEVICES = "MOBY_DEVICES",
FIREBASE = "FIREBASE",
CAMERA = "CAMERA"
}
abstract class Decodable {
static decode(from: Object): Object | null;
}
export class Error extends Decodable {
readonly code: number;
readonly description?: string;
constructor(code: number, description?: string);
static decode(from: any): Error | null;
}
export class Response {
readonly result?: Decodable;
readonly error?: Error;
readonly id: number | undefined;
constructor(nativeResponse: NativeResponse, decode?: (from: Object) => Decodable);
}
export class NativeResponse extends Decodable {
readonly id: number;
readonly result?: Object;
readonly error?: Error;
readonly more_msg?: boolean;
constructor(id: number, result?: Object, error?: Error, more_msg?: boolean);
static decode(from: any): NativeResponse | null;
}
export class jsbridge {
static debug_mode: boolean;
static emulator_mode: boolean;
static emulate_response: boolean;
private static _instance;
private handlerManager;
private osType;
private static notifications;
lastRequest: {
method: ApiMethod;
params: Object;
};
static get instance(): jsbridge;
private sendToNative;
static getOSType(): OSType;
request(method: ApiMethod, params?: Object, handler?: (response: NativeResponse) => void): boolean;
static log(message: string): void;
registerEventHandler(handler?: (response: NativeResponse) => void): void;
onResponse(object: Object): void;
static notification(data: string): void;
static get_notifications(): any;
}
enum OSType {
UNDEFINED = 0,
IOS = 1,
ANDROID = 2,
MACOS = 3
}
export {};
}
declare module MobylabsWallet {
function nativeHandler(object: Object): void;
}
declare function init(): void;