1 | /**
|
2 | * Represents [`DetailedError`](/api/client/detailederror/).
|
3 | */
|
4 | export interface IDetailedError<D> extends Error {
|
5 | /**
|
6 | * The error details.
|
7 | */
|
8 | details?: D;
|
9 | }
|
10 | /**
|
11 | * A function which [`Logger`](/api/client/logger/) uses to log messages. It
|
12 | * takes an optional message and any number of additional params.
|
13 | */
|
14 | export declare type LogFn = (message?: any, ...optionalParams: any[]) => void;
|
15 | /**
|
16 | * The options for [`Logger`](/api/client/logger/).
|
17 | */
|
18 | export interface LoggerOptions {
|
19 | /**
|
20 | * If silent is `true`, the `Logger`'s `infofn` and `warnfn` will not be
|
21 | * called.
|
22 | */
|
23 | silent?: boolean;
|
24 | }
|
25 | /**
|
26 | * Represents a [`Logger`](/api/client/logger/).
|
27 | */
|
28 | export interface ILogger {
|
29 | /**
|
30 | * The function to use to log info level messages.
|
31 | */
|
32 | infofn: LogFn;
|
33 | /**
|
34 | * The function to use to log warn level messages.
|
35 | */
|
36 | warnfn: LogFn;
|
37 | /**
|
38 | * The function to use to log error level messages.
|
39 | */
|
40 | errorfn: LogFn;
|
41 | /**
|
42 | * Send a log at info level.
|
43 | *
|
44 | * @param message - The message to log.
|
45 | */
|
46 | info(message?: any, ...optionalParams: any[]): any;
|
47 | /**
|
48 | * Send a log at warn level.
|
49 | *
|
50 | * @param message - The message to log.
|
51 | */
|
52 | warn(message?: any, ...optionalParams: any[]): any;
|
53 | /**
|
54 | * Send a log at error level.
|
55 | *
|
56 | * @param message - The message to log.
|
57 | */
|
58 | error(message?: any, ...optionalParams: any[]): any;
|
59 | }
|
60 | /**
|
61 | * @hidden
|
62 | */
|
63 | export interface CloudSettingsUrls {
|
64 | api?: string;
|
65 | web?: string;
|
66 | }
|
67 | /**
|
68 | * General settings for the Cloud Client.
|
69 | */
|
70 | export interface CoreSettings {
|
71 | /**
|
72 | * Your app ID.
|
73 | */
|
74 | app_id: string;
|
75 | /**
|
76 | * @hidden
|
77 | */
|
78 | urls?: CloudSettingsUrls;
|
79 | }
|
80 | /**
|
81 | * The settings object for the Cloud Client.
|
82 | *
|
83 | * `CloudSettings` contains various specific configuration sections, acting more
|
84 | * like a parent object for them.
|
85 | *
|
86 | * @featured
|
87 | */
|
88 | export interface CloudSettings {
|
89 | /**
|
90 | * General settings for the Cloud Client.
|
91 | */
|
92 | core: CoreSettings;
|
93 | /**
|
94 | * Settings for Push Notifications.
|
95 | */
|
96 | push?: PushOptions;
|
97 | /**
|
98 | * Log settings.
|
99 | */
|
100 | logger?: LoggerOptions;
|
101 | }
|
102 | /**
|
103 | * @hidden
|
104 | */
|
105 | export interface IConfig {
|
106 | settings: CloudSettings;
|
107 | register(settings: CloudSettings): any;
|
108 | get(name: string): any;
|
109 | getURL(name: string): string;
|
110 | }
|
111 | /**
|
112 | * Represents a [`Client`](/api/client/client/).
|
113 | */
|
114 | export interface IClient {
|
115 | baseUrl: string;
|
116 | get(endpoint: string): any;
|
117 | post(endpoint: string): any;
|
118 | put(endpoint: string): any;
|
119 | patch(endpoint: string): any;
|
120 | delete(endpoint: string): any;
|
121 | request(method: string, endpoint: string): any;
|
122 | }
|
123 | /**
|
124 | * A function which [`EventEmitter`](/api/client/eventemitter/) uses to handle
|
125 | * events.
|
126 | *
|
127 | * All event handlers have a single parameter: `data`, which is always an
|
128 | * object and which will differ depending on the event.
|
129 | */
|
130 | export declare type EventHandler = (data: Object) => any;
|
131 | /**
|
132 | * Represents an [`EventReceiver`](/api/client/eventreceiver/).
|
133 | */
|
134 | export interface IEventReceiver {
|
135 | key: string | number;
|
136 | event: string;
|
137 | handler: EventHandler;
|
138 | }
|
139 | /**
|
140 | * Represents an [`EventEmitter`](/api/client/eventemitter/).
|
141 | */
|
142 | export interface IEventEmitter {
|
143 | on(event: string, callback: EventHandler): any;
|
144 | off(receiver: IEventReceiver): any;
|
145 | once(event: string, callback: () => void): any;
|
146 | emit(event: string, data?: Object): any;
|
147 | emitted(event: string): number;
|
148 | }
|
149 | /**
|
150 | * @hidden
|
151 | */
|
152 | export interface StorageDependencies {
|
153 | strategy: IStorageStrategy;
|
154 | }
|
155 | /**
|
156 | * @hidden
|
157 | */
|
158 | export interface StorageOptions {
|
159 | prefix?: string;
|
160 | cache?: boolean;
|
161 | }
|
162 | /**
|
163 | * Represents a [`Storage`](/api/client/storage/).
|
164 | */
|
165 | export interface IStorage<T> {
|
166 | /**
|
167 | * Get a value from the storage by the given key.
|
168 | *
|
169 | * @param key - The storage key to get.
|
170 | */
|
171 | get(key: string): T;
|
172 | /**
|
173 | * Set a value in the storage by the given key.
|
174 | *
|
175 | * @param key - The storage key to set.
|
176 | * @param value - The value to set. (Must be JSON-serializable).
|
177 | */
|
178 | set(key: string, value: T): void;
|
179 | /**
|
180 | * Delete a value from the storage by the given key.
|
181 | *
|
182 | * @param key - The storage key to delete.
|
183 | */
|
184 | delete(key: string): void;
|
185 | }
|
186 | /**
|
187 | * @hidden
|
188 | */
|
189 | export interface IStorageStrategy {
|
190 | get(key: string): string;
|
191 | set(key: string, value: string): void;
|
192 | delete(key: string): void;
|
193 | }
|
194 | /**
|
195 | * @hidden
|
196 | */
|
197 | export interface DeviceIsConnectedToNetworkOptions {
|
198 | strictMode?: boolean;
|
199 | }
|
200 | /**
|
201 | * @hidden
|
202 | */
|
203 | export interface DeviceDependencies {
|
204 | emitter: IEventEmitter;
|
205 | }
|
206 | /**
|
207 | * @hidden
|
208 | */
|
209 | export interface IDevice {
|
210 | deviceType: string;
|
211 | isAndroid(): boolean;
|
212 | isIOS(): boolean;
|
213 | }
|
214 | /**
|
215 | * @hidden
|
216 | */
|
217 | export interface CordovaDependencies {
|
218 | appStatus: AppStatus;
|
219 | device: IDevice;
|
220 | emitter: IEventEmitter;
|
221 | logger: ILogger;
|
222 | }
|
223 | /**
|
224 | * @hidden
|
225 | */
|
226 | export interface CordovaOptions {
|
227 | }
|
228 | /**
|
229 | * @hidden
|
230 | */
|
231 | export interface ICordova {
|
232 | app: AppStatus;
|
233 | bootstrap(): void;
|
234 | }
|
235 | /**
|
236 | * @hidden
|
237 | */
|
238 | export interface CoreDependencies {
|
239 | config: IConfig;
|
240 | logger: ILogger;
|
241 | emitter: IEventEmitter;
|
242 | insights: IInsights;
|
243 | }
|
244 | /**
|
245 | * @hidden
|
246 | */
|
247 | export interface ICore {
|
248 | version: string;
|
249 | init(): void;
|
250 | }
|
251 | /**
|
252 | * @hidden
|
253 | */
|
254 | export interface UserContextDependencies {
|
255 | config: IConfig;
|
256 | storage: IStorage<StoredUser>;
|
257 | }
|
258 | /**
|
259 | * @hidden
|
260 | */
|
261 | export interface IUserContext {
|
262 | label: string;
|
263 | load(user: IUser): IUser;
|
264 | store(user: IUser): void;
|
265 | unstore(): void;
|
266 | }
|
267 | /**
|
268 | * Represents a locally stored user (usually in local storage).
|
269 | */
|
270 | export interface StoredUser {
|
271 | id: string;
|
272 | data: Object;
|
273 | details: Object;
|
274 | social: Object;
|
275 | fresh: boolean;
|
276 | }
|
277 | /**
|
278 | * @hidden
|
279 | */
|
280 | export interface IUserData {
|
281 | data: Object;
|
282 | get(key: string, defaultValue: any): any;
|
283 | set(key: string, value: any): any;
|
284 | unset(key: string): any;
|
285 | }
|
286 | /**
|
287 | * The user details common to us and you, used in email/password
|
288 | * authentication.
|
289 | *
|
290 | * We store common fields such as `email` and `password` separate from your
|
291 | * custom data to avoid name clashes.
|
292 | */
|
293 | export interface UserDetails {
|
294 | /**
|
295 | * The user's email address.
|
296 | *
|
297 | * We enforce email address correctness server-side.
|
298 | */
|
299 | email?: string;
|
300 | /**
|
301 | * The user's password.
|
302 | *
|
303 | * We enforce no password requirements and expect you to implement
|
304 | * client-side password requirements that best suit your app.
|
305 | */
|
306 | password?: string;
|
307 | /**
|
308 | * A username unique to the user.
|
309 | *
|
310 | * You can use it in addition to `email` to identify your users. Uniqueness
|
311 | * is enforced on this field.
|
312 | */
|
313 | username?: string;
|
314 | /**
|
315 | * A URL to an image for the user.
|
316 | *
|
317 | * `image` defaults to a generic user avatar hosted by us.
|
318 | */
|
319 | image?: string;
|
320 | /**
|
321 | * The user's full (first + last) name, generally used for display.
|
322 | */
|
323 | name?: string;
|
324 | /**
|
325 | * TODO: Better way to handle this?
|
326 | *
|
327 | * @hidden
|
328 | */
|
329 | custom?: Object;
|
330 | }
|
331 | /**
|
332 | * @hidden
|
333 | */
|
334 | export interface UserDependencies {
|
335 | service: ISingleUserService;
|
336 | }
|
337 | /**
|
338 | * The user social details we collect from the social networks for social
|
339 | * authentication.
|
340 | *
|
341 | * `UserSocialDetails` is a container. Depending on which social providers you
|
342 | * use, the details are accessible as their respective fields.
|
343 | */
|
344 | export interface UserSocialDetails {
|
345 | /**
|
346 | * The provider details for Facebook Authentication.
|
347 | */
|
348 | facebook?: UserSocialProviderDetails;
|
349 | /**
|
350 | * The provider details for Github Authentication.
|
351 | */
|
352 | github?: UserSocialProviderDetails;
|
353 | /**
|
354 | * The provider details for Twitter Authentication.
|
355 | */
|
356 | twitter?: UserSocialProviderDetails;
|
357 | /**
|
358 | * The provider details for Instagram Authentication.
|
359 | */
|
360 | instagram?: UserSocialProviderDetails;
|
361 | /**
|
362 | * The provider details for Google Authentication.
|
363 | */
|
364 | google?: UserSocialProviderDetails;
|
365 | /**
|
366 | * The provider details for LinkedIn Authentication.
|
367 | */
|
368 | linkedin?: UserSocialProviderDetails;
|
369 | }
|
370 | /**
|
371 | * More general information from the social network.
|
372 | *
|
373 | * Although these details have the same keys and types regardless of the social
|
374 | * providers you use, we don't guarantee every field has a value. Some networks
|
375 | * don't give us `email`, others don't give us `username`.
|
376 | */
|
377 | export interface UserSocialProviderDetailsData {
|
378 | /**
|
379 | * The email address of the user on the social network.
|
380 | */
|
381 | email: string;
|
382 | /**
|
383 | * The username of the user on the social network.
|
384 | */
|
385 | username: string;
|
386 | /**
|
387 | * The full (first + last) name of the user on the social network.
|
388 | */
|
389 | full_name: string;
|
390 | /**
|
391 | * A URL to the profile picture of the user on the social network.
|
392 | */
|
393 | profile_picture: string;
|
394 | /**
|
395 | * Raw data about this user from the network.
|
396 | *
|
397 | * It is generally unsafe to rely on raw data, as we can't promise social
|
398 | * networks won't change the format. For developers that like to live on the
|
399 | * wild side, enjoy.
|
400 | */
|
401 | raw_data: Object;
|
402 | }
|
403 | /**
|
404 | * The provider-specific user social details.
|
405 | *
|
406 | * These details have the same keys and types no matter what social providers
|
407 | * you use.
|
408 | */
|
409 | export interface UserSocialProviderDetails {
|
410 | /**
|
411 | * The ID of the user in the social network.
|
412 | */
|
413 | uid: string;
|
414 | /**
|
415 | * More general information from the social network.
|
416 | */
|
417 | data: UserSocialProviderDetailsData;
|
418 | }
|
419 | /**
|
420 | * Represents a [`User`](/api/client/user/).
|
421 | */
|
422 | export interface IUser {
|
423 | /**
|
424 | * The UUID of this user.
|
425 | */
|
426 | id: string;
|
427 | /**
|
428 | * Is this user fresh, meaning they haven't been persisted?
|
429 | */
|
430 | fresh: boolean;
|
431 | /**
|
432 | * The details (email, password, etc) of this user.
|
433 | */
|
434 | details: UserDetails;
|
435 | /**
|
436 | * The social details of this user.
|
437 | */
|
438 | social: UserSocialDetails;
|
439 | /**
|
440 | * The custom data of this user.
|
441 | */
|
442 | data: IUserData;
|
443 | /**
|
444 | * Check whether this user is anonymous or not.
|
445 | */
|
446 | isAnonymous(): boolean;
|
447 | /**
|
448 | * Get a value from this user's custom data.
|
449 | *
|
450 | * Optionally, a default value can be provided.
|
451 | *
|
452 | * @param key - The data key to get.
|
453 | * @param defaultValue - The value to return if the key is absent.
|
454 | */
|
455 | get(key: string, defaultValue: any): any;
|
456 | /**
|
457 | * Set a value in this user's custom data.
|
458 | *
|
459 | * @param key - The data key to set.
|
460 | * @param value - The value to set.
|
461 | */
|
462 | set(key: string, value: any): any;
|
463 | /**
|
464 | * Delete a value from this user's custom data.
|
465 | *
|
466 | * @param key - The data key to delete.
|
467 | */
|
468 | unset(key: string): any;
|
469 | /**
|
470 | * Revert this user to a fresh, anonymous state.
|
471 | */
|
472 | clear(): any;
|
473 | /**
|
474 | * Store this user in local storage.
|
475 | */
|
476 | store(): any;
|
477 | /**
|
478 | * Remove this user from local storage.
|
479 | */
|
480 | unstore(): any;
|
481 | /**
|
482 | * Save this user to the API.
|
483 | */
|
484 | save(): Promise<void>;
|
485 | /**
|
486 | * Delete this user from the API.
|
487 | */
|
488 | delete(): Promise<void>;
|
489 | /**
|
490 | * Load the user from the API, overwriting the local user's data.
|
491 | *
|
492 | * @param id - The user ID to load into this user.
|
493 | */
|
494 | load(id?: string): Promise<void>;
|
495 | serializeForAPI(): UserDetails;
|
496 | serializeForStorage(): StoredUser;
|
497 | }
|
498 | /**
|
499 | * @hidden
|
500 | */
|
501 | export interface SingleUserServiceDependencies {
|
502 | client: IClient;
|
503 | context: IUserContext;
|
504 | }
|
505 | /**
|
506 | * @hidden
|
507 | */
|
508 | export interface SingleUserServiceOptions {
|
509 | }
|
510 | /**
|
511 | * @hidden
|
512 | */
|
513 | export interface ISingleUserService {
|
514 | current(): IUser;
|
515 | store(): any;
|
516 | unstore(): any;
|
517 | load(id?: string): Promise<void>;
|
518 | delete(): Promise<void>;
|
519 | save(): Promise<void>;
|
520 | }
|
521 | /**
|
522 | * @hidden
|
523 | */
|
524 | export interface TokenContextDependencies {
|
525 | storage: IStorage<string>;
|
526 | }
|
527 | /**
|
528 | * @hidden
|
529 | */
|
530 | export interface ITokenContextStoreOptions {
|
531 | }
|
532 | /**
|
533 | * @hidden
|
534 | */
|
535 | export interface ITokenContext {
|
536 | label: string;
|
537 | get(): string;
|
538 | store(token: string, options: ITokenContextStoreOptions): void;
|
539 | delete(): void;
|
540 | }
|
541 | /**
|
542 | * @hidden
|
543 | */
|
544 | export interface CombinedTokenContextDependencies extends TokenContextDependencies {
|
545 | tempStorage: IStorage<string>;
|
546 | }
|
547 | /**
|
548 | * @hidden
|
549 | */
|
550 | export interface ICombinedTokenContextStoreOptions extends ITokenContextStoreOptions {
|
551 | permanent?: boolean;
|
552 | }
|
553 | /**
|
554 | * @hidden
|
555 | */
|
556 | export interface ICombinedTokenContext extends ITokenContext {
|
557 | store(token: string, options: ICombinedTokenContextStoreOptions): void;
|
558 | }
|
559 | /**
|
560 | * These are the IDs of the valid [authentication
|
561 | * providers](/services/users/#providers).
|
562 | *
|
563 | * @featured
|
564 | */
|
565 | export declare type AuthModuleId = 'basic' | 'custom' | 'facebook' | 'github' | 'google' | 'instagram' | 'linkedin' | 'twitter';
|
566 | /**
|
567 | * @hidden
|
568 | */
|
569 | export interface AuthTypeDependencies {
|
570 | config: IConfig;
|
571 | client: IClient;
|
572 | }
|
573 | /**
|
574 | * A container object that [`login()`](/api/client/auth#login) resolves with.
|
575 | */
|
576 | export interface AuthLoginResult {
|
577 | /**
|
578 | * The raw auth token string.
|
579 | */
|
580 | token: string;
|
581 | /**
|
582 | * For social authentication, we create a user account the first time a user
|
583 | * logs in. When `true`, this flag indicates the user has just signed up for
|
584 | * the first time.
|
585 | */
|
586 | signup?: boolean;
|
587 | }
|
588 | /**
|
589 | * @hidden
|
590 | */
|
591 | export interface IAuthType {
|
592 | authenticate(data: any, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
593 | }
|
594 | /**
|
595 | * @hidden
|
596 | */
|
597 | export interface BasicLoginCredentials {
|
598 | email: string;
|
599 | password: string;
|
600 | }
|
601 | /**
|
602 | * @hidden
|
603 | */
|
604 | export interface IBasicAuthType extends IAuthType {
|
605 | signup(data: UserDetails): Promise<void>;
|
606 | requestPasswordReset(email: string): Promise<void>;
|
607 | confirmPasswordReset(email: string, code: number, newPassword: string): Promise<void>;
|
608 | }
|
609 | /**
|
610 | * @hidden
|
611 | */
|
612 | export interface IAuthModules {
|
613 | basic: IBasicAuthType;
|
614 | custom: IAuthType;
|
615 | facebook: IAuthType;
|
616 | github: IAuthType;
|
617 | google: IAuthType;
|
618 | instagram: IAuthType;
|
619 | linkedin: IAuthType;
|
620 | twitter: IAuthType;
|
621 | }
|
622 | /**
|
623 | * Options for [`login()`](/api/client/auth/#login).
|
624 | *
|
625 | * [`Auth`](/api/client/auth/) uses the InAppBrowser plugin to redirect the
|
626 | * user through authentication. We expose settings for when we open a plugin
|
627 | * window.
|
628 | */
|
629 | export interface AuthLoginOptions {
|
630 | /**
|
631 | * If `true`, the user's session is persisted in local storage, but not
|
632 | * guaranteed to be remembered.
|
633 | */
|
634 | remember?: boolean;
|
635 | /**
|
636 | * The options for the InAppBrowser window that is opened.
|
637 | */
|
638 | inAppBrowserOptions?: InAppBrowserPluginOptions;
|
639 | }
|
640 | /**
|
641 | * @hidden
|
642 | */
|
643 | export interface AuthDependencies {
|
644 | config: IConfig;
|
645 | emitter: IEventEmitter;
|
646 | authModules: IAuthModules;
|
647 | tokenContext: ICombinedTokenContext;
|
648 | userService: ISingleUserService;
|
649 | storage: IStorage<string>;
|
650 | }
|
651 | /**
|
652 | * @hidden
|
653 | */
|
654 | export interface AuthOptions {
|
655 | }
|
656 | /**
|
657 | * Represents [`Auth`](/api/client/auth/).
|
658 | */
|
659 | export interface IAuth {
|
660 | /**
|
661 | * Link the user to this URL for password resets. Only for email/password
|
662 | * authentication.
|
663 | */
|
664 | passwordResetUrl: string;
|
665 | /**
|
666 | * Check whether the user is logged in or not.
|
667 | */
|
668 | isAuthenticated(): boolean;
|
669 | /**
|
670 | * Attempt to log the user in with the given credentials.
|
671 | *
|
672 | * @param moduleId
|
673 | * The authentication provider module ID to use with this login.
|
674 | * @param credentials
|
675 | * Email and password object.
|
676 | * @param options
|
677 | * Options for this login such as whether to remember the login.
|
678 | */
|
679 | login(moduleId: 'basic', credentials: BasicLoginCredentials, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
680 | /**
|
681 | * Kick-off the custom authentication process.
|
682 | *
|
683 | * @param moduleId
|
684 | * The authentication provider module ID to use with this login.
|
685 | * @param credentials
|
686 | * Send whatever details you need to authenticate your custom users.
|
687 | * @param options
|
688 | * Options for this login, such as whether to remember the login and
|
689 | * InAppBrowser window options.
|
690 | */
|
691 | login(moduleId: 'custom', credentials: Object, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
692 | /**
|
693 | * Attempt to log the user in with the given credentials. For custom & social
|
694 | * logins, kick-off the authentication process.
|
695 | *
|
696 | * After login, the full user is loaded from the cloud and saved in local
|
697 | * storage along with their auth token.
|
698 | *
|
699 | * @param moduleId
|
700 | * The authentication provider module ID to use with this login.
|
701 | * @param credentials
|
702 | * For email/password authentication, give an email and password. For social
|
703 | * authentication, exclude this parameter. For custom authentication, send
|
704 | * whatever you need.
|
705 | * @param options
|
706 | * Options for this login, such as whether to remember the login and
|
707 | * InAppBrowser window options for authentication providers that make use of
|
708 | * it.
|
709 | */
|
710 | login(moduleId: AuthModuleId, credentials?: Object, options?: AuthLoginOptions): Promise<AuthLoginResult>;
|
711 | /**
|
712 | * Log the user out of the app.
|
713 | *
|
714 | * This clears the auth token out of local storage and restores the user to
|
715 | * an unauthenticated state.
|
716 | */
|
717 | logout(): void;
|
718 | /**
|
719 | * Sign up a user with the given data. Only for email/password
|
720 | * authentication.
|
721 | *
|
722 | * @param details - The details that describe a user.
|
723 | */
|
724 | signup(data: UserDetails): Promise<void>;
|
725 | /**
|
726 | * Kick-off the password reset process. Only for email/password
|
727 | * authentication.
|
728 | *
|
729 | * @param email - The email address to which to send a code.
|
730 | */
|
731 | requestPasswordReset(email: string): Promise<void>;
|
732 | /**
|
733 | * Confirm a password reset.
|
734 | *
|
735 | * @param code - The password reset code from the user.
|
736 | * @param newPassword - The requested changed password from the user.
|
737 | */
|
738 | confirmPasswordReset(code: number, newPassword: string): Promise<void>;
|
739 | }
|
740 | /**
|
741 | * Simple status flags of an app.
|
742 | */
|
743 | export interface AppStatus {
|
744 | /**
|
745 | * When `true`, the app was asleep when this was constructed.
|
746 | */
|
747 | asleep?: boolean;
|
748 | /**
|
749 | * When `true`, the app was closed when this was constructed.
|
750 | */
|
751 | closed?: boolean;
|
752 | }
|
753 | /**
|
754 | * @hidden
|
755 | */
|
756 | export interface PushPluginRegistration {
|
757 | registrationId: string;
|
758 | }
|
759 | /**
|
760 | * Additional data from the Push Plugin.
|
761 | */
|
762 | export interface PushPluginNotificationAdditionalData {
|
763 | /**
|
764 | * Whether the notification was received while the app was in the foreground.
|
765 | */
|
766 | foreground: boolean;
|
767 | /**
|
768 | * Will be `true` if the application is started by clicking on the push
|
769 | * notification, `false` if the app is already started.
|
770 | */
|
771 | coldstart: boolean;
|
772 | [key: string]: any;
|
773 | }
|
774 | /**
|
775 | * The notification object received from the Push Plugin.
|
776 | *
|
777 | * Full documentation and examples can be found on the Push Plugin's
|
778 | * [README](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushonnotification-callback).
|
779 | */
|
780 | export interface PushPluginNotification {
|
781 | /**
|
782 | * The text of the push message sent from the 3rd party service.
|
783 | */
|
784 | message: string;
|
785 | /**
|
786 | * The optional title of the push message sent from the 3rd party service.
|
787 | */
|
788 | title: string;
|
789 | /**
|
790 | * The number of messages to be displayed in the badge in iOS/Android or
|
791 | * message count in the notification shade in Android. For windows, it
|
792 | * represents the value in the badge notification which could be a number or
|
793 | * a status glyph.
|
794 | */
|
795 | count: number;
|
796 | /**
|
797 | * The name of the sound file to be played upon receipt of the notification.
|
798 | */
|
799 | sound: string;
|
800 | /**
|
801 | * The path of the image file to be displayed in the notification.
|
802 | */
|
803 | image: string;
|
804 | /**
|
805 | * The args to be passed to the application on launch from push notification.
|
806 | * This works when notification is received in background. (Windows Only)
|
807 | */
|
808 | launchArgs: string;
|
809 | /**
|
810 | * An optional collection of data sent by the 3rd party push service that
|
811 | * does not fit in the above properties.
|
812 | */
|
813 | additionalData: PushPluginNotificationAdditionalData;
|
814 | }
|
815 | /**
|
816 | * Represents a [`PushMessage`](/api/client/pushmessage/).
|
817 | */
|
818 | export interface IPushMessage {
|
819 | /**
|
820 | * Native information about the app when the push message was received.
|
821 | */
|
822 | app: AppStatus;
|
823 | /**
|
824 | * The message of this push message.
|
825 | */
|
826 | text: string;
|
827 | /**
|
828 | * The title of this push message.
|
829 | */
|
830 | title: string;
|
831 | /**
|
832 | * The badge count that was set by this push message.
|
833 | */
|
834 | count: number;
|
835 | /**
|
836 | * The sound that was played by this push message.
|
837 | */
|
838 | sound: string;
|
839 | /**
|
840 | * The image of this push message.
|
841 | */
|
842 | image: string;
|
843 | /**
|
844 | * The custom payload of this push message.
|
845 | */
|
846 | payload: Object;
|
847 | raw: PushPluginNotification;
|
848 | }
|
849 | /**
|
850 | * The object received when your app is sent a push notification. To learn how
|
851 | * to handle push notifications, [go to the Push
|
852 | * docs](/services/push/#handling-notifications).
|
853 | *
|
854 | * Internally, this is the object for the `push:notification` event from the
|
855 | * [`EventEmitter`](/api/client/eventemitter/).
|
856 | *
|
857 | * @featured
|
858 | */
|
859 | export interface PushNotificationEvent {
|
860 | /**
|
861 | * The push message.
|
862 | */
|
863 | message: IPushMessage;
|
864 | /**
|
865 | * The raw push notification from the Push Plugin.
|
866 | */
|
867 | raw: PushPluginNotification;
|
868 | }
|
869 | /**
|
870 | * Options for [`saveToken()`](/api/client/push/#saveToken).
|
871 | */
|
872 | export interface PushSaveTokenOptions {
|
873 | /**
|
874 | * When `true`, do not attempt to save the token to the active user.
|
875 | */
|
876 | ignore_user?: boolean;
|
877 | }
|
878 | /**
|
879 | * @hidden
|
880 | */
|
881 | export interface PushDependencies {
|
882 | config: IConfig;
|
883 | auth: IAuth;
|
884 | userService: ISingleUserService;
|
885 | device: IDevice;
|
886 | client: IClient;
|
887 | emitter: IEventEmitter;
|
888 | storage: IStorage<PushToken>;
|
889 | logger: ILogger;
|
890 | }
|
891 | export interface PushPluginConfigAndroid {
|
892 | senderID?: string;
|
893 | icon?: string;
|
894 | iconColor?: string;
|
895 | sound?: boolean;
|
896 | vibrate?: boolean;
|
897 | clearBadge?: boolean;
|
898 | clearNotifications?: boolean;
|
899 | forceShow?: boolean;
|
900 | topics?: string[];
|
901 | }
|
902 | export interface PushPluginConfigiOS {
|
903 | alert?: boolean | string;
|
904 | badge?: boolean | string;
|
905 | sound?: boolean | string;
|
906 | clearBadge?: boolean | string;
|
907 | categories?: any;
|
908 | }
|
909 | /**
|
910 | * The configuration options for the Push Plugin.
|
911 | *
|
912 | * Full documentation and examples can be found on the Push Plugin's
|
913 | * [README](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions).
|
914 | */
|
915 | export interface PushPluginConfig {
|
916 | android?: PushPluginConfigAndroid;
|
917 | ios?: PushPluginConfigiOS;
|
918 | }
|
919 | /**
|
920 | * The configuration options for an InAppBrowser window.
|
921 | *
|
922 | * Full documentation and examples can be found on the InAppBrowser Plugin's
|
923 | * [README](https://github.com/apache/cordova-plugin-inappbrowser#cordovainappbrowseropen).
|
924 | */
|
925 | export interface InAppBrowserPluginOptions {
|
926 | location?: boolean;
|
927 | hidden?: boolean;
|
928 | clearcache?: boolean;
|
929 | clearsessioncache?: boolean;
|
930 | zoom?: boolean;
|
931 | hardwareback?: boolean;
|
932 | mediaPlaybackRequiresUserAction?: boolean;
|
933 | closebuttoncaption?: string;
|
934 | disallowoverscroll?: boolean;
|
935 | toolbar?: boolean;
|
936 | enableViewportScale?: boolean;
|
937 | allowInlineMediaPlayback?: boolean;
|
938 | keyboardDisplayRequiresUserAction?: boolean;
|
939 | suppressesIncrementalRendering?: boolean;
|
940 | presentationstyle?: "pagesheet" | "formsheet" | "fullscreen";
|
941 | transitionstyle?: "fliphorizontal" | "crossdissolve" | "coververtical";
|
942 | toolbarposition?: "top" | "bottom";
|
943 | fullscreen?: boolean;
|
944 | }
|
945 | /**
|
946 | * Settings for Push Notifications.
|
947 | */
|
948 | export interface PushOptions {
|
949 | /**
|
950 | * The GCM project ID.
|
951 | */
|
952 | sender_id?: string;
|
953 | /**
|
954 | * When `true`, debug logs for push notifications are enabled.
|
955 | */
|
956 | debug?: boolean;
|
957 | /**
|
958 | * Configuration options to pass onto the Push Plugin.
|
959 | */
|
960 | pluginConfig?: PushPluginConfig;
|
961 | }
|
962 | /**
|
963 | * A push token which is constructed from a APNS/GCM device token.
|
964 | *
|
965 | * @featured
|
966 | */
|
967 | export interface PushToken {
|
968 | /**
|
969 | * The token ID on the API.
|
970 | */
|
971 | id?: string;
|
972 | /**
|
973 | * The token type (or platform), e.g. 'android' or 'ios'
|
974 | */
|
975 | type?: 'android' | 'ios';
|
976 | /**
|
977 | * Has the push token been registered with APNS/GCM?
|
978 | */
|
979 | registered?: boolean;
|
980 | /**
|
981 | * Has the push token been saved to the API?
|
982 | */
|
983 | saved?: boolean;
|
984 | /**
|
985 | * The raw push device token.
|
986 | */
|
987 | token: string;
|
988 | }
|
989 | /**
|
990 | * Represents [`Push`](/api/client/push/).
|
991 | */
|
992 | export interface IPush {
|
993 | options: PushOptions;
|
994 | /**
|
995 | * The push plugin (window.PushNotification).
|
996 | */
|
997 | plugin: any;
|
998 | /**
|
999 | * The push token of the device.
|
1000 | */
|
1001 | token: PushToken;
|
1002 | /**
|
1003 | * Register a token with the API.
|
1004 | *
|
1005 | * When a token is saved, you can send push notifications to it. If a user is
|
1006 | * logged in, the token is linked to them by their ID.
|
1007 | *
|
1008 | * @param token - The token.
|
1009 | * @param options
|
1010 | */
|
1011 | saveToken(token: PushToken, options: PushSaveTokenOptions): Promise<PushToken>;
|
1012 | /**
|
1013 | * Registers the device with GCM/APNS to get a push token.
|
1014 | */
|
1015 | register(): Promise<PushToken>;
|
1016 | /**
|
1017 | * Invalidate the current push token.
|
1018 | */
|
1019 | unregister(): Promise<void>;
|
1020 | }
|
1021 | /**
|
1022 | * Options for [`download()`](/api/client/deploy/#download).
|
1023 | */
|
1024 | export interface DeployDownloadOptions {
|
1025 | /**
|
1026 | * Attach a progress handler for the download.
|
1027 | *
|
1028 | * `p` is a number from 0 to 100, representing the download progress.
|
1029 | */
|
1030 | onProgress?: (p: number) => void;
|
1031 | }
|
1032 | /**
|
1033 | * Options for [`extract()`](/api/client/deploy/#extract).
|
1034 | */
|
1035 | export interface DeployExtractOptions {
|
1036 | /**
|
1037 | * Attach a progress handler for the extraction process.
|
1038 | *
|
1039 | * `p` is a number from 0 to 100, representing the extraction progress.
|
1040 | */
|
1041 | onProgress?: (p: number) => void;
|
1042 | }
|
1043 | /**
|
1044 | * These are the valid deploy channels. `DeployChannel` can also be any string,
|
1045 | * allowing for custom channel tags.
|
1046 | *
|
1047 | * @featured
|
1048 | */
|
1049 | export declare type DeployChannel = 'dev' | 'staging' | 'production' | string;
|
1050 | /**
|
1051 | * @hidden
|
1052 | */
|
1053 | export interface DeployOptions {
|
1054 | }
|
1055 | /**
|
1056 | * @hidden
|
1057 | */
|
1058 | export interface DeployDependencies {
|
1059 | config: IConfig;
|
1060 | emitter: IEventEmitter;
|
1061 | logger: ILogger;
|
1062 | }
|
1063 | /**
|
1064 | * Represents a [`Deploy`](/api/client/deploy/).
|
1065 | */
|
1066 | export interface IDeploy {
|
1067 | options: DeployOptions;
|
1068 | /**
|
1069 | * The active deploy channel. Set this to change the channel on which
|
1070 | * `Deploy` operates.
|
1071 | */
|
1072 | channel: DeployChannel;
|
1073 | /**
|
1074 | * Check for updates on the active channel.
|
1075 | *
|
1076 | * The promise resolves with a boolean. When `true`, a new snapshot exists on
|
1077 | * the channel.
|
1078 | */
|
1079 | check(): Promise<boolean>;
|
1080 | /**
|
1081 | * Download the available snapshot.
|
1082 | *
|
1083 | * @param options
|
1084 | * Options for this download, such as a progress callback.
|
1085 | */
|
1086 | download(options?: DeployDownloadOptions): Promise<boolean>;
|
1087 | /**
|
1088 | * Extract the downloaded snapshot.
|
1089 | *
|
1090 | * @param options
|
1091 | */
|
1092 | extract(options?: DeployExtractOptions): Promise<boolean>;
|
1093 | /**
|
1094 | * Immediately reload the app with the latest deployed snapshot.
|
1095 | */
|
1096 | load(): any;
|
1097 | /**
|
1098 | * Get information about the current snapshot.
|
1099 | */
|
1100 | info(): Promise<any>;
|
1101 | /**
|
1102 | * List the snapshots that have been installed on this device.
|
1103 | *
|
1104 | * The promise is resolved with an array of snapshot UUIDs.
|
1105 | */
|
1106 | getSnapshots(): Promise<any>;
|
1107 | /**
|
1108 | * Remove a snapshot from this device.
|
1109 | *
|
1110 | * @param uuid
|
1111 | * The snapshot UUID to remove from the device.
|
1112 | */
|
1113 | deleteSnapshot(uuid: string): Promise<any>;
|
1114 | /**
|
1115 | * Fetches the metadata for a given snapshot. If no UUID is given, it will
|
1116 | * attempt to grab the metadata for the most recently known snapshot.
|
1117 | *
|
1118 | * @param uuid
|
1119 | * The snapshot from which to grab metadata.
|
1120 | */
|
1121 | getMetadata(uuid: string): Promise<any>;
|
1122 | }
|
1123 | /**
|
1124 | * @hidden
|
1125 | */
|
1126 | export interface IStatSerialized {
|
1127 | app_id: string;
|
1128 | stat: string;
|
1129 | value: number;
|
1130 | created: string;
|
1131 | }
|
1132 | /**
|
1133 | * @hidden
|
1134 | */
|
1135 | export interface InsightsDependencies {
|
1136 | appStatus: AppStatus;
|
1137 | storage: IStorage<string>;
|
1138 | config: IConfig;
|
1139 | client: IClient;
|
1140 | logger: ILogger;
|
1141 | }
|
1142 | /**
|
1143 | * @hidden
|
1144 | */
|
1145 | export interface InsightsOptions {
|
1146 | intervalSubmit?: number;
|
1147 | intervalActiveCheck?: number;
|
1148 | submitCount?: number;
|
1149 | }
|
1150 | /**
|
1151 | * @hidden
|
1152 | */
|
1153 | export interface IInsights {
|
1154 | track(stat: string, value?: number): void;
|
1155 | }
|